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

ASF GitHub Bot commented on CXF-5822:
-------------------------------------

GitHub user cehser opened a pull request:

    https://github.com/apache/cxf/pull/8

    Fix for [CXF-5822]. 

    Checks classLoader for null and sets it to 
PropertiesLoaderUtils.class.getClassLoader() in case.

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/cehser/cxf 2.6.x-fixes

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/cxf/pull/8.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #8
    
----
commit b84b9b2569a9616396fa22c112662a2dddc98f1e
Author: Christoph Eßer <[email protected]>
Date:   2014-06-25T14:39:49Z

    Fix for [CXF-5822]. Checks classLoader for null and sets it to 
PropertiesLoaderUtils.class.getClassLoader() in case.

----


> NullPointerException in PropertiesLoaderUtils
> ---------------------------------------------
>
>                 Key: CXF-5822
>                 URL: https://issues.apache.org/jira/browse/CXF-5822
>             Project: CXF
>          Issue Type: Bug
>          Components: Core
>    Affects Versions: 2.6.14
>            Reporter: Christoph Eßer
>            Priority: Critical
>
> Under some circumstances in our project 
> {{Thread.currentThread().getContextClasssLoader()}} is {{null}}. This leads 
> to a {{NullPointerException}} when 
> org.apache.cxf.common.util.PropertiesLoaderUtils.loadAllProperties() is 
> called with that as an argument.
> This is the specific part of the code that contains the problem:
> {code:title=PropertiesLoaderUtils.java|borderStyle=solid}
> /**
>      * Load all properties from the given class path resource, using the given
>      * class loader.
>      * <p>
>      * Merges properties if more than one resource of the same name found in 
> the
>      * class path.
>      * 
>      * @param resourceName the name of the class path resource
>      * @param classLoader the ClassLoader to use for loading (or
>      *            <code>null</code> to use the default class loader)
>      * @return the populated Properties instance
>      * @throws IOException if loading failed
>      */
>     public static Properties loadAllProperties(String resourceName, 
> ClassLoader classLoader)
>         throws IOException {
>         return loadAllProperties(resourceName, classLoader, null, null, null);
>     }        
>     public static Properties loadAllProperties(String resourceName, 
> ClassLoader classLoader,
>                                                Logger logger, Level level, 
> String msg)
>         throws IOException {
>         Properties properties = new Properties();
>         Enumeration<URL> urls = classLoader.getResources(resourceName);
> ...
> {code}
> The Javadoc says that {{null}} is a valid value for this argument. However, 
> the code does not check the variable for {{null}} and just calls 
> {{classLoader.getResources(resourceName)}}. This check should be added and 
> {{classLoader}} should be set to a reasonable value in case it is {{null}}. I 
> will add a pull request for a fix of this issue later.



--
This message was sent by Atlassian JIRA
(v6.2#6252)

Reply via email to