Skip to content

Commit

Permalink
Merge branch '__rultor'
Browse files Browse the repository at this point in the history
  • Loading branch information
rultor committed Jun 10, 2023
2 parents 58f96e9 + dd7e52e commit a8dcad3
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions src/main/java/com/jcabi/jdbc/JdbcSession.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@
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;
import javax.sql.DataSource;
import lombok.EqualsAndHashCode;
Expand Down Expand Up @@ -152,11 +152,18 @@ public final class JdbcSession {

/**
* Arguments.
*
* <p>Every time this attribute is modified, we must synchronize, because
* a non-thread-safe {@link LinkedList} is assigned to it.</p>
*/
private final transient Collection<Object> args;

/**
* Arguments.
*
* <p>Every time this attribute is modified, we must synchronize, because
* a non-thread-safe {@link LinkedList} is assigned to it.</p>
*
* @since 0.13
*/
private final transient Collection<Preparation> preparations;
Expand Down Expand Up @@ -188,8 +195,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 +258,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 a8dcad3

Please sign in to comment.