Skip to content

Commit

Permalink
#80: no more CopyOnWriteArrayList
Browse files Browse the repository at this point in the history
  • Loading branch information
yegor256 committed Jun 10, 2023
1 parent e2978d5 commit c0c4040
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/main/java/com/jcabi/jdbc/JdbcSession.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Collection;
import java.util.LinkedList;
import java.util.UUID;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.atomic.AtomicReference;
Expand Down Expand Up @@ -188,8 +189,8 @@ public final class JdbcSession {
*/
@SuppressWarnings("PMD.ConstructorOnlyInitializesOrCallOtherConstructors")
public JdbcSession(final DataSource src) {
this.args = new CopyOnWriteArrayList<>();
this.preparations = new CopyOnWriteArrayList<>();
this.args = new LinkedList<>();
this.preparations = new LinkedList<>();
this.connection = new AtomicReference<>();
this.auto = true;
this.source = src;
Expand Down Expand Up @@ -251,7 +252,9 @@ public JdbcSession autocommit(final boolean autocommit) {
* @return This object
*/
public JdbcSession set(final Object value) {
this.args.add(value);
synchronized (this.args) {
this.args.add(value);
}
return this;
}

Expand Down

0 comments on commit c0c4040

Please sign in to comment.