Details
-
Test
-
Status: Resolved
-
Minor
-
Resolution: Fixed
-
None
-
None
-
None
Description
Exit.scala is a wrap of Exit.java, and the benefit is "Nothing" which can make methods throw exception. IMHO, the benefit is too small, and also we are going to drop scala code. Hence, it would be great to use Exit.java directly and then remove Exit.scala
BEFORE
I noticed it due to following exception.
java.lang.ClassCastException: class scala.runtime.BoxedUnit cannot be cast to class scala.runtime.Nothing$ (scala.runtime.BoxedUnit and scala.runtime.Nothing$ are in unnamed module of loader 'app') at kafka.server.ServerShutdownTest.$anonfun$testNoCleanShutdownAfterFailedStartupDueToCorruptLogs$3(ServerShutdownTest.scala:176) at kafka.server.ServerShutdownTest.$anonfun$testNoCleanShutdownAfterFailedStartupDueToCorruptLogs$3$adapted(ServerShutdownTest.scala:174) at kafka.utils.Exit$$anon$1.execute(Exit.scala:81) at org.apache.kafka.common.utils.Exit.halt(Exit.java:71) at kafka.utils.Exit$.halt(Exit.scala:33) at kafka.log.LogManager.handleLogDirFailure(LogManager.scala:230) at kafka.server.ReplicaManager.handleLogDirFailure(ReplicaManager.scala:2501) at kafka.server.ReplicaManager$LogDirFailureHandler.doWork(ReplicaManager.scala:325) at org.apache.kafka.server.util.ShutdownableThread.run(ShutdownableThread.java:136)
It seems to me using `Nothing` as returned type is weird and in this case the suitable type should be `Unit` (same as other methods). Also, that can fix the casting error in `testNoCleanShutdownAfterFailedStartupDueToCorruptLogs`
[0] https://github.com/apache/kafka/blob/trunk/core/src/main/scala/kafka/utils/Exit.scala#44
[1] https://github.com/apache/kafka/blob/trunk/core/src/main/scala/kafka/utils/Exit.scala#50
Attachments
Issue Links
- is related to
-
KAFKA-16450 Add thread-safe alternative to Exit
- Patch Available
- links to