commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Oliver Heger (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (CONFIGURATION-641) XMLConfiguration.load may throw NPE
Date Sat, 18 Mar 2017 15:01:41 GMT

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

Oliver Heger commented on CONFIGURATION-641:
--------------------------------------------

The support for reading configuration data from streams via builders is probably not ideal.
Do you want to open a new ticket to address this? We can then discuss there what could be
done to improve the situation. (At least the documentation could be improved as you already
pointed out.)

> XMLConfiguration.load may throw NPE
> -----------------------------------
>
>                 Key: CONFIGURATION-641
>                 URL: https://issues.apache.org/jira/browse/CONFIGURATION-641
>             Project: Commons Configuration
>          Issue Type: Bug
>    Affects Versions: 2.1
>         Environment: Java 8 / Linux
>            Reporter: Claude Warren
>             Fix For: 2.1.1
>
>   Original Estimate: 1h
>  Remaining Estimate: 1h
>
> I expect that 
> {noformat}
>     URL url = Test.class.getResource( "/Test.xml");	
>     XMLConfiguration config = new XMLConfiguration();
>     config.read( url.openStream());
> {noformat}
> Would read the XML file.  However it will throw a NPE at line 967
> {noformat}
>  private void load(InputSource source) throws ConfigurationException
>     {
>         try
>         {
>             URL sourceURL = locator.getSourceURL(); // <- NPE here
>             if (sourceURL != null)
>             {
>                 source.setSystemId(sourceURL.toString());
>             }
> {noformat}
> I believe that testing for locator == null first will solve the problem as the rest of
the code in the method does not appear to use it.



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)

Mime
View raw message