Skip to content

Commit ad86391

Browse files
committed
chore: make state field volatile in AsyncResultSetImpl
Mark the `state` field in `AsyncResultSetImpl` volatile, as it is inspected by different threads.
1 parent 8547735 commit ad86391

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

google-cloud-spanner/src/main/java/com/google/cloud/spanner/AsyncResultSetImpl.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,9 +112,9 @@ private enum State {
112112
* Listeners that will be called when the {@link AsyncResultSetImpl} has finished fetching all
113113
* rows and any underlying transaction or session can be closed.
114114
*/
115-
private Collection<Runnable> listeners = new LinkedList<>();
115+
private final Collection<Runnable> listeners = new LinkedList<>();
116116

117-
private State state = State.INITIALIZED;
117+
private volatile State state = State.INITIALIZED;
118118

119119
/** This variable indicates that produce rows thread is initiated */
120120
private volatile boolean produceRowsInitiated;

0 commit comments

Comments
 (0)