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

   `SchemaResourceManager.writeInputStreamToFile` leans on 
`IOUtil.copyCompletely` to close both streams:
   
   ```java
   OutputStream output = Files.newOutputStream(targetFile.toPath());
   IOUtil.copyCompletely(input, output);
   ```
   
   But `copyCompletely` only runs once the target has been opened. If 
`Files.newOutputStream` throws — an unwritable directory, a path component that 
is not a directory, a full disk — the caller's input is never closed.
   
   The callers in `BaseSchemaResourceManager` hand it live downloads: 
`url.openStream()` (`copyOrIdentifyDuplicateURL`), `conn.getInputStream()` 
(`redownloadEntry`) and the index document stream (`writeCache`). A write 
failure there leaks the socket, and 
`redownloadEntry`/`copyOrIdentifyDuplicateURL` both just `warning(...)` and 
carry on to the next resource, so this accumulates across a `-refresh` run.
   
   The method now owns the input in a try-with-resources, so it is released 
either way; the second close on the normal path is a no-op.
   
   Added `SchemaResourceManagerWriteTest`, which puts a plain file where the 
target's parent directory should be. It fails on trunk and passes with this 
change.
   
   🤖 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