Skip to content

Commit 92bc17b

Browse files
committed
Merge branch '2.12' into 2.13
2 parents 15ed91c + c8f3dff commit 92bc17b

File tree

3 files changed

+30
-2
lines changed

3 files changed

+30
-2
lines changed

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1391,6 +1391,10 @@ protected int _nextToken() throws IOException {
13911391
return _xmlTokens.next();
13921392
} catch (XMLStreamException e) {
13931393
return StaxUtil.throwAsParseException(e, this);
1394+
} catch (IllegalStateException e) {
1395+
// 08-Apr-2021, tatu: Should improve on this, wrt better information
1396+
// on issue.
1397+
throw new JsonParseException(this, e.getMessage(), e);
13941398
}
13951399
}
13961400

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ public class XmlTokenStream
143143
*/
144144
protected String _nextLocalName;
145145
protected String _nextNamespaceURI;
146-
146+
147147
/*
148148
/**********************************************************************
149149
/* Life-cycle
@@ -426,7 +426,8 @@ private final int _next() throws XMLStreamException
426426
throw new IllegalStateException("Unexpected end-of-input after null token");
427427
default:
428428
}
429-
throw new IllegalStateException("Unexpected START_ELEMENT after null token");
429+
throw new IllegalStateException(
430+
"Unexpected START_ELEMENT after null token (inside element with 'xsi:nil' attribute)");
430431
}
431432
if (_nextAttributeIndex < _attributeCount) {
432433
//System.out.println(" XmlTokenStream._next(): Got attr(s)!");
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
package com.fasterxml.jackson.dataformat.xml.failing;
2+
3+
import com.fasterxml.jackson.databind.JsonNode;
4+
import com.fasterxml.jackson.dataformat.xml.XmlMapper;
5+
import com.fasterxml.jackson.dataformat.xml.XmlTestBase;
6+
7+
public class XsiNilEnableDisable467Test extends XmlTestBase
8+
{
9+
private final static String XSI_NS_DECL = "xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'";
10+
11+
private final XmlMapper MAPPER = newMapper();
12+
13+
// [databind#467] / [databind#467]: xsi:nil handling of nested elements etc
14+
public void testNilAsNodeLeaf() throws Exception
15+
{
16+
JsonNode node = MAPPER.readTree(
17+
"<e>"
18+
+"<h xmlns:xsi='"+XSI_NS_DECL+"' xsi:nil='true'><child /></h>"
19+
+"</e>"
20+
);
21+
assertNotNull(node);
22+
}
23+
}

0 commit comments

Comments
 (0)