Copilot commented on code in PR #13235:
URL: https://github.com/apache/gravitino/pull/13235#discussion_r4026181662


##########
api/src/main/java/org/apache/gravitino/exceptions/NoSuchEntityException.java:
##########
@@ -34,7 +38,7 @@ public class NoSuchEntityException extends RuntimeException {
    */
   @FormatMethod
   public NoSuchEntityException(@FormatString String message, Object... args) {
-    super(String.format(message, args));
+    super(message, args);

Review Comment:
   `GravitinoRuntimeException(String, Object...)` deliberately skips 
`String.format` when `args` is empty (see 
`GravitinoRuntimeException.java:43-45`). Changing this constructor from 
`super(String.format(message, args))` therefore changes zero-argument 
formatting: for example, `new NoSuchEntityException("100%% complete")` used to 
expose `100% complete`, but now exposes `100%% complete`, contrary to the 
stated unchanged message formatting. Preserve the existing `String.format` call 
here or add an explicit compatibility test if this change is intentional.



##########
api/src/test/java/org/apache/gravitino/exceptions/TestExceptions.java:
##########
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.gravitino.exceptions;
+
+import static 
org.apache.gravitino.exceptions.NoSuchEntityException.NO_SUCH_ENTITY_MESSAGE;
+
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
+
+public class TestExceptions {
+
+  @Test
+  public void testNoSuchEntityExceptionIsInGravitinoHierarchy() {
+    // Before the fix, NoSuchEntityException extended RuntimeException 
directly, outside the
+    // GravitinoRuntimeException hierarchy every sibling NoSuch* exception 
uses, so
+    // catch (GravitinoRuntimeException) blocks silently missed it.
+    Object noCause = new NoSuchEntityException(NO_SUCH_ENTITY_MESSAGE, 
"table", "a.b.c");
+    Object withCause =
+        new NoSuchEntityException(
+            new IllegalStateException("cause"), NO_SUCH_ENTITY_MESSAGE, 
"table", "a.b.c");
+    Assertions.assertTrue(noCause instanceof GravitinoRuntimeException);
+    Assertions.assertTrue(withCause instanceof GravitinoRuntimeException);

Review Comment:
   This test only verifies `GravitinoRuntimeException`, so it would still pass 
if the class were moved under a different runtime-exception subclass and does 
not pin the `NotFoundException` contract that drives the 404 mapping. Assert 
`NotFoundException` for both constructor paths (or exercise the REST handler).



-- 
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]

Reply via email to