Skip to content

Commit

Permalink
Fix #196: move endDocument() call to outside of finally-block
Browse files Browse the repository at this point in the history
  • Loading branch information
cowtowncoder committed Feb 21, 2024
1 parent 4a6d227 commit 82de3f4
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
2 changes: 2 additions & 0 deletions release-notes/VERSION
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ Project: woodstox

#134: Increase JDK baseline to Java 8
#194: Remove `QNameCreator` compatibility class
#196: WstxSAXParser error handling when used with JAXB validation
(reported by @winfriedgerlach)

6.6.0 (15-Jan-2024)

Expand Down
14 changes: 8 additions & 6 deletions src/main/java/com/ctc/wstx/sax/WstxSAXParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -584,9 +584,8 @@ public void parse(InputSource input) throws SAXException
mContentHandler.startDocument();
}

/* Note: since we are reusing the same config instance, need to
* make sure state is not carried forward. Thus:
*/
// Note: since we are reusing the same config instance, need to
// make sure state is not carried forward. Thus:
cfg.resetState();

try {
Expand Down Expand Up @@ -626,9 +625,6 @@ public void parse(InputSource input) throws SAXException
} catch (XMLStreamException strex) {
throwSaxException(strex);
} finally {
if (mContentHandler != null) {
mContentHandler.endDocument();
}
// Could try holding onto the buffers, too... but
// maybe it's better to allow them to be reclaimed, if
// needed by GC
Expand All @@ -650,6 +646,12 @@ public void parse(InputSource input) throws SAXException
} catch (IOException ioe) { }
}
}
// 20-Feb-2024, tatu: Was formerly done in finally-block for some
// reason; but makes more sense to only be done on happy path
// (as per [woodstox-core#196]
if (mContentHandler != null) {
mContentHandler.endDocument();
}
}

@Override
Expand Down

0 comments on commit 82de3f4

Please sign in to comment.