You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "RENJITH ALEXANDER (Jira)" <ji...@apache.org> on 2020/12/09 05:13:00 UTC

[jira] [Created] (LOGGING-172) Disparity in exception handling of logger factory creation, causing failure in some cases.

RENJITH ALEXANDER created LOGGING-172:
-----------------------------------------

             Summary: Disparity in exception handling of logger factory creation, causing failure in some cases.
                 Key: LOGGING-172
                 URL: https://issues.apache.org/jira/browse/LOGGING-172
             Project: Commons Logging
          Issue Type: Bug
    Affects Versions: 1.2
            Reporter: RENJITH ALEXANDER


The following is the way the log factory instance is created in org.apache.commons.logging.LogFactory.getFactory implementation:

1.0 Check if the log factory for the current context class loader is available in the cache.
    1.1 If found, return it.
    1.2 If not found, continue to step 2.0
2.0 See if there is a factory provider registered via system property "org.apache.commons.logging.LogFactory", and try to load that class.
    2.1 If no such system property found, go to step 3.0
    2.2 If successfully loaded return an instance of the class, after adding it to cache.
    2.3 If there is a security exception while doing this, continue to step 3.0.
    2.4 If there is ANY OTHER exception, RETHROW it.
3.0 See if there is a resource under the context class loader path "META-INF/services/org.apache.commons.logging.LogFactory", and try to load the class.
    3.1 If no such file found, go to step 4.0
    3.2 If successfully loaded return an instance of the class, after adding it to cache.
    3.3 If there is ANY exception, got to step 4.0.
4.0 Load the provider class(read during steps 2.0 or 3.0, or the default provider if none read) with the current context class loader, cache it and return it.

 

Since the exception handling in 2.0 is different from exception handling in 3.0, a class cast exception in 3.3 will cause 4.0 to be executed, returning a logger factory successfully, while the same exception in 2.4 causes an exception to be thrown back, and no logger factory being created.

The ideal scenario should be that, the exception handling should be identical in both cases,  the fall back mechanism(4.0) should be executed in both cases to return a logger factory instance successfully.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)