wcarlson5 commented on a change in pull request #9697: URL: https://github.com/apache/kafka/pull/9697#discussion_r540661585
########## File path: streams/src/test/java/org/apache/kafka/streams/integration/StreamsUncaughtExceptionHandlerIntegrationTest.java ########## @@ -202,6 +213,29 @@ private void testShutdownApplication(final int numThreads) throws InterruptedExc assertThat(processorValueCollector.size(), equalTo(1)); } } + + private void testReplaceThreads(final int numThreads) throws InterruptedException { + properties.put(StreamsConfig.NUM_STREAM_THREADS_CONFIG, numThreads); + try (final KafkaStreams kafkaStreams = new KafkaStreams(builder.build(), properties)) { + kafkaStreams.setUncaughtExceptionHandler((t, e) -> fail("should not hit old handler")); + + final AtomicInteger count = new AtomicInteger(); + kafkaStreams.setUncaughtExceptionHandler(exception -> { + count.getAndIncrement(); + if (count.get() > 2) { + return SHUTDOWN_CLIENT; + } + return REPLACE_THREAD; + }); + StreamsTestUtils.startKafkaStreamsAndWaitForRunningState(kafkaStreams); + + produceMessages(0L, inputTopic, "A"); + waitForApplicationState(Collections.singletonList(kafkaStreams), KafkaStreams.State.NOT_RUNNING, DEFAULT_DURATION); + + assertThat(processorValueCollector.size(), equalTo(3)); + //because we only have 2 threads at the start and each record kills a thread we must have replaced threads + } + } } Review comment: added ---------------------------------------------------------------- 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. For queries about this service, please contact Infrastructure at: us...@infra.apache.org