You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@poi.apache.org by "pjfanning (via GitHub)" <gi...@apache.org> on 2026/09/07 13:14:04 UTC

[PR] Close the digest stream when shaDigestForFile can't read a file [poi-xmlbeans]

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: dev-unsubscribe@poi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org


Re: [PR] Close the digest stream when shaDigestForFile can't read a file [poi-xmlbeans]

Posted by "pjfanning (via GitHub)" <gi...@apache.org>.
pjfanning merged PR #116:
URL: https://github.com/apache/poi-xmlbeans/pull/116


-- 
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: dev-unsubscribe@poi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org