Details
-
Bug
-
Status: Resolved
-
Major
-
Resolution: Fixed
-
None
-
None
-
None
Description
In method loadClass we expect ClassNotFoundException. But if class comes from another java machine we can get NoClassDefFoundError.
Possible fix:
private Class<?> loadClass(final ClassLoader lastLoader, final String className) { // XXX: this is overly complicated Class<?> clazz; if (lastLoader != null) { try { clazz = Loader.initializeClass(className, lastLoader); if (clazz != null) { return clazz; } } catch (final Throwable ignore) { // Ignore exception. } } try { clazz = Loader.loadClass(className); } catch (final ClassNotFoundException | LinkageError ignored) { try { clazz = Loader.initializeClass(className, this.getClass().getClassLoader()); } catch (final ClassNotFoundException | LinkageError ignore) { return null; } } return clazz; }
Attachments
Attachments
Issue Links
- relates to
-
LOG4J2-832 ThrowableProxy fails if a class in logged stack trace throws java.lang.Error from initializer
- Closed