Skip to content

Commit d9e559a

Browse files
committed
Merge branch '2.12' into 2.13
2 parents 8360b9e + d9738d9 commit d9e559a

File tree

4 files changed

+29
-16
lines changed

4 files changed

+29
-16
lines changed

release-notes/VERSION-2.x

+5
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@ Project: jackson-dataformat-xml
1616
(reported by Fabian M)
1717
- Woodstox dependency 6.2.6 (from 6.2.4)
1818

19+
2.12.4 (not yet released)
20+
21+
#469: Empty tags cause incorrect deserialization of unwrapped lists
22+
(reported by jackson-code1@github)
23+
1924
2.12.3 (12-Apr-2021)
2025

2126
#456: Fix JsonAlias with unwrapped lists

src/main/java/com/fasterxml/jackson/dataformat/xml/deser/WrapperHandlingDeserializer.java

+9-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import java.util.*;
55

66
import com.fasterxml.jackson.core.JsonParser;
7+
import com.fasterxml.jackson.core.JsonToken;
78
import com.fasterxml.jackson.core.util.JsonParserDelegate;
89
import com.fasterxml.jackson.databind.*;
910
import com.fasterxml.jackson.databind.deser.*;
@@ -154,7 +155,14 @@ protected final void _configureParser(JsonParser p) throws IOException
154155
p = ((JsonParserDelegate) p).delegate();
155156
}
156157
if (p instanceof FromXmlParser) {
157-
((FromXmlParser) p).addVirtualWrapping(_namesToWrap, _caseInsensitive);
158+
// 03-May-2021, tatu: as per [dataformat-xml#469] there are special
159+
// cases where we get String token to represent XML empty element.
160+
// If so, need to refrain from adding wrapping as that would
161+
// override parent settings
162+
JsonToken t = p.currentToken();
163+
if (t == JsonToken.START_OBJECT || t == JsonToken.START_ARRAY) {
164+
((FromXmlParser) p).addVirtualWrapping(_namesToWrap, _caseInsensitive);
165+
}
158166
}
159167
}
160168

src/main/java/com/fasterxml/jackson/dataformat/xml/deser/XmlReadContext.java

+14-15
Original file line numberDiff line numberDiff line change
@@ -43,20 +43,19 @@ public final class XmlReadContext
4343
protected String _wrappedName;
4444

4545
/*
46-
/**********************************************************
47-
/* Simple instance reuse slots; speeds up things
48-
/* a bit (10-15%) for docs with lots of small
49-
/* arrays/objects (for which allocation was
46+
/**********************************************************************
47+
/* Simple instance reuse slots; speeds up things a bit (10-15%)
48+
/* for docs with lots of small arrays/objects (for which allocation was
5049
/* visible in profile stack frames)
51-
/**********************************************************
50+
/**********************************************************************
5251
*/
5352

5453
protected XmlReadContext _child = null;
5554

5655
/*
57-
/**********************************************************
56+
/**********************************************************************
5857
/* Instance construction, reuse
59-
/**********************************************************
58+
/**********************************************************************
6059
*/
6160

6261
public XmlReadContext(XmlReadContext parent, int type, int lineNr, int colNr)
@@ -91,9 +90,9 @@ public void setCurrentValue(Object v) {
9190
}
9291

9392
/*
94-
/**********************************************************
93+
/**********************************************************************
9594
/* Factory methods
96-
/**********************************************************
95+
/**********************************************************************
9796
*/
9897

9998
public static XmlReadContext createRootContext(int lineNr, int colNr) {
@@ -129,9 +128,9 @@ public final XmlReadContext createChildObjectContext(int lineNr, int colNr)
129128
}
130129

131130
/*
132-
/**********************************************************
131+
/**********************************************************************
133132
/* Abstract method implementation, overrides
134-
/**********************************************************
133+
/**********************************************************************
135134
*/
136135

137136
@Override
@@ -156,9 +155,9 @@ public final JsonLocation startLocation(ContentReference srcRef) {
156155
}
157156

158157
/*
159-
/**********************************************************
158+
/**********************************************************************
160159
/* Extended API
161-
/**********************************************************
160+
/**********************************************************************
162161
*/
163162

164163
/**
@@ -189,9 +188,9 @@ protected void convertToArray() {
189188
}
190189

191190
/*
192-
/**********************************************************
191+
/**********************************************************************
193192
/* Overridden standard methods
194-
/**********************************************************
193+
/**********************************************************************
195194
*/
196195

197196
/**

src/test/java/com/fasterxml/jackson/dataformat/xml/failing/ListDeser469FailingTest.java

+1
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ public void testIssue469WithDefaults() throws Exception
8383
"<outer>\n" +
8484
" <inner1/>\n" +
8585
" <inner2 str2='aaaa'/>\n" +
86+
// " <inner2><str2>aaaa</str2></inner2>\n" +
8687
"</outer>\n";
8788

8889
Outer469 result = mapper.readValue(xmlInput, Outer469.class);

0 commit comments

Comments
 (0)