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

   `BaseSchemaResourceManager.shaDigestForFile` closes the stream only after 
the read loop completes:
   
   ```java
   DigestInputStream str = digestInputStream(inputStreamForFile(filename));
   
   byte[] dummy = new byte[4096];
   int i = 1;
   while (i > 0) {
       i = str.read(dummy);
   }
   
   str.close();
   ```
   
   An `IOException` part-way through skips the close. The caller, 
`syncCacheWithLocalXsdFiles`, swallows it —
   
   ```java
   } catch (IOException e) {
       // unable to read digest... no problem, ignore then
   }
   ```
   
   — and carries on to the next file, so `sdownload -sync` over a cache 
containing unreadable `.xsd` files leaks one handle per file instead of failing.
   
   Wrapped in a try-with-resources. `getMessageDigest().digest()` moves inside 
the block; it reads the digest state and does not require the stream to be 
closed first.
   
   Added `SchemaResourceManagerStreamTest`, which serves a stream that opens 
and then fails every read. It fails on trunk and passes with this change. Full 
suite: 3171 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]

Reply via email to