[ 
https://issues.apache.org/jira/browse/LOG4J2-230?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13647495#comment-13647495
 ] 

Nick Williams commented on LOG4J2-230:
--------------------------------------

If NoClassDefFoundError is found here, it should not be caught. It should be 
allowed to propagate.

ClassNotFoundException: Thrown when code attempts to load a class via 
reflection. This is a checked exception, because the code loading the class 
could not be checked by the compiler, so it must be checked at runtime.

NoClassDefFoundError: This is thrown when code that WAS checked by the compiler 
fails to load at runtime. This happens when a class that was successfully 
linked at compile time cannot be located on the class path. For example:

public class Animal {
    public Fur fur;
}

If Fur cannot be loaded here, a NoClassDefFoundError is thrown. Fur, in this 
case, was linked at compile time, but that linkage broke at runtime.

If Class.forName() throws a NoClassDefFoundError in this case, it could be 
while loading that class, OR it could be some other major problem with the JRE 
class path. Importantly, IF NoClassDefFoundError is thrown while loading 
Log4JLoggerFactory, that means Log4JLoggerFactory WAS found, but one of its 
references was not found. In this situation you SHOULD still throw an 
exception, because Log4JLoggerFactory was found and should not have been. 
However, your catching Throwable will suppress that exception. IMO, this seems 
incorrect. Log4JLoggerFactory should just be allowed to propagate.

I really think ONLY ClassNotFoundException should be caught here. Any other 
exceptions should be allowed to propagate.
                
> Preempt StackOverflowEx when both slf4j-impl jar and log4j-to-slf4j jar are 
> on the classpath
> --------------------------------------------------------------------------------------------
>
>                 Key: LOG4J2-230
>                 URL: https://issues.apache.org/jira/browse/LOG4J2-230
>             Project: Log4j 2
>          Issue Type: Improvement
>          Components: SLF4J Bridge
>    Affects Versions: 2.0-beta5
>            Reporter: Remko Popma
>
> This ticket is to prevent issues like LOG4J2-204.
> Aiming for something similar to what is documented here:
> http://www.slf4j.org/codes.html#jclDelegationLoop

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to