LuciferYang commented on code in PR #259:
URL: https://github.com/apache/commons-crypto/pull/259#discussion_r1368085134


##########
src/main/java/org/apache/commons/crypto/utils/ReflectionUtils.java:
##########
@@ -73,9 +81,16 @@ public static Class<?> getClassByName(final String name) 
throws ClassNotFoundExc
      * couldn't be loaded. This is to avoid the overhead of creating an 
exception.
      *
      * @param name the class name.
-     * @return the class object, or {@code null} if it could not be found.
+     * @return the class object, or {@code null} if it could not be found or 
initialization failed.
      */
     private static Class<?> getClassByNameOrNull(final String name) {
+        final Set<String> set =
+            INIT_ERROR_CLASSES.computeIfAbsent(CLASSLOADER, k -> 
Collections.synchronizedSet(new HashSet<>()));
+
+        if (set.contains(name)) {
+            return null;
+        }

Review Comment:
   Add a collection to record classes that have `ExceptionInInitializerError` 
to avoid unnecessary reentry of the `Class.forName` method in this scenario. 
This collection cannot be garbage collected, otherwise there will still be 
reentry issues.



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