commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Silas De Munck (JIRA)" <j...@apache.org>
Subject [jira] Created: (CONFIGURATION-429) configuration values of nodes with children inconsistent
Date Wed, 24 Nov 2010 14:41:14 GMT
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


{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()) 
        {
            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.


Mime
View raw message