[
https://issues.apache.org/jira/browse/CONFIGURATION-641?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15682952#comment-15682952
]
Claude Warren commented on CONFIGURATION-641:
---------------------------------------------
(posted to [email protected]) For background see:
https://issues.apache.org/jira/browse/CONFIGURATION-641?
page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&
focusedCommentId=15681474#comment-15681474
Perhaps there is a bigger problem with the semantics of the classes. I
come late to this project having used version 1.x and not participated or
followed any of the development discussion for 2.x versions. So from a
pseudo-noob point of view perhaps the Configuration objects should not have
a read/write method that does not take a FileHandler object.
I think this makes sense in that you can create a configuration and do a
lot with it without reading or writeing it. The read/write issues arise
because of resolution issues in reading/writing (e.g. resolving include
statements).
Perhaps in version 2.2 the read/write methods could be deprecated in favor
of _read() and _write() (renaming the methods in FileBased) and FileHandler
could be renamed to IOHandler. So reading from a stream, file, ByteBuffer,
etc would be handled by the IOHandler. It seem counter inturitive that a
FileHandler would be needed to read/write a configuration to a Stream.
Just thoughts. Any comments?
Claude
On Sun, Nov 20, 2016 at 5:07 PM, Oliver Heger (JIRA) <[email protected]>
--
I like: Like Like - The likeliest place on the web
<http://like-like.xenei.com>
LinkedIn: http://www.linkedin.com/in/claudewarren
> 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
> 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.4#6332)