lweitzendorf opened a new pull request, #3239: URL: https://github.com/apache/jackrabbit-oak/pull/3239
Jira: https://issues.apache.org/jira/browse/OAK-12486 `org.apache.jackrabbit.oak.commons.Buffer` was introduced to avoid `NoSuchMethodError` when Java 9+ compiled code ran on Java 8. Oak now requires Java 17, so that reason no longer applies, while the wrapper's restricted API is tedious to keep up to date and prevents callers from using more concise/efficient `ByteBuffer` methods. ### Changes - Deprecate `Buffer` (`oak-commons` package version 2.4.0 → 2.5.0) and add `Buffer.wrap(ByteBuffer)` / `toByteBuffer()` zero-copy bridges. - Use `ByteBuffer` internally in `oak-segment-tar`, `oak-segment-remote`, `oak-segment-aws`, `oak-segment-azure` and `oak-upgrade`, using e.g. absolute bulk `get`, `slice(int, int)`, absolute `getInt`/`getLong`, `CRC32.update(ByteBuffer)` instead of position/duplicate chains; fewer copies in `PersistentRedisCache`, `S3Directory` and Azure `SegmentCopy`. - Reuse the existing `IOUtils.readFully(FileChannel, int, ByteBuffer)` in place of `Buffer.readFully`. - **No breaking changes:** the segment persistence SPI (`SegmentArchiveReader`/`Writer`, `PersistentCache`) and the exported `oak-segment-remote` hooks keep `Buffer`; conversion happens at the boundary (null-safe via the internal `segment.util.Buffers`, since these SPI results are `@Nullable`). - Update AGENTS.md: the minimum Java version is 17 (separate commit). ### Behaviour notes for reviewers - Several reads now use absolute positions and no longer move the caller's buffer position (e.g. `BinaryReferencesIndexLoader*`, `SegmentStream.read`). - `SegmentStream.getString()` is now idempotent and returns the full value even after `read()` (previously returned only the unread remainder). Covered by the new `SegmentStreamTest`. ### Testing - oak-segment-tar: 847 tests, all pass except `RecordCacheTest.weightConvergesAfterAsyncEviction`, which failed once on an async-eviction timeout; it is untouched by this change and passed 3/3 reruns. - oak-segment-remote 65 (2 skipped), oak-segment-aws 72 (3 skipped), oak-segment-azure 278 (11 skipped), oak-upgrade 184 (21 skipped): all pass. OSGi baseline passes. ### Follow-up Moving the SPI and the `oak-segment-remote` hooks to `ByteBuffer` (major version bump) would allow removing `Buffer` and `Buffers` entirely. -- 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]
