[ https://issues.apache.org/jira/browse/CONFIGURATION-641?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15929471#comment-15929471 ]
RafaĆ Figas commented on CONFIGURATION-641: ------------------------------------------- Oh, right, I forgot that line. Yes, I know that is not support forum, but loading those data from input stream is really confusing. Especially for users of version 1.x. The first thing I did was the same thing as a reporter, and looking at Stack Overflow it is not a rare occurance. Second thing was to find this issue :-) and I hoped to find some clues here. Because I didn't I thought that maybe my comment could be useful for others. Btw some clear example in User's Guide how to do this properly would be very helpful. Anyway, thank you for your answer. > 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)