You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by "Carsten Kaiser (JIRA)" <ji...@apache.org> on 2007/02/28 22:22:51 UTC

[jira] Created: (CONFIGURATION-254) Wrong creation of XMLFileConfigurationDelegate in XMLConfiguration.clone()

Wrong creation of XMLFileConfigurationDelegate in XMLConfiguration.clone()
--------------------------------------------------------------------------

                 Key: CONFIGURATION-254
                 URL: https://issues.apache.org/jira/browse/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
     {
            XMLConfiguration.this.load(in);
      }
}

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

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

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

       copy.setDelegate(createDelegate());

       // clear all references in the nodes, too
       copy.getRoot().visit(new NodeVisitor()
       {
            public void visitBeforeChildren(Node node, ConfigurationKey key)
            {
                node.setReference(null);
             }
        }, 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

        copy.setDelegate(copy.createDelegate());

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: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


[jira] Resolved: (CONFIGURATION-254) Wrong creation of XMLFileConfigurationDelegate in XMLConfiguration.clone()

Posted by "Oliver Heger (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/CONFIGURATION-254?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Oliver Heger resolved CONFIGURATION-254.
----------------------------------------

    Resolution: Fixed

The suggested fix was committed. Many thanks.

> Wrong creation of XMLFileConfigurationDelegate in XMLConfiguration.clone()
> --------------------------------------------------------------------------
>
>                 Key: CONFIGURATION-254
>                 URL: https://issues.apache.org/jira/browse/CONFIGURATION-254
>             Project: Commons Configuration
>          Issue Type: Bug
>    Affects Versions: 1.3
>         Environment: Java 1.4.2, Windows XP, Shale
>            Reporter: Carsten Kaiser
>         Assigned To: Oliver Heger
>             Fix For: 1.4
>
>
> 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
>      {
>             XMLConfiguration.this.load(in);
>       }
> }
> Obviously the delegate references the XMLConfiguration instance it is created in. Thus when calling
> public Object clone()
> {
>       XMLConfiguration copy = (XMLConfiguration) super.clone();
>        // clear document related properties
>        copy.document = null;
>        copy.setDelegate(createDelegate());
>        // clear all references in the nodes, too
>        copy.getRoot().visit(new NodeVisitor()
>        {
>             public void visitBeforeChildren(Node node, ConfigurationKey key)
>             {
>                 node.setReference(null);
>              }
>         }, 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
>         copy.setDelegate(copy.createDelegate());
> 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: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


[jira] Updated: (CONFIGURATION-254) Wrong creation of XMLFileConfigurationDelegate in XMLConfiguration.clone()

Posted by "Oliver Heger (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/CONFIGURATION-254?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Oliver Heger updated CONFIGURATION-254:
---------------------------------------

    Fix Version/s: 1.4

> Wrong creation of XMLFileConfigurationDelegate in XMLConfiguration.clone()
> --------------------------------------------------------------------------
>
>                 Key: CONFIGURATION-254
>                 URL: https://issues.apache.org/jira/browse/CONFIGURATION-254
>             Project: Commons Configuration
>          Issue Type: Bug
>    Affects Versions: 1.3
>         Environment: Java 1.4.2, Windows XP, Shale
>            Reporter: Carsten Kaiser
>         Assigned To: Oliver Heger
>             Fix For: 1.4
>
>
> 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
>      {
>             XMLConfiguration.this.load(in);
>       }
> }
> Obviously the delegate references the XMLConfiguration instance it is created in. Thus when calling
> public Object clone()
> {
>       XMLConfiguration copy = (XMLConfiguration) super.clone();
>        // clear document related properties
>        copy.document = null;
>        copy.setDelegate(createDelegate());
>        // clear all references in the nodes, too
>        copy.getRoot().visit(new NodeVisitor()
>        {
>             public void visitBeforeChildren(Node node, ConfigurationKey key)
>             {
>                 node.setReference(null);
>              }
>         }, 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
>         copy.setDelegate(copy.createDelegate());
> 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: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org