Copilot commented on code in PR #30184:
URL: https://github.com/apache/flink/pull/30184#discussion_r4723943062


##########
flink-table/flink-table-common/src/main/java/org/apache/flink/table/functions/UserDefinedFunctionHelper.java:
##########
@@ -257,8 +258,12 @@ public static UserDefinedFunction 
instantiateFunction(Class<?> functionClass) {
         }
         validateClass((Class) functionClass, true);
         try {
-            return (UserDefinedFunction) functionClass.newInstance();
+            return (UserDefinedFunction) 
functionClass.getDeclaredConstructor().newInstance();
         } catch (Exception e) {
+            // Class#newInstance propagated errors such as OutOfMemoryError, 
keep that
+            if (e instanceof InvocationTargetException && e.getCause() 
instanceof Error) {
+                throw (Error) e.getCause();

Review Comment:
   `UserDefinedFunctionHelperTest` has no constructor-failure cases, so 
removing this rethrow would leave the tests passing while constructor-thrown 
errors become `ValidationException`s. Add a valid public UDF whose public 
no-argument constructor throws a pre-created `AssertionError`, and assert that 
the identical error escapes. Also cover an ordinary constructor exception to 
verify that it remains wrapped in `ValidationException`.



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