Conversation
…Stream Co-authored-by: Cursor <cursoragent@cursor.com>
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Unresolved thread-safety and invalid-position handling issues remain, with gaps in concurrency and failure-path test coverage.
Get a fresh assessment by requesting another Copilot review.
Pull request overview
This pull request improves thread safety for positioned reads in OzoneCryptoInputStream and adds related test coverage.
Changes:
- Synchronizes sequential and positioned read operations.
- Adds positioned
ByteBufferand byte-array read handling. - Adds boundary, EOF, failure-recovery, and concurrency tests.
File summaries
| File | Summary |
|---|---|
hadoop-ozone/client/src/test/java/org/apache/hadoop/ozone/client/io/TestOzoneCryptoInputStream.java |
Adds functional and concurrency coverage. |
hadoop-ozone/client/src/main/java/org/apache/hadoop/ozone/client/io/OzoneCryptoInputStream.java |
Adds synchronized positioned-read implementations. |
Review details
Suppressed comments (1)
hadoop-ozone/client/src/test/java/org/apache/hadoop/ozone/client/io/TestOzoneCryptoInputStream.java:255
- The read-only check in
read(long, ByteBuffer)runs beforeseekand beforeadjustReadPositioncan set either adjustment field, so this non-boundary position never exercises the cleanup path described by the test. It only verifies early rejection and cannot catch stale adjustment state after a later read failure; add a failure injected after adjustment or make that claim a separate test.
// Seek to a non-boundary offset so adjustReadPosition sets readPositionAdjustedBy.
s.seek(100);
assertThrows(ReadOnlyBufferException.class, () -> s.read(100, readOnly));
- Files reviewed: 2/2 changed files
- Comments generated: 3
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| */ | ||
| @Override | ||
| public int read(byte[] b, int off, int len) throws IOException { | ||
| public synchronized int read(byte[] b, int off, int len) throws IOException { |
Comment on lines
+198
to
+200
| if (position < 0 || position >= getLength()) { | ||
| return EOF; | ||
| } |
Comment on lines
+320
to
+323
| // Interleave skip(0) — a no-op skip that still acquires the monitor — | ||
| // to exercise the happens-before between skip and positioned reads. | ||
| s.skip(0); | ||
| s.readFully(offset, buf); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changes were proposed in this pull request?
Make sure all positioned reads in OzoneCryptoInputStream are thread-safe
Please describe your PR in detail:
Split from HDDS-15424 #11102 , this change only make sure OzoneCryptoInputStream has complied with thread-safe positional reads
What is the link to the Apache JIRA
https://issues.apache.org/jira/browse/HDDS-16426
How was this patch tested?
unit tests and compared with HDDS-16400 #11245