pjfanning opened a new pull request, #1253:
URL: https://github.com/apache/poi/pull/1253

   `PPTXMLDump.main` opened the `.xml` output stream and closed it only after 
`dump()` returned:
   
   ```java
   OutputStream fos = Files.newOutputStream(Path.of(ppt.getName() + ".xml"));
   OutputStreamWriter out = new OutputStreamWriter(fos, StandardCharsets.UTF_8);
   dump.dump(out);
   out.close();
   ```
   
   An `IOException` part way through the dump skips the `close()` and leaks the 
stream. Switched to try-with-resources.
   
   ### Also in the same block
   
   The console branch wraps `System.out` in a `BufferedWriter` and never 
flushes it. `dump(Writer)` does not flush either — it ends at `write(out, 
"</Presentation>", padding)` — so running the tool **without** `-f` printed 
nothing at all. I've added the missing flush since it is the same six lines and 
the same class of mistake, but happy to split it out if you would rather keep 
this PR to the leak alone.
   
   `System.out` is deliberately flushed rather than closed.
   
   The now-unused `java.io.OutputStream` import is dropped.
   
   This is a dev/debug tool (`org.apache.poi.hslf.dev`), so the leak itself has 
no production impact — it was the one spot in the file not already using 
try-with-resources.
   
   No public signatures change, so there is nothing for MiMa to check. 
`:poi-scratchpad:compileJava` 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]

Reply via email to