pjfanning opened a new pull request, #117:
URL: https://github.com/apache/poi-xmlbeans/pull/117
`SaxLoader.postLoad()` exists to drop the loader's references to the
document it just built:
```java
void postLoad(Cur c) {
// fix garbage collection of Locale -> Xobj -> STL
_locale = null;
_context = null;
}
```
It only runs when the parse completes. Every failure path leaves both fields
set — the four catch blocks call `_context.abort()` and rethrow without
clearing them, and an `IOException` out of `_xr.parse(is)` is not caught at
all, so it does not even abort.
That matters because the `XMLReader` holds the `SaxLoader` as its content,
DTD, error, lexical and declaration handler. When xmlbeans creates the reader
itself the loader becomes garbage anyway, but
`XmlOptions.setLoadUseXMLReader(...)` lets a caller supply a reader that
outlives the parse — and callers reuse `XmlOptions`. A failed load then pins
the partly built document and its `SchemaTypeLoader` on that reader until the
next parse, which is exactly the `Locale -> Xobj -> STL` chain the comment
above is about.
This aborts and clears from a `finally`, which also covers the previously
uncaught `IOException` path. The per-catch `_context.abort()` calls go away,
and the `catch (RuntimeException e)` block existed only to abort before
rethrowing, so it goes too.
Added `SaxLoaderAbortTest`: it supplies its own `XMLReader`, parses, then
reflects on the reader's content handler to check `_locale` and `_context` are
cleared. The two failure cases fail on trunk and pass with this change; the
success case passes either way and pins the existing `postLoad` behaviour.
Full suite: 3173 tests pass (170 skipped).
🤖 Generated with [Claude Code](https://claude.com/claude-code)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]