MINOR: trivial cleanups#6767
Conversation
|
Thanks for the PR. Ignoring the exhaustiveness warnings can hide bugs, if we don't expect it to happen, we should throw an exception. |
There was a problem hiding this comment.
Don't need this because the Dead case is being handled already in the upstream.
There was a problem hiding this comment.
You mean, if (group.is(Dead)) { in the line 350, right? Then, how to suppress not-exhaustive match warning? Do you have any idea?
There was a problem hiding this comment.
We could raise an exception since we expect to have handled this state. I think it is better to be exhaustive with matches. In fact, I'd prefer to handle case Dead explicitly rather than a blind case _. That way the compiler will generate a warning if we add a new state and don't update this. In other words, the warning will have value.
…oup, and GroupCoordinator#handleHeartbeat.
fb26048 to
a2ad4f6
Compare
hachikuji
left a comment
There was a problem hiding this comment.
Thanks @dongjinleekr . Left a minor suggestion. Otherwise, looks good.
|
|
||
| case Dead => | ||
| // this case is already handled, so raise exception | ||
| throw new IllegalStateException("can't reach this line") |
There was a problem hiding this comment.
Can we provide a more useful message? These impossible states have a funny way of becoming possible over time 😉 . Maybe something like this?
throw new IllegalStateException(s"Reached unexpected condition for Dead group $groupId")We can probably remove the comment if the exception message is already clear.
|
Here is the fix. cc/ @abbccdda @hachikuji |
hachikuji
left a comment
There was a problem hiding this comment.
LGTM. Thanks @dongjinleekr !
| case Startup => | ||
| processStartup() | ||
| case ShutdownEventThread => | ||
| // not handled here |
There was a problem hiding this comment.
Shouldn't we throw an exception here too?
There was a problem hiding this comment.
Well, I have been still thinking about it; If we need an Exception, I will apply it in next cleanup. @abbccdda Could you tell me your opinion?
There was a problem hiding this comment.
Previously we would throw an exception (MatchError) and now we ignore it. That seems worse, right?
There was a problem hiding this comment.
Yes, you are right. I went ahead and merged because it was being addressed in #6686.
Reviewers: Boyang Chen <bchen11@outlook.com>, Jason Gustafson <jason@confluent.io>
Reviewers: Boyang Chen <bchen11@outlook.com>, Jason Gustafson <jason@confluent.io>
CommandLineUtils,KafkaConfig.KafkaController#process,GroupCoordinator#doSyncGroup, andGroupCoordinator#handleHeartbeat.Committer Checklist (excluded from commit message)