Copilot commented on code in PR #2792:
URL:
https://github.com/apache/incubator-hugegraph/pull/2792#discussion_r2343059642
##########
hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/util/Reflection.java:
##########
@@ -33,49 +33,36 @@ public class Reflection {
private static final Method REGISTER_FILEDS_TO_FILTER_METHOD;
private static final Method REGISTER_METHODS_TO_FILTER_METHOD;
- public static final String JDK_INTERNAL_REFLECT_REFLECTION =
"jdk.internal.reflect.Reflection";
- public static final String SUN_REFLECT_REFLECTION =
"sun.reflect.Reflection";
-
static {
Method registerFieldsToFilterMethodTemp = null;
Method registerMethodsToFilterMethodTemp = null;
Class<?> reflectionClazzTemp = null;
try {
- reflectionClazzTemp =
Class.forName(JDK_INTERNAL_REFLECT_REFLECTION);
+ reflectionClazzTemp =
Class.forName("jdk.internal.reflect.Reflection");
+
+ registerFieldsToFilterMethodTemp =
+ reflectionClazzTemp.getMethod("registerFieldsToFilter",
+ Class.class, String[].class);
+
+ registerMethodsToFilterMethodTemp =
+ reflectionClazzTemp.getMethod("registerMethodsToFilter",
+ Class.class, String[].class);
} catch (ClassNotFoundException e) {
- try {
- reflectionClazzTemp = Class.forName(SUN_REFLECT_REFLECTION);
- } catch (ClassNotFoundException ex) {
- LOG.error("Can't find Reflection class", ex);
- }
+ LOG.error("Can't find jdk.internal.reflect.Reflection class, " +
+ "please ensure you are using Java 11", e);
+ } catch (NoSuchMethodException e) {
+ LOG.error("Can't find reflection filter methods", e);
}
Review Comment:
The method lookup logic should be wrapped in a try-catch block to handle
NoSuchMethodException separately from ClassNotFoundException, ensuring proper
error handling for each failure scenario.
##########
hugegraph-server/hugegraph-api/src/main/java/org/apache/hugegraph/auth/HugeFactoryAuthProxy.java:
##########
@@ -636,8 +634,8 @@ public static void optionalMethodsToFilter(String
className, String... methodNam
try {
clazz = Class.forName(className);
} catch (ClassNotFoundException e) {
- // TODO: we just ignore the exception, change it after we drop
Java8 support
- LOG.warn("Skip register class {} to filter", className);
+ LOG.debug("Internal class {} not found in this JDK implementation,
skipping filter registration",
+ className, e);
Review Comment:
The log message has a grammatical error. 'Internal class {} not found in
this JDK implementation' should be 'Internal class {} not found in this JDK
implementation,'.
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]