[jira] [Commented] (CONFIGURATION-641) XMLConfiguration.load may throw NPE

2016-11-20 Thread Oliver Heger (JIRA)

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

Oliver Heger commented on CONFIGURATION-641:


Agreed that it is not a good style to throw a NPE here. However, the underlying 
problem here is that the read() method should not be called directly, but a 
{{FileHandler}} object should be used to load or save a configuration as 
described at
http://commons.apache.org/proper/commons-configuration/userguide/howto_filebased.html#File_Operations_on_Configurations

The documentation of read() and write() methods should be improved to state 
this.

> 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)


[jira] [Commented] (CONFIGURATION-641) XMLConfiguration.load may throw NPE

2016-11-21 Thread Claude Warren (JIRA)

[ 
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 u...@commons.apache.org)  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) 




-- 
I like: Like Like - The likeliest place on the web

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)


[jira] [Commented] (CONFIGURATION-641) XMLConfiguration.load may throw NPE

2016-11-22 Thread Oliver Heger (JIRA)

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

Oliver Heger commented on CONFIGURATION-641:


These are valid points. However, Commons policy does only allow breaking (i.e. 
binary incompatible) changes in major versions. So such changes could only go 
in a version 3.0, but not 2.2.

The intended use case for Configuration 2.x is that configurations are created 
via builders. In this setup no problems occur.  Direct file operations on 
configuration objects should be done only in exceptional cases, e.g. when 
copying a configuration to another location. So I think, documenting the 
limitations of read() and write() would be acceptable.

> 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)


[jira] [Commented] (CONFIGURATION-641) XMLConfiguration.load may throw NPE

2017-03-16 Thread JIRA

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

Rafał Figas commented on CONFIGURATION-641:
---

My question is: what is by the book code, that should be used for loading (and 
then perform reading) configuration from input stream?
After some reading I came with something like this, what seems to be working 
well:

{code}
XMLConfiguration cfg = new 
BasicConfigurationBuilder<>(XMLConfiguration.class).configure(new 
Parameters().xml()).getConfiguration();
FileHandler fh = new FileHandler(cfg);
{code}

And then {{cfg}} should contain loaded configuration. Is this correct?


> 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)


[jira] [Commented] (CONFIGURATION-641) XMLConfiguration.load may throw NPE

2017-03-16 Thread Oliver Heger (JIRA)

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

Oliver Heger commented on CONFIGURATION-641:


There seems to be a line missing in your code fragment which actually loads the 
data. Something like
{code}
fh.load(stream);
{code}

However, Jira is not a support forum, and this ticket has been closed. Please 
send questions to the user list. See 
http://commons.apache.org/proper/commons-configuration/mail-lists.html

> 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)


[jira] [Commented] (CONFIGURATION-641) XMLConfiguration.load may throw NPE

2017-03-16 Thread JIRA

[ 
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)


[jira] [Commented] (CONFIGURATION-641) XMLConfiguration.load may throw NPE

2017-03-18 Thread Oliver Heger (JIRA)

[ 
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)