You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Martin den Heijer (Jira)" <ji...@apache.org> on 2020/03/02 17:27:00 UTC

[jira] [Created] (CONFIGURATION-781) The conversion handler is not inherited by children

Martin den Heijer created CONFIGURATION-781:
-----------------------------------------------

             Summary: The conversion handler is not inherited by children
                 Key: CONFIGURATION-781
                 URL: https://issues.apache.org/jira/browse/CONFIGURATION-781
             Project: Commons Configuration
          Issue Type: Bug
          Components: Type conversion
    Affects Versions: 2.6, 2.1
         Environment: Package: commons-configuration2-2.6.jar (from maven central), apache-commons-configuration2-2.1-6.fc30.noarch (from Fedora repo).

JVM and Java compiler: java-11-openjdk-11.0.6.10-0.fc31.x86_64 (from Fedora repo). 

OS: Fedora 31
            Reporter: Martin den Heijer
         Attachments: Main.java

If a setting is requested from a configuration with a custom converter, the custom converter will be invoked for all conversions as expected, even if the key points to an element in a INI section/XML child element, etcetera.

If the INI section or XML child element is requested using the ImmutableHierarchicalConfiguration.immutableConfigurationAt() or a similar method and the property is requested from the child configuration, then the DefaultConversionHandler is used to perform the conversion.

The attached source demonstrates this behaviour: the last get() causes a ConversionException instead of returning the requested Duration.

I noticed that the conversion handler is not copied in BaseHierarchicalConfiguration.initSubConfiguration(). It should probably be added there, but I do not know if there are more locations were the conversion handler should be copied as well.

 

 

 



--
This message was sent by Atlassian Jira
(v8.3.4#803005)