[
https://issues.apache.org/jira/browse/KAFKA-13908?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17598233#comment-17598233
]
Nikolay Izhikov commented on KAFKA-13908:
-----------------------------------------
Hello, [~showuon].
I open PR for this issue - https://github.com/apache/kafka/pull/12574
It don't contain any tests for the patch.
I made a bit of investigation but don't find way to throw test exception from
specific blocks:
{code:java}
try {
metadataListener.startPublishing(metadataPublisher).get()
} catch {
case ee: ExecutionException => throw ee
case t: Throwable => throw new RuntimeException("Received a fatal error
while " +
"waiting for the broker to catch up with the current cluster
metadata.", t)
}
...
try {
lifecycleManager.setReadyToUnfence().get()
} catch {
case ee: ExecutionException => throw ee
case t: Throwable => throw new RuntimeException("Received a fatal error
while " +
"waiting for the broker to be unfenced.", t)
}
{code}
If you know how to test this lines, please, tell me.
> RuntimeException will be thrown in BrokerServer.startup, not the cause of
> exception
> -----------------------------------------------------------------------------------
>
> Key: KAFKA-13908
> URL: https://issues.apache.org/jira/browse/KAFKA-13908
> Project: Kafka
> Issue Type: Improvement
> Reporter: Luke Chen
> Assignee: Nikolay Izhikov
> Priority: Major
> Labels: newbie
>
> Before [#11969|https://github.com/apache/kafka/pull/11969], We will throw an
> {{ExecutionException(KafkaStorageException)}} in
> {{{}BrokerServer.startup{}}}, and we'll catch the exception and rethrow the
> cause by:
> {code:java}
> throw if (e.isInstanceOf[ExecutionException]) e.getCause else e{code}
> [https://github.com/apache/kafka/blob/trunk/core/src/main/scala/kafka/Kafka.scala#L113]
>
> After [#11969|https://github.com/apache/kafka/pull/11969], We will throw a
> {{{}RuntimeException(ExecutionException(KafkaStorageException)){}}}. But the
> catch logic didn't change. That means, if the exception is RuntimeException,
> we won't throw only the cause, but all the exception chains.
>
> We should update it and add tests for it.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)