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

Laszlo Hujber commented on CONFIGURATION-848:
---------------------------------------------

Hi [~ggregory],

I tested and reviewed your changes, and they look good to me. You are right 
that the custom delimiter was not supported in 2.9 for 
{{{}JSONConfiguration{}}}, and I am fine with that. We can remove this 
assertion:
{code:java}
// 3. using '@' delimiter
subset = new SubsetConfiguration(jsonConfiguration, "books(1)@details", "@");
assertFalse(subset.isEmpty());
assertEquals(2, subset.size());
assertEquals("White Nights", subset.getString("title")); {code}
However, the first assertion using {{CompositeConfiguration}} is passing on 
2.9, which is one of my use cases. Could we maybe extend 
{{CompositeConfiguration}} like you did in 
[AbstractHierarchicalConfiguration|https://github.com/apache/commons-configuration/commit/24a1baf929a44d210c80fb932d8275e506b41d46#diff-718c630624a310af12fd08b38ddc674f12a2170b27ac8470d8ac78ca6c8be958]?
 For example:
{code:java}
@Override
protected Iterator<String> getKeysInternal(final String key) {
    final Set<String> keys = new LinkedHashSet<>();
    configList.forEach(config -> 
config.getKeys(key).forEachRemaining(keys::add));
    return keys.iterator();
}

@Override
protected Iterator<String> getKeysInternal(final String key, final String 
delimiter) {
   return getKeysInternal(key);
} {code}

> SubsetConfiguration does not account for delimiters as it did in 2.9.0
> ----------------------------------------------------------------------
>
>                 Key: CONFIGURATION-848
>                 URL: https://issues.apache.org/jira/browse/CONFIGURATION-848
>             Project: Commons Configuration
>          Issue Type: Bug
>    Affects Versions: 2.10.0, 2.10.1, 2.11.0
>            Reporter: Laszlo Hujber
>            Assignee: Gary D. Gregory
>            Priority: Major
>
> A bug occurs when using {{SubsetConfiguration}} with concrete subclasses of 
> {{{}AbstractHierarchicalConfiguration{}}}. This issue likely happens because 
> {{AbstractHierarchicalConfiguration}} does not override:
> {code:java}
> protected Iterator<String> getKeysInternal(String prefix, String delimiter) {
> }
> {code}
> The relevant pull request that introduced this bug is 
> [#300|https://github.com/apache/commons-configuration/pull/300].
> Refer to the test case that passes in version 2.9.
> {code:java}
>     @Test
>     public void testSubsetWithJSONConfiguration() throws 
> FileNotFoundException, ConfigurationException {
>         final JSONConfiguration jsonConfiguration = new JSONConfiguration();
>         jsonConfiguration.read(new 
> FileReader(ConfigurationAssert.getTestFile("test.json").getAbsolutePath()));
>         final SubsetConfiguration subset = new 
> SubsetConfiguration(jsonConfiguration, "capitals(0)", ".");
>         assertFalse(subset.isEmpty());
>         assertEquals(2, subset.size());
>         assertEquals("USA", subset.getString("country"));
>     }
> {code}
> Actual Behavior:
>  * {{isEmpty()}} returns {{{}true{}}}.
>  * {{size()}} returns {{{}0{}}}.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to