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

Greg Harris commented on KAFKA-17270:
-------------------------------------

Nothing is the scala bottom type (a type which has no values), and indicates 
that the function should never return normally. Rather than casting Unit to 
Nothing (which is illegal, as Nothing is the bottom type) the method should 
throw an exception.

If you're changing this and the callers to Unit. then it would probably also 
make sense to remove kafka.utils.Exit entirely, as the Unit/Nothing distinction 
is the only benefit it provides vs the java form of the class.

> the input function of Exit#setHaltProcedure/Exit#setExitProcedure should 
> return `Unit` rather than `Nothing`
> ------------------------------------------------------------------------------------------------------------
>
>                 Key: KAFKA-17270
>                 URL: https://issues.apache.org/jira/browse/KAFKA-17270
>             Project: Kafka
>          Issue Type: Test
>            Reporter: Chia-Ping Tsai
>            Assignee: Ming-Yen Chung
>            Priority: Minor
>
> I noticed it due to following exception.
> {code:java}
> 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)
> {code}
> 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



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

Reply via email to