[
https://issues.apache.org/jira/browse/CONFIGURATION-429?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12936092#action_12936092
]
Oliver Heger commented on CONFIGURATION-429:
--------------------------------------------
To your questions:
The reason why the method cannot be added to the Configuration interface is
also related to backwards compatibility. We have the rule that minor releases
must be binary backwards compatible. Adding a method to an interface is not a
binary compatible change. So this allowed only for a major release.
Making the behavior optional would be possible, but to be honest, I do not like
this approach very much. We have done this in the past for some flags (e.g. for
the handling of list delimiters), and it always makes the code pretty complex.
Also, from an API user's point of view this solution does not seem to be ideal.
If you accidently set your flags wrong, you will get unpredictable behavior and
errors hard to debug.
But maybe you can use the {{getMaxIndex()}} method: it returns values >= 0 if
the key is present and -1 otherwise.
> configuration values of nodes with children inconsistent
> --------------------------------------------------------
>
> Key: CONFIGURATION-429
> URL: https://issues.apache.org/jira/browse/CONFIGURATION-429
> Project: Commons Configuration
> Issue Type: Bug
> Affects Versions: 1.6
> Reporter: Silas De Munck
> Original Estimate: 0.08h
> Remaining Estimate: 0.08h
>
> {quote}
> <core>
> <multicore>
> <numberOfCores>2</numberOfCores>
> </multicore>
> <singlecore />
> </core>
> {quote}
> In an XML configfile (see above) where I want to check if a specific node is
> specified. I do this using the containsKey() method on the configuration.
> In this case it will return true for the key "core.singlecore" but not for
> the key "core.multicore".
> If I change the multicore part to this (adding text as a child), it does
> return true.
> {quote}
> <multicore>
> ABC
> <numberOfCores>2</numberOfCores>
> </multicore>
> {quote}
> As the containsKey() method depends on the getProperty() method, the same
> problem exists in that method.
> In the first case:
> "core.singlecore" returns an empty string
> "core.multicore" returns null
> and in the second case, "ABC" is returned.
> I would like it to also return an empty string in the first case for
> "core.multicore".
> This behaviour is caused by the code in lines 642-644 of
> XMLConfiguration.java (svn):
> {quote}
> if (text.length() > 0 || (!node.hasChildren() && node != getRoot()))
> \{
> node.setValue(text);
> \}
> {quote}
> I think it can be changed to just this:
> {quote}
> if (node != getRoot() || text.length() > 0)
> \{
> node.setValue(text);
> \}
> {quote}
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.