aoli-al commented on code in PR #18418:
URL: https://github.com/apache/kafka/pull/18418#discussion_r1906324898


##########
streams/src/test/java/org/apache/kafka/streams/KafkaStreamsTest.java:
##########
@@ -957,6 +960,7 @@ public void shouldThrowOnCleanupWhileShuttingDown() throws 
Exception {
             assertThat(streams.state() == State.PENDING_SHUTDOWN, 
equalTo(true));
             assertThrows(IllegalStateException.class, streams::cleanUp);
             assertThat(streams.state() == State.PENDING_SHUTDOWN, 
equalTo(true));
+            terminableThreadBlockingLatch.countDown();

Review Comment:
   No, because the `try (final KafkaStreams streams = new 
KafkaStreams(getBuilderWithSource().build(), props, supplier, time))` statement 
will call `streams.close()` at the end of the try block but before the final 
block. So we need to call `terminableThreadBlockingLatch.countDown();` inside 
the try block. 
   
   If we want to ensure `terminableThreadBlockingLatch.countDown();` is always 
called. We may write:
   
   ```java
           try (final KafkaStreams streams = new 
KafkaStreams(getBuilderWithSource().build(), props, supplier, time)) {
               streams.start();
               try {
                   waitForCondition(
                       () -> streams.state() == KafkaStreams.State.RUNNING,
                       "Streams never started.");
                   streams.close(Duration.ZERO);
                   assertThat(streams.state() == State.PENDING_SHUTDOWN, 
equalTo(true));
                   assertThrows(IllegalStateException.class, streams::cleanUp);
                   assertThat(streams.state() == State.PENDING_SHUTDOWN, 
equalTo(true));
               } finally {
                   terminableThreadBlockingLatch.countDown();
               }
           }
   ```
   
   Please let me know if you prefer this. 



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to