Skip to content

Commit afc146a

Browse files
committed
fix: protect writes with monitor
1 parent ad86391 commit afc146a

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

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

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -498,10 +498,12 @@ public ApiFuture<Void> setCallback(Executor exec, ReadyCallback cb) {
498498
}
499499

500500
private void initiateProduceRows() {
501-
if (this.state == State.STREAMING_INITIALIZED) {
502-
this.state = State.RUNNING;
501+
synchronized (monitor) {
502+
if (this.state == State.STREAMING_INITIALIZED) {
503+
this.state = State.RUNNING;
504+
}
505+
produceRowsInitiated = true;
503506
}
504-
produceRowsInitiated = true;
505507
this.service.execute(new ProduceRowsRunnable());
506508
}
507509

0 commit comments

Comments
 (0)