sabashaikh4 commented on code in PR #9854:
URL: https://github.com/apache/gravitino/pull/9854#discussion_r2758734665
##########
core/src/main/java/org/apache/gravitino/listener/api/event/ListTopicFailureEvent.java:
##########
@@ -39,10 +40,15 @@ public final class ListTopicFailureEvent extends
TopicFailureEvent {
* @param exception The exception encountered during the attempt to list
topics.
*/
public ListTopicFailureEvent(String user, Namespace namespace, Exception
exception) {
- super(user, NameIdentifier.of(namespace.levels()), exception);
Review Comment:
@jerryshao I tried placing the precondition check after super() as
suggested, but this causes a NullPointerException in the test. Since
`namespace.levels()` is called in the super() constructor before the null check
happens, we get NPE instead of the expected IllegalArgumentException.
The helper method ensures validation happens before super() is invoked
(which must be the first statement). The test `testNamespaceMustNotBeNull()`
expects IllegalArgumentException when namespace is null.
Would it be acceptable to keep the `validateNamespace()` helper method to
ensure proper validation order?
Test failure log: ListTopicFailureEventTest > testNamespaceMustNotBeNull()
FAILED
org.opentest4j.AssertionFailedError: Unexpected exception type thrown
==> expected: <java.lang.IllegalArgumentException> but was:
<java.lang.NullPointerException>
at
app//org.junit.jupiter.api.AssertThrows.assertThrows(AssertThrows.java:65)
at
app//org.junit.jupiter.api.AssertThrows.assertThrows(AssertThrows.java:37)
at
app//org.junit.jupiter.api.Assertions.assertThrows(Assertions.java:3082)
at
app//org.apache.gravitino.listener.api.event.ListTopicFailureEventTest.testNamespaceMustNotBeNull(ListTopicFailureEventTest.java:29)
Caused by:
java.lang.NullPointerException: Cannot invoke
"org.apache.gravitino.Namespace.levels()" because "namespace" is null
at
org.apache.gravitino.listener.api.event.ListTopicFailureEvent.<init>(ListTopicFailureEvent.java:43)
at
org.apache.gravitino.listener.api.event.ListTopicFailureEventTest.lambda$testNamespaceMustNotBeNull$0(ListTopicFailureEventTest.java:31)
at
org.junit.jupiter.api.AssertThrows.assertThrows(AssertThrows.java:55)
... 3 more
--
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]