[ https://issues.apache.org/jira/browse/LOG4J2-834?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14228613#comment-14228613 ]
Thiago Kronig edited comment on LOG4J2-834 at 11/29/14 3:23 AM: ---------------------------------------------------------------- Hi. I encountered this bug this morning and cooked-up this patch, with a test case built-in: [^0001-LOG4J2-834-Ignores-NoClassDefFoundError-and-other-Th.patch]. was (Author: thiagokronig): Hi. I encountered this bug this morning and cooked-up this patch, with a test case built-in. > NoClassDefFoundError in ThrowableProxy > -------------------------------------- > > Key: LOG4J2-834 > URL: https://issues.apache.org/jira/browse/LOG4J2-834 > Project: Log4j 2 > Issue Type: Bug > Reporter: Nikita Koval > Attachments: > 0001-LOG4J2-834-Ignores-NoClassDefFoundError-and-other-Th.patch > > > In method *loadClass* we expect {{ClassNotFoundException}}. But if class > comes from another java machine we can get {{NoClassDefFoundError}}. > Possible fix: > {code:java} > 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; > } > {code} -- This message was sent by Atlassian JIRA (v6.3.4#6332) --------------------------------------------------------------------- To unsubscribe, e-mail: log4j-dev-unsubscr...@logging.apache.org For additional commands, e-mail: log4j-dev-h...@logging.apache.org