pjfanning opened a new pull request, #112: URL: https://github.com/apache/poi-xmlbeans/pull/112
Every `saveXxx()` in `SchemaTypeSystemImpl` (`saveIndex`, `savePointerFile`, `saveGlobalElement`, `saveGlobalAttribute`, `saveModelGroup`, `saveAttributeGroup`, `saveIdentityConstraint`, `saveType`) runs the same sequence: ```java XsbReader saver = new XsbReader(getTypeSystem(), handle); saver.writeTypeData(type); // fills the string pool saver.writeRealHeader(handle, FILETYPE_SCHEMATYPE); // opens the Filer output stream saver.writeTypeData(type); // the real write saver.writeEnd(); // flush + close ``` Nothing guards the middle. Every write helper raises `SchemaTypeLoaderException` on an `IOException`, so a failing write skips `writeEnd()` and leaves the `.xsb` output stream open over a partial file. scomp writes one file per global type, so a failure part-way through a large schema leaks a descriptor for each one already opened. Adds `XsbReader.closeOutputQuietly()` — a no-op once `writeEnd()` has cleared `_output` — and calls it from a `finally` in all eight save methods. Closing quietly rather than calling `writeEnd()` keeps the original failure from being masked by a second `SchemaTypeLoaderException`. Added `XsbSaveStreamTest`, which serves a `Filer` output stream that opens and then fails every write, and asserts the stream is closed. It fails on trunk and passes with this change. `compile.scomp.checkin.CompilationTests` still passes. 🤖 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]
