Skip to content

Commit 5546490

Browse files
add sync block
1 parent cd417c6 commit 5546490

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -468,6 +468,11 @@ public void run() {
468468
// Those result sets will trigger initiateProduceRows() when the first results are received.
469469
// Non-streaming result sets do not trigger this callback, and for those result sets, we
470470
// need to eagerly start the ProduceRowsRunnable.
471+
synchronized (monitor) {
472+
if (!(state == State.STREAMING_INITIALIZED)) {
473+
return;
474+
}
475+
}
471476
if (!initiateStreaming(AsyncResultSetImpl.this)) {
472477
initiateProduceRows();
473478
}
@@ -490,7 +495,6 @@ public ApiFuture<Void> setCallback(Executor exec, ReadyCallback cb) {
490495
this.result = SettableApiFuture.create();
491496
this.state = State.STREAMING_INITIALIZED;
492497
this.service.execute(new InitiateStreamingRunnable());
493-
// initiateProduceRows();
494498
this.executor = MoreExecutors.newSequentialExecutor(Preconditions.checkNotNull(exec));
495499
this.callback = Preconditions.checkNotNull(cb);
496500
pausedLatch.countDown();

0 commit comments

Comments
 (0)