[ 
https://issues.apache.org/jira/browse/KAFKA-19724?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18022105#comment-18022105
 ] 

Bruno Cadonna edited comment on KAFKA-19724 at 9/23/25 8:58 AM:
----------------------------------------------------------------

We specified the Streams uncaught exception handler to handle {{Throwable}}. If 
we want to keep that, we need to catch {{Throwable}}s. And we actually already 
do that for stream threads. 
The Java uncaught exception handler also handles {{Throwable}}s and we wanted 
to have a custom uncaught exception handler for Streams.
To be fair, the global stream thread is a bit special since it cannot be 
replaced as the stream threads. So, I would either:
* log the failure in the Java uncaught exception of the global stream thread 
and let the Kafka Streams instance just fail with the throwable, or
* catch the {{Throwable}} and log (and let the Kafka Streams instance fail).



was (Author: cadonna):
We specified the Streams uncaught exception handler to handle {{Throwable}}. If 
we want to keep that, we need to catch {{Throwable}}s. And we actually already 
do that for stream threads. 
The Java uncaught exception handler also handles {{Throwable}}s and we wanted 
to have a custom uncaught exception handler for Streams.
To be fair, the global stream thread is a bit special since it cannot be 
replaced as the stream threads. So, I would either:
* log the failure in the Java uncaught exception of the global stream thread 
and let the Kafka Streams instance just fail with the throwable, or
* catch the {{Throwable}} and log.


> Global stream thread ignores all exceptions
> -------------------------------------------
>
>                 Key: KAFKA-19724
>                 URL: https://issues.apache.org/jira/browse/KAFKA-19724
>             Project: Kafka
>          Issue Type: Bug
>          Components: streams
>    Affects Versions: 3.4.0
>            Reporter: Mikołaj Bul
>            Assignee: Fatih Celik
>            Priority: Major
>              Labels: beginner, newbie
>
> {{globalStreamThread}} in {{KafkaStreams}} class ignores all exceptions and 
> fails to apply the user-provided {{StreamsUncaughtExceptionHandler}} in:
> {code:java}
> public void setUncaughtExceptionHandler(final StreamsUncaughtExceptionHandler 
> userStreamsUncaughtExceptionHandler)
> {code}
> This can lead to streams being stuck in faulty state after an exception is 
> thrown during their initialization phase (e.g. failure to load the RocksDB 
> native library). The exception isn't logged, so debugging such problem is 
> difficult.
> From my understanding of the {{b62d8b97}} commit message, the following code 
> is unnecessary as the {{globalStreamThread}} can't be replaced and the issue 
> description from KAFKA-12699 doesn't apply to it. Removing it should help.
> {code:java}
> if (globalStreamThread != null) {
>     globalStreamThread.setUncaughtExceptionHandler((t, e) -> { }
>     );
> }
> {code}



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to