sharanggupta opened a new pull request, #662: URL: https://github.com/apache/commons-configuration/pull/662
Fixes [CONFIGURATION-781](https://issues.apache.org/jira/browse/CONFIGURATION-781). **What** A custom `ConversionHandler` set on a hierarchical configuration is not used by its sub configurations. `config.get(Duration.class, "section.timeout")` uses the custom handler, but `config.immutableConfigurationAt("section").get(Duration.class, "timeout")` uses the default one and, in the example from the issue, throws a `ConversionException`. **How** `BaseHierarchicalConfiguration.initSubConfiguration()` copies the synchronizer, the expression engine, the list delimiter handler and the throw-exception-on-missing flag to every sub configuration it creates, but not the conversion handler. It now copies the conversion handler too, as the reporter suggested. This covers `configurationAt()`, with and without updates, `immutableConfigurationAt()`, `configurationsAt()` and `childConfigurationsAt()`, which all go through this method. **Tests** `TestHierarchicalConfiguration.testSubConfigurationsUseConversionHandlerOfParent` sets a conversion handler that converts every value to `Locale.CANADA` and reads a `Locale` through each kind of sub configuration. It fails on master (`Key 'name' cannot be converted to class java.util.Locale. Value is: 'users'.`) and passes with this change. The default `mvn` goal passes locally on Java 17. Before you push a pull request, review this list: - [x] Read the [contribution guidelines](CONTRIBUTING.md) for this project. - [x] Read the [ASF Generative Tooling Guidance](https://www.apache.org/legal/generative-tooling.html) if you use Artificial Intelligence (AI). - [x] I used AI to create any part of, or all of, this pull request. Which AI tool was used to create this pull request, and to what extent did it contribute? Claude (Anthropic) helped draft the fix and the test; I reviewed them, ran the build and checked that the test fails without the change. - [x] Run a successful build using the default [Maven](https://maven.apache.org/) goal with `mvn`; that's `mvn` on the command line by itself. - [x] Write unit tests that match behavioral changes, where the tests fail if the changes to the runtime are not applied. This may not always be possible, but it is a best practice. - [x] Write a pull request description that is detailed enough to understand what the pull request does, how, and why. - [x] Each commit in the pull request should have a meaningful subject line and body. Note that a maintainer may squash commits during the merge process. -- 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]
