pjfanning opened a new pull request, #1371:
URL: https://github.com/apache/poi/pull/1371
This follows the review of POI's `InputStream`/`LittleEndianInput`
implementations that started in #1370.
### Bugs
- **`RLEDecompressingInputStream.skip`** used `n` where it should use the
remaining count, so a skip spanning several chunks skipped too far. It also
returned -1 at EOF and always returned `n`. It now returns the number of bytes
actually skipped.
- **`RecordInputStream.readPlain(buf, off, len)`** ignored `off`/`len` and
always filled the whole buffer.
- **`ReplacingInputStream`**:
- It compared signed pattern bytes with `read()`'s 0..255, so pattern
bytes ≥ 0x80 never matched.
- It returned replacement bytes ≥ 0x80 as negative values from `read()`.
- `skip` and `mark`/`reset` were delegated to the wrapped stream and
bypassed the replacement. `skip` now reads through the replacement, and `mark`
is not supported.
- **`ContinuableRecordInput.readShort`/`readDouble`** didn't roll over
CONTINUE records like the other reads of that class.
- **`LittleEndianByteArrayInputStream.setReadIndex`** rejected the end
position.
- **`ZipArchiveThresholdInputStream.skip`** returned -1 at the end of the
stream.
### Locking (SpotBugs IS2_INCONSISTENT_SYNC pattern)
- **`LittleEndianInputStream`** and **`ChunkedCipherInputStream`**: removed
`synchronized` from `mark`/`reset`, since the reads were never locked.
- **`CryptoAPIDocumentInputStream`**: `seek`/`setBlock` now lock like `read`
does.
### Performance
- **`LittleEndianInputStream`**:
- The primitive reads use a reused buffer and `readFully`. Before, a short
read from the wrapped stream could cause a false end-of-file error.
- `read()`/`skip()` now advance `getReadIndex()`.
- `skipFully` reuses its skip buffer. It still reads rather than calling
`skip()`, so that the end of the stream is detected (IO-203).
- **`ChunkedCipherInputStream`**: `read()` no longer allocates. `skipFully`
moves the position instead of decrypting every skipped chunk.
- **`LittleEndianByteArrayInputStream`**: advances `pos` directly instead of
calling the synchronized `ByteArrayInputStream.skip`/`read`.
- **`XSSFVMLDrawing`**: buffers the stream under the byte-by-byte
`ReplacingInputStream`.
- **`ZipHelper`**: uses commons-io `CloseShieldInputStream`, and the
package-private `NoCloseInputStream` is removed.
### Tests
New tests cover each bug, plus `LittleEndianInputStream` read index,
`skipFully` and short reads. These suites pass locally:
- poi: `util`, `hssf.record`, `poifs.crypt` and `hpsf` packages, plus
`TestHSSFWorkbook` — 848 tests
- poi-ooxml: VML, openxml4j, crypt and XLSB tests — 416 tests
- poi-scratchpad: HEMF, HWMF and HSLF record/picture tests — 237 tests
🤖 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]