commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Carsten Kaiser (JIRA)" <>
Subject [jira] Created: (CONFIGURATION-254) Wrong creation of XMLFileConfigurationDelegate in XMLConfiguration.clone()
Date Wed, 28 Feb 2007 21:22:51 GMT
Wrong creation of XMLFileConfigurationDelegate in XMLConfiguration.clone()

                 Key: CONFIGURATION-254
             Project: Commons Configuration
          Issue Type: Bug
    Affects Versions: 1.3
         Environment: Java 1.4.2, Windows XP, Shale
            Reporter: Carsten Kaiser

The clone() operation on a XMLConfiguration does not work correctly due to the following problem:

private class XMLFileConfigurationDelegate extends FileConfigurationDelegate
     public void load(InputStream in) throws ConfigurationException

Obviously the delegate references the XMLConfiguration instance it is created in. Thus when

public Object clone()
      XMLConfiguration copy = (XMLConfiguration) super.clone();

       // clear document related properties
       copy.document = null;


       // clear all references in the nodes, too
       copy.getRoot().visit(new NodeVisitor()
            public void visitBeforeChildren(Node node, ConfigurationKey key)
        }, null);
        return copy;
the delegate still references the original XMLConfiguration, thus will save the content of
the original one
to file instead of the clone as expected! Changing the code like this


solves the problem! Now the cloned XMLConfiguration with all its  applied changes can be saved!

This message is automatically generated by JIRA.
You can reply to this email to add a comment to the issue online.

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message