pingpingy1 opened a new pull request, #368:
URL: https://github.com/apache/commons-configuration/pull/368

   The current implementation of `DatabaseConfiguration.getKeysInternal` throws 
an NPE (with a rather convoluted error trace, might I add) if the `Datasource` 
of the instance has not been set.
   It might be a better description to return an empty iterator in those cases, 
which this PR intends to implement.
   
   Example:
   ```java
   import org.apache.commons.configuration2.ConfigurationUtils;
   import org.apache.commons.configuration2.DatabaseConfiguration;
   
   public class Test {
       public static void main(String args[]) throws Exception {
           ConfigurationUtils.toString(new DatabaseConfiguration());
       }
   }
   ```
   
   ```console
   Exception in thread "main" java.lang.NullPointerException: Cannot invoke 
"javax.sql.DataSource.getConnection()" because the return value of 
"org.apache.commons.configuration2.DatabaseConfiguration.getDatasource()" is 
null
           at 
org.apache.commons.configuration2.DatabaseConfiguration$AbstractJdbcOperation.execute(DatabaseConfiguration.java:615)
           at 
org.apache.commons.configuration2.DatabaseConfiguration.getKeysInternal(DatabaseConfiguration.java:481)
           at 
org.apache.commons.configuration2.AbstractConfiguration.getKeys(AbstractConfiguration.java:752)
           at 
org.apache.commons.configuration2.ConfigurationUtils.dump(ConfigurationUtils.java:114)
           at 
org.apache.commons.configuration2.ConfigurationUtils.toString(ConfigurationUtils.java:149)
           at 
org.apache.commons.configuration2.ConfigurationUtils.toString(ConfigurationUtils.java:161)
           at Test.main(Test.java:6)
   ```


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to