diff --git a/src/main/java/com/jcabi/jdbc/JdbcSession.java b/src/main/java/com/jcabi/jdbc/JdbcSession.java index 6761bc1..b988cd0 100644 --- a/src/main/java/com/jcabi/jdbc/JdbcSession.java +++ b/src/main/java/com/jcabi/jdbc/JdbcSession.java @@ -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; @@ -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; @@ -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; }