arunpandianp commented on code in PR #35523: URL: https://github.com/apache/beam/pull/35523#discussion_r2259798218
########## runners/google-cloud-dataflow-java/worker/src/main/java/org/apache/beam/runners/dataflow/worker/windmill/client/AbstractWindmillStream.java: ########## @@ -214,54 +242,66 @@ public final void start() { } if (shouldStartStream) { + // Add the stream to the registry after it has been fully constructed. + streamRegistry.add(this); startStream(); } } /** Starts the underlying stream. */ private void startStream() { - // Add the stream to the registry after it has been fully constructed. - streamRegistry.add(this); while (true) { @NonNull PhysicalStreamHandler streamHandler = newResponseHandler(); - try { - synchronized (this) { + synchronized (this) { + try { + checkState(currentPhysicalStream == null, "Overwriting existing physical stream"); + checkState(halfCloseFuture == null, "Unexpected half-close future"); + if (isShutdown) { + // No need to start the stream. shutdown() or onPhysicalStreamCompletion will be + // responsible for completing Review Comment: ```suggestion // responsible for completing ``` ########## runners/google-cloud-dataflow-java/worker/src/main/java/org/apache/beam/runners/dataflow/worker/windmill/client/AbstractWindmillStream.java: ########## @@ -214,54 +242,66 @@ public final void start() { } if (shouldStartStream) { + // Add the stream to the registry after it has been fully constructed. + streamRegistry.add(this); startStream(); } } /** Starts the underlying stream. */ private void startStream() { - // Add the stream to the registry after it has been fully constructed. - streamRegistry.add(this); while (true) { @NonNull PhysicalStreamHandler streamHandler = newResponseHandler(); - try { - synchronized (this) { + synchronized (this) { + try { + checkState(currentPhysicalStream == null, "Overwriting existing physical stream"); + checkState(halfCloseFuture == null, "Unexpected half-close future"); + if (isShutdown) { + // No need to start the stream. shutdown() or onPhysicalStreamCompletion will be + // responsible for completing Review Comment: ```suggestion // responsible for completing ``` -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: github-unsubscr...@beam.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org