You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "jo desmet (JIRA)" <ji...@apache.org> on 2011/04/06 14:55:05 UTC
[jira] [Created] (CONFIGURATION-445) XMLConfiguration save gives
wrong xml when it contains combined elements (viewNode) with attributes
XMLConfiguration save gives wrong xml when it contains combined elements (viewNode) with attributes
---------------------------------------------------------------------------------------------------
Key: CONFIGURATION-445
URL: https://issues.apache.org/jira/browse/CONFIGURATION-445
Project: Commons Configuration
Issue Type: Bug
Reporter: jo desmet
when creating a CombinedConfiguration with an overridecombiner I get into trouble when I need to generate a xml file from te resulting view. It seems that the viewNodes which are created do not handle the parent of the attributes correctly.
So when saving this configuration the attributes get lost and attached to the rootnode.
I made a unit test and will attach the following files :
- component1.xml
- component1_spec.xml
- AttributeTest.java
- log output
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] [Updated] (CONFIGURATION-445) XMLConfiguration save gives
wrong xml when it contains combined elements (viewNode) with attributes
Posted by "jo desmet (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/CONFIGURATION-445?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
jo desmet updated CONFIGURATION-445:
------------------------------------
seems no attachement is possible, so inlined :
component1.xml :
<configuration>
<key1 override="USER">value1</key1>
<key2 override="USER2">value2</key2>
</configuration>
component1_spec.xml:
<configuration>
<key2 override="USER2">value2_spec</key2>
</configuration>
AttributeTest.java (relevant section)
@Test
public void testAttributeSave() throws Exception {
final XMLConfiguration x1 = new XMLConfiguration("component1.xml");
final XMLConfiguration x2 = new XMLConfiguration("component1_spec.xml");
dump(x1);
dump(x2);
final CombinedConfiguration c = new CombinedConfiguration();
c.setNodeCombiner(new OverrideCombiner());
c.addConfiguration(x2);
dump(c);
c.addConfiguration(x1);
dump(c);
}
public static void dump(final XMLConfiguration c) throws ConfigurationException {
final StringWriter w = new StringWriter();
c.save(w);
LOGGER.info(w.toString());
}
public static void dump(final CombinedConfiguration c) throws ConfigurationException {
final XMLConfiguration dump = new XMLConfiguration(c);
dump(dump);
}
and resulting output (Last section is where the output is : the attribute is moved to top level):
14:41:53.704 [main] INFO AttributeTest - <?xml version="1.0" encoding="UTF-8"?>
<configuration>
<key1 override="USER">value1</key1>
<key2 override="USER2">value2</key2>
</configuration>
14:41:53.704 [main] INFO AttributeTest - <?xml version="1.0" encoding="UTF-8"?>
<configuration>
<key2 override="USER2">value2_spec</key2>
</configuration>
14:41:53.720 [main] INFO AttributeTest - <?xml version="1.0" encoding="UTF-8"?>
<configuration>
<key2 override="USER2">value2_spec</key2>
</configuration>
14:41:53.720 [main] INFO AttributeTest - <?xml version="1.0" encoding="UTF-8"?>
<configuration override="USER2">
<key2>value2_spec</key2>
<key1 override="USER">value1</key1>
</configuration>
> XMLConfiguration save gives wrong xml when it contains combined elements (viewNode) with attributes
> ---------------------------------------------------------------------------------------------------
>
> Key: CONFIGURATION-445
> URL: https://issues.apache.org/jira/browse/CONFIGURATION-445
> Project: Commons Configuration
> Issue Type: Bug
> Reporter: jo desmet
>
> when creating a CombinedConfiguration with an overridecombiner I get into trouble when I need to generate a xml file from te resulting view. It seems that the viewNodes which are created do not handle the parent of the attributes correctly.
> So when saving this configuration the attributes get lost and attached to the rootnode.
> I made a unit test and will attach the following files :
> - component1.xml
> - component1_spec.xml
> - AttributeTest.java
> - log output
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] [Commented] (CONFIGURATION-445) XMLConfiguration save gives
wrong xml when it contains combined elements (viewNode) with attributes
Posted by "jo desmet (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/CONFIGURATION-445?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13016710#comment-13016710 ]
jo desmet commented on CONFIGURATION-445:
-----------------------------------------
I tried to debug to get more info : it seems that the issue is linke to the following :
In the hierarchicalConfiguration$Node.visit the visitBeforeChildren is called on the visitor. This visitor sets the references of the nodes correctly. Except when the node concerned is a viewnode, it creates a new Node based on this. When coming back to the visit afterwards, logic continues based on the children which still contain the viewnode and thus the wrong or absent reference. I currently have not enough knowledge of the code to understand how this best should work.
tnx
Jo
> XMLConfiguration save gives wrong xml when it contains combined elements (viewNode) with attributes
> ---------------------------------------------------------------------------------------------------
>
> Key: CONFIGURATION-445
> URL: https://issues.apache.org/jira/browse/CONFIGURATION-445
> Project: Commons Configuration
> Issue Type: Bug
> Reporter: jo desmet
> Attachments: AttributeTest.java, component1.xml, component1_spec.xml
>
>
> when creating a CombinedConfiguration with an overridecombiner I get into trouble when I need to generate a xml file from te resulting view. It seems that the viewNodes which are created do not handle the parent of the attributes correctly.
> So when saving this configuration the attributes get lost and attached to the rootnode.
> I made a unit test and will attach the following files :
> - component1.xml
> - component1_spec.xml
> - AttributeTest.java
> - log output
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] [Updated] (CONFIGURATION-445) XMLConfiguration save gives
wrong xml when it contains combined elements (viewNode) with attributes
Posted by "jo desmet (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/CONFIGURATION-445?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
jo desmet updated CONFIGURATION-445:
------------------------------------
Attachment: AttributeTest.java
component1_spec.xml
component1.xml
> XMLConfiguration save gives wrong xml when it contains combined elements (viewNode) with attributes
> ---------------------------------------------------------------------------------------------------
>
> Key: CONFIGURATION-445
> URL: https://issues.apache.org/jira/browse/CONFIGURATION-445
> Project: Commons Configuration
> Issue Type: Bug
> Reporter: jo desmet
> Attachments: AttributeTest.java, component1.xml, component1_spec.xml
>
>
> when creating a CombinedConfiguration with an overridecombiner I get into trouble when I need to generate a xml file from te resulting view. It seems that the viewNodes which are created do not handle the parent of the attributes correctly.
> So when saving this configuration the attributes get lost and attached to the rootnode.
> I made a unit test and will attach the following files :
> - component1.xml
> - component1_spec.xml
> - AttributeTest.java
> - log output
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] [Resolved] (CONFIGURATION-445) XMLConfiguration save gives
wrong xml when it contains combined elements (viewNode) with attributes
Posted by "Oliver Heger (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/CONFIGURATION-445?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Oliver Heger resolved CONFIGURATION-445.
----------------------------------------
Resolution: Fixed
Fix Version/s: 1.7
A fix was applied in subversion. Many thanks for this report and your detailed analysis!
A note regarding the configuration2 branch: The problem probably does not exist here because there is no transformation of ViewNodes to other nodes (this is actually the result of a refactoring which could not be fully finished because of the requirement to stay binary compatible). However, it is currently not possible to copy a combined configuration into an XMLConfiguration easily. So this assumption cannot be verified.
> XMLConfiguration save gives wrong xml when it contains combined elements (viewNode) with attributes
> ---------------------------------------------------------------------------------------------------
>
> Key: CONFIGURATION-445
> URL: https://issues.apache.org/jira/browse/CONFIGURATION-445
> Project: Commons Configuration
> Issue Type: Bug
> Reporter: jo desmet
> Assignee: Oliver Heger
> Fix For: 1.7
>
> Attachments: AttributeTest.java, component1.xml, component1_spec.xml
>
>
> when creating a CombinedConfiguration with an overridecombiner I get into trouble when I need to generate a xml file from te resulting view. It seems that the viewNodes which are created do not handle the parent of the attributes correctly.
> So when saving this configuration the attributes get lost and attached to the rootnode.
> I made a unit test and will attach the following files :
> - component1.xml
> - component1_spec.xml
> - AttributeTest.java
> - log output
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira