justinmclean opened a new issue, #10658:
URL: https://github.com/apache/gravitino/issues/10658
### What would you like to be improved?
In AccessControlEventDispatcher#removeGroup, when
dispatcher.removeGroup(...) throws, the code enters the catch block and
dispatches RemoveGroupFailureEvent.
If eventBus.dispatchEvent(...) also throws because a registered listener
fails while handling that failure event, the listener exception replaces the
original removeGroup exception. This hides the real root cause from callers and
makes production failures harder to diagnose.
Relevant path:
/gravitino/core/src/main/java/org/apache/gravitino/listener/AccessControlEventDispatcher.java:246
### How should we improve?
Protect failure-event dispatch so it cannot mask the original exception and
log the new exception.
Here's a unit test to help:
```
@Test
void
testRemoveGroupFailureEventShouldNotMaskOriginalExceptionWhenListenerThrows() {
GravitinoRuntimeException originalException =
new GravitinoRuntimeException("Original remove group failure");
GravitinoRuntimeException listenerException =
new GravitinoRuntimeException("Failure listener exception");
AccessControlDispatcher exceptionDispatcher =
mock(AccessControlDispatcher.class);
when(exceptionDispatcher.removeGroup(METALAKE,
groupName)).thenThrow(originalException);
EventBus eventBus =
new EventBus(
Collections.singletonList(
new EventListenerPlugin() {
@Override
public void init(Map<String, String> properties) {}
@Override
public void start() {}
@Override
public void stop() {}
@Override
public void onPostEvent(Event event) {
if (event instanceof RemoveGroupFailureEvent) {
throw listenerException;
}
}
}));
AccessControlEventDispatcher testDispatcher =
new AccessControlEventDispatcher(eventBus, exceptionDispatcher);
GravitinoRuntimeException thrownException =
Assertions.assertThrowsExactly(
GravitinoRuntimeException.class, () ->
testDispatcher.removeGroup(METALAKE, groupName));
Assertions.assertSame(originalException, thrownException);
}
```
--
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]