mirror of https://github.com/apache/kafka.git
KAFKA-12699: Override the default handler for stream threads if the stream's handler is used (#12324)
Override the default handler for stream threads if the stream's handler is used. We do no want the java default handler triggering when a thread is replaced. Reviewers: Anna Sophie Blee-Goldman <ableegoldman@apache.org>
This commit is contained in:
parent
693e283802
commit
b62d8b975c
|
@ -471,6 +471,13 @@ public class KafkaStreams implements AutoCloseable {
|
|||
exception -> handleStreamsUncaughtException(exception, userStreamsUncaughtExceptionHandler, false)
|
||||
);
|
||||
}
|
||||
processStreamThread(thread -> thread.setUncaughtExceptionHandler((t, e) -> { }
|
||||
));
|
||||
|
||||
if (globalStreamThread != null) {
|
||||
globalStreamThread.setUncaughtExceptionHandler((t, e) -> { }
|
||||
);
|
||||
}
|
||||
} else {
|
||||
throw new IllegalStateException("Can only set UncaughtExceptionHandler before calling start(). " +
|
||||
"Current state is: " + state);
|
||||
|
|
|
@ -176,6 +176,12 @@ public class StreamsUncaughtExceptionHandlerIntegrationTest {
|
|||
testReplaceThreads(2);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldReplaceThreadsWithoutJavaHandler() throws InterruptedException {
|
||||
Thread.setDefaultUncaughtExceptionHandler((t, e) -> fail("exception thrown"));
|
||||
testReplaceThreads(2);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldReplaceSingleThread() throws InterruptedException {
|
||||
testReplaceThreads(1);
|
||||
|
|
Loading…
Reference in New Issue