[
https://issues.apache.org/jira/browse/KAFKA-19724?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18022675#comment-18022675
]
Mikołaj Bul commented on KAFKA-19724:
-------------------------------------
My case can be fixed by catching the error
[here|https://github.com/apache/kafka/blob/trunk/streams/src/main/java/org/apache/kafka/streams/processor/internals/GlobalStreamThread.java#L434]
and it will get re-thrown by the thread calling {{streams.start()}}
[here|https://github.com/apache/kafka/blob/trunk/streams/src/main/java/org/apache/kafka/streams/processor/internals/GlobalStreamThread.java#L464].
I was trying to advocate against catching {{Throwable}} because I've seen posts
like [this|https://stackoverflow.com/a/352793], saying that when a
{{VirtualMachineError}} is thrown there are no guarantees for executing any
code reliably, including error handling or passing the error to a custom
exception handler.
Java's {{UncaughtExceptionHandler}} seems to me like the last line of defense,
where user could try to detect these problems and take action like shutting
down the app. Setting these handlers to no-op
[here|https://github.com/apache/kafka/blob/trunk/streams/src/main/java/org/apache/kafka/streams/KafkaStreams.java#L472-L478]
looks like ignoring everything that's unexpected.
I might be wrong though, so I'm not pushing for any specific solution. Catching
{{Throwable}} should probably handle most of the cases just fine.
> 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)