Skip to content

Commit 98d8c27

Browse files
committed
Merge branch '2.6'
Conflicts: pom.xml release-notes/VERSION
2 parents df60be4 + 3502de0 commit 98d8c27

File tree

3 files changed

+27
-19
lines changed

3 files changed

+27
-19
lines changed

release-notes/VERSION

+4
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ Project: jackson-dataformat-xml
99
#156: Add `XmlMapper.setDefaultUseWrapper()` for convenience.
1010
#169: Fail to deserialize "empty" polymorphic classes
1111

12+
2.6.5 (not yet released)
13+
14+
#177: Failure to deserialize unwrapped list where entry has empty content, attribute(s)
15+
1216
2.6.4 (07-Dec-2015)
1317

1418
#171: `@JacksonXmlRootElement` malfunction in multi-thread environment

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

+21-17
Original file line numberDiff line numberDiff line change
@@ -411,7 +411,7 @@ public boolean isExpectedStartArrayToken()
411411
//System.out.println(" isExpectedArrayStart: OBJ->Array, wraps now: "+_parsingContext.getNamesToWrap());
412412
// And just in case a field name was to be returned, wipe it
413413
_nextToken = null;
414-
// and last thing, [Issue#33], better ignore attributes
414+
// and last thing, [dataformat-xml#33], better ignore attributes
415415
_xmlTokens.skipAttributes();
416416
return true;
417417
}
@@ -422,7 +422,7 @@ public boolean isExpectedStartArrayToken()
422422
// DEBUGGING
423423
/*
424424
@Override
425-
public JsonToken nextToken() throws IOException, JsonParseException
425+
public JsonToken nextToken() throws IOException
426426
{
427427
JsonToken t = nextToken0();
428428
if (t != null) {
@@ -444,7 +444,7 @@ public JsonToken nextToken() throws IOException, JsonParseException
444444
@Override
445445
public JsonToken nextToken() throws IOException
446446
{
447-
_binaryValue = null; // to fix [Issue-29]
447+
_binaryValue = null;
448448
if (_nextToken != null) {
449449
JsonToken t = _nextToken;
450450
_currToken = t;
@@ -471,9 +471,8 @@ public JsonToken nextToken() throws IOException
471471
}
472472
int token = _xmlTokens.next();
473473

474-
/* Need to have a loop just because we may have to eat/convert
475-
* a start-element that indicates an array element.
476-
*/
474+
// Need to have a loop just because we may have to eat/convert
475+
// a start-element that indicates an array element.
477476
while (token == XmlTokenStream.XML_START_ELEMENT) {
478477
// If we thought we might get leaf, no such luck
479478
if (_mayBeLeaf) {
@@ -483,28 +482,24 @@ public JsonToken nextToken() throws IOException
483482
return (_currToken = JsonToken.START_OBJECT);
484483
}
485484
if (_parsingContext.inArray()) {
486-
/* Yup: in array, so this element could be verified; but it won't be reported
487-
* anyway, and we need to process following event.
488-
*/
485+
// Yup: in array, so this element could be verified; but it won't be
486+
// reported anyway, and we need to process following event.
489487
token = _xmlTokens.next();
490488
_mayBeLeaf = true;
491489
continue;
492490
}
493491
String name = _xmlTokens.getLocalName();
494492
_parsingContext.setCurrentName(name);
495493

496-
/* Ok: virtual wrapping can be done by simply repeating
497-
* current START_ELEMENT. Couple of ways to do it; but
498-
* start by making _xmlTokens replay the thing...
499-
*/
494+
// Ok: virtual wrapping can be done by simply repeating current START_ELEMENT.
495+
// Couple of ways to do it; but start by making _xmlTokens replay the thing...
500496
if (_namesToWrap != null && _namesToWrap.contains(name)) {
501497
_xmlTokens.repeatStartElement();
502498
}
503499

504500
_mayBeLeaf = true;
505-
/* Ok: in array context we need to skip reporting field names. But what's the best way
506-
* to find next token?
507-
*/
501+
// Ok: in array context we need to skip reporting field names.
502+
// But what's the best way to find next token?
508503
return (_currToken = JsonToken.FIELD_NAME);
509504
}
510505

@@ -555,8 +550,17 @@ public JsonToken nextToken() throws IOException
555550
}
556551
}
557552
return (_currToken = JsonToken.VALUE_STRING);
553+
} else {
554+
// [dataformat-xml#177]: empty text may also need to be skipped
555+
if (_parsingContext.inObject()
556+
&& (_currToken != JsonToken.FIELD_NAME) && _isEmpty(_currText)) {
557+
_currToken = JsonToken.END_OBJECT;
558+
_parsingContext = _parsingContext.getParent();
559+
_namesToWrap = _parsingContext.getNamesToWrap();
560+
return _currToken;
561+
}
558562
}
559-
// If not a leaf, need to transform into property...
563+
// If not a leaf (or otherwise ignorable), need to transform into property...
560564
_parsingContext.setCurrentName(_cfgNameForTextElement);
561565
_nextToken = JsonToken.VALUE_STRING;
562566
return (_currToken = JsonToken.FIELD_NAME);

src/test/java/com/fasterxml/jackson/dataformat/xml/failing/EmptyList177Test.java renamed to src/test/java/com/fasterxml/jackson/dataformat/xml/lists/EmptyListDeserTest.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
package com.fasterxml.jackson.dataformat.xml.failing;
1+
package com.fasterxml.jackson.dataformat.xml.lists;
22

33
import java.util.List;
44

55
import com.fasterxml.jackson.dataformat.xml.*;
66
import com.fasterxml.jackson.dataformat.xml.annotation.*;
77

88
// for [dataformat-xml#177]
9-
public class EmptyList177Test extends XmlTestBase
9+
public class EmptyListDeserTest extends XmlTestBase
1010
{
1111
static class Config
1212
{

0 commit comments

Comments
 (0)