Skip to content

Commit

Permalink
Fixed #350
Browse files Browse the repository at this point in the history
  • Loading branch information
cowtowncoder committed Jul 18, 2019
1 parent 2b5a763 commit 561a456
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
1 change: 1 addition & 0 deletions release-notes/VERSION-2.x
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ Project: jackson-dataformat-xml

#336: WRITE_BIGDECIMAL_AS_PLAIN Not Used When Writing Pretty
(fix contributed by Kevin D)
#350: Wrap Xerces/Stax (JDK-bundled) exceptions during parser initialization

2.9.10 (not yet released)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -649,8 +649,8 @@ protected XMLStreamWriter _createXmlWriter(IOContext ctxt, OutputStream out) thr
XMLStreamWriter sw;
try {
sw = _xmlOutputFactory.createXMLStreamWriter(_decorate(ctxt, out), "UTF-8");
} catch (XMLStreamException e) {
return StaxUtil.throwAsGenerationException(e, null);
} catch (Exception e) {
throw new JsonGenerationException(e.getMessage(), e, null);
}
return _initializeXmlWriter(sw);
}
Expand All @@ -660,8 +660,8 @@ protected XMLStreamWriter _createXmlWriter(IOContext ctxt, Writer w) throws IOEx
XMLStreamWriter sw;
try {
sw = _xmlOutputFactory.createXMLStreamWriter(_decorate(ctxt, w));
} catch (XMLStreamException e) {
return StaxUtil.throwAsGenerationException(e, null);
} catch (Exception e) {
throw new JsonGenerationException(e.getMessage(), e, null);
}
return _initializeXmlWriter(sw);
}
Expand All @@ -672,8 +672,8 @@ protected final XMLStreamWriter _initializeXmlWriter(XMLStreamWriter sw) throws
// (Woodstox doesn't care) -- otherwise it'll add unnecessary odd declaration
try {
sw.setDefaultNamespace("");
} catch (XMLStreamException e) {
return StaxUtil.throwAsGenerationException(e, null);
} catch (Exception e) {
throw new JsonGenerationException(e.getMessage(), e, null);
}
return sw;
}
Expand All @@ -685,8 +685,9 @@ protected final XMLStreamReader _initializeXmlReader(XMLStreamReader sr) throws
while (sr.next() != XMLStreamConstants.START_ELEMENT) {
;
}
} catch (XMLStreamException e) {
return StaxUtil.throwAsParseException(e, null);
// [dataformat-xml#350]: Xerces-backed impl throws non-XMLStreamException so:
} catch (Exception e) {
throw new JsonParseException(null, e.getMessage(), e);
}
return sr;
}
Expand Down

0 comments on commit 561a456

Please sign in to comment.