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

   Currently when initializing a 
org.apache.commons.configuration2.SubsetConfiguration.SubsetConfiguration(Configuration,
 String, String) with a delimiter (other than ".") methods 
SubsetConfiguration.getKeys() and SubsetConfiguration.isEmpty() wont work.
   
   - SubsetConfiguration.isEmpty() always will return "true"
   - SubsetConfiguration.getKeys() always will return an empty iterator
   
   This is because SubsetConfiguration.getKeysInternal() instantiates a 
SubsetIterator and passing the iterator returned by 
org.apache.commons.configuration2.AbstractConfiguration.getKeys(String)
   ```
   @Override
   protected Iterator<String> getKeysInternal() {
       return new SubsetIterator(parent.getKeys(prefix));
   }
   ```
   With org.apache.commons.configuration2.AbstractConfiguration.getKeys(String) 
org.apache.commons.configuration2.PrefixedKeysIterator.PrefixedKeysIterator is 
instantiated. Here "." is hard coded to be used as a prefix delimiter, as also 
mentioned in the Javadoc.
   
   org.apache.commons.configuration2.PrefixedKeysIterator.setNextElement():
   ```
   private boolean setNextElement() {
       while (iterator.hasNext()) {
           final String key = iterator.next();
           if (key.startsWith(prefix + ".") || key.equals(prefix)) {
               nextElement = key;
               nextElementSet = true;
               return true;
           }
       }
       return false;
   }
   ```
   
   When using SubsetConfiguration with a specified delimiter the delimiter 
should also be used consequently. 


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