Skip to content

Fail clearly when a CRAM query needs to seek but cannot - #1791

Merged
tfenne merged 1 commit into
masterfrom
tf_fix_cram_426
Jul 26, 2026
Merged

Fail clearly when a CRAM query needs to seek but cannot#1791
tfenne merged 1 commit into
masterfrom
tf_fix_cram_426

Conversation

@tfenne

@tfenne tfenne commented Jul 25, 2026

Copy link
Copy Markdown
Member

Closes #426.

CRAMFileReader can be constructed from an InputStream together with an index. If that stream is not a SeekableStream, getSeekableStreamOrFailWithRTE — despite its name — returned null rather than failing, and the null surfaced later as a bare NullPointerException from whichever query call the user made.

It now throws an IllegalStateException naming the actual constraint: query and index operations need a File, a Path, or a SeekableStream.

Sequential iteration does not seek and is unaffected, which one of the tests pins down. I also confirmed the test genuinely covers the bug by reverting the fix and watching it fail with the original NullPointerException.

CRAMFileReader can be constructed from an InputStream together with an index.
If that stream is not a SeekableStream, getSeekableStreamOrFailWithRTE -- despite
its name -- returned null instead of failing, and the null surfaced later as a
bare NullPointerException from whichever query call the user made.

Throw an IllegalStateException naming the actual constraint: query and index
operations need a File, a Path, or a SeekableStream. Sequential iteration does
not seek and is unaffected, which the test pins down.
@coderabbitai

coderabbitai Bot commented Jul 25, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@tfenne, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 59 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: a529b1cf-1f81-417f-98f4-575609763f71

📥 Commits

Reviewing files that changed from the base of the PR and between 2ae4aaa and 33274b6.

📒 Files selected for processing (2)
  • src/main/java/htsjdk/samtools/CRAMFileReader.java
  • src/test/java/htsjdk/samtools/cram/CRAMFileReaderNonSeekableStreamTest.java
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch tf_fix_cram_426

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@tfenne
tfenne merged commit 2ce61f3 into master Jul 26, 2026
5 checks passed
@tfenne
tfenne deleted the tf_fix_cram_426 branch July 26, 2026 00:36
tfenne added a commit that referenced this pull request Jul 26, 2026
Three test classes added in #1789, #1791 and #1792 used snake_case method names
without the conventional test prefix, which is neither idiomatic Java nor what
this repo does: of 2417 test methods, 2020 start with "test" and only 199
contain an underscore at all.

Rename the nine offending methods in these three classes to testXxx camelCase.
Test bodies are untouched; this is naming only.
tfenne added a commit that referenced this pull request Jul 26, 2026
Three test classes added in #1789, #1791 and #1792 used snake_case method names
without the conventional test prefix, which is neither idiomatic Java nor what
this repo does: of 2417 test methods, 2020 start with "test" and only 199
contain an underscore at all.

Rename the nine offending methods in these three classes to testXxx camelCase.
Test bodies are untouched; this is naming only.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CRAMFileReader query calls throw NPE on non-seekable input streams

1 participant