Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 1d660b5

Browse filesBrowse files
kwinmichael-o
authored andcommitted
Xpp3DomUtils#mergeIntoXpp3Dom() must not override the dominant value in case it is empty (#216)
This #216 and fixes #217
1 parent 748933c commit 1d660b5
Copy full SHA for 1d660b5

File tree

Expand file treeCollapse file tree

2 files changed

+15
-9
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+15
-9
lines changed

‎src/main/java/org/codehaus/plexus/util/xml/Xpp3DomUtils.java

Copy file name to clipboardExpand all lines: src/main/java/org/codehaus/plexus/util/xml/Xpp3DomUtils.java
-8Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,6 @@ public void writeToSerializer( String namespace, XmlSerializer serializer, Xpp3D
9595
* </ol></li>
9696
* <li> If mergeSelf == true
9797
* <ol type="A">
98-
* <li> if the dominant root node's value is empty, set it to the recessive root node's value</li>
99-
* <li> For each attribute in the recessive root node which is not set in the dominant root node, set it.</li>
10098
* <li> Determine whether children from the recessive DOM will be merged or appended to the dominant DOM as
10199
* siblings (flag=mergeChildren).
102100
* <ol type="i">
@@ -140,12 +138,6 @@ private static void mergeIntoXpp3Dom( Xpp3Dom dominant, Xpp3Dom recessive, Boole
140138

141139
if ( mergeSelf )
142140
{
143-
if ( isEmpty( dominant.getValue() ) && !isEmpty( recessive.getValue() ) )
144-
{
145-
dominant.setValue( recessive.getValue() );
146-
dominant.setInputLocation( recessive.getInputLocation() );
147-
}
148-
149141
String[] recessiveAttrs = recessive.getAttributeNames();
150142
for ( String attr : recessiveAttrs )
151143
{

‎src/test/java/org/codehaus/plexus/util/xml/Xpp3DomUtilsTest.java

Copy file name to clipboardExpand all lines: src/test/java/org/codehaus/plexus/util/xml/Xpp3DomUtilsTest.java
+15-1Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ public void testCombineKeys()
115115
}
116116

117117
@Test
118-
public void testOverwriteDominantBlankValue() throws XmlPullParserException, IOException {
118+
public void testPreserveDominantBlankValue() throws XmlPullParserException, IOException {
119119
String lhs = "<parameter xml:space=\"preserve\"> </parameter>";
120120

121121
String rhs = "<parameter>recessive</parameter>";
@@ -127,6 +127,20 @@ public void testOverwriteDominantBlankValue() throws XmlPullParserException, IOE
127127
assertEquals( " ", mergeResult.getValue() );
128128
}
129129

130+
@Test
131+
public void testPreserveDominantEmptyNode() throws XmlPullParserException, IOException
132+
{
133+
String lhs = "<parameter></parameter>";
134+
135+
String rhs = "<parameter>recessive</parameter>";
136+
137+
Xpp3Dom leftDom = Xpp3DomBuilder.build( new StringReader( lhs ), new FixedInputLocationBuilder( "left" ) );
138+
Xpp3Dom rightDom = Xpp3DomBuilder.build( new StringReader( rhs ), new FixedInputLocationBuilder( "right" ) );
139+
140+
Xpp3Dom mergeResult = Xpp3DomUtils.mergeXpp3Dom( leftDom, rightDom, true );
141+
assertEquals( "", mergeResult.getValue() );
142+
}
143+
130144
@Test
131145
public void testIsNotEmptyNegatesIsEmpty()
132146
{

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.