justinmclean opened a new issue, #10129:
URL: https://github.com/apache/gravitino/issues/10129
### What would you like to be improved?
EventBus.dispatchEvent is intended to throw a RuntimeException for unknown
event types. However, when baseEvent is null, the else branch builds the
message using baseEvent.getClass().getSimpleName(), which throws a
NullPointerException.
### How should we improve?
Add an explicit null guard at the start of dispatchEvent, e.g.
Preconditions.checkNotNull(baseEvent, "...") or throw a clear
RuntimeException/IllegalArgumentException with a message.
Here's a unit test to help:
```
public class TestEventBus {
@Test
void testDispatchNullEventThrowsUnknownTypeRuntimeException() {
EventBus eventBus = new EventBus(Collections.emptyList());
Assertions.assertThrowsExactly(RuntimeException.class, () ->
eventBus.dispatchEvent(null));
}
}
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]