Fix NPE in getCryptFilters() - #720
Conversation
|
Warning Review limit reached
Next review available in: 14 minutes You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. How can I continue?After more reviews become available, a review can be triggered using the 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 configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (3)
📝 WalkthroughWalkthroughThe reader now exposes explicit decryption. COS document initialization decrypts the reader before loading structures and propagates ChangesExplicit reader decryption
Estimated code review effort: 3 (Moderate) | ~20 minutes Sequence Diagram(s)sequenceDiagram
participant COSDocument
participant Reader
participant PDFSource
participant ResourceHandler
COSDocument->>Reader: decrypt()
Reader->>Reader: validate encrypted-document password
alt decryption fails
Reader->>PDFSource: close
Reader->>ResourceHandler: close
Reader-->>COSDocument: InvalidPasswordException
else decryption succeeds
Reader-->>COSDocument: return
COSDocument->>COSDocument: load document structures
end
Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
06664fd to
966bebb
Compare
There was a problem hiding this comment.
Actionable comments posted: 3
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/main/java/org/verapdf/pd/encryption/PDEncryption.java`:
- Around line 188-190: Update the Reader resolution in PDEncryption(COSObject)
so it does not dereference a null result from StaticResources.getReader();
preferably pass the document Reader explicitly, or validate the missing Reader
before calling getObject and handle it through the existing error path.
- Around line 186-193: Update the indirect-filter handling in PDEncryption so
reader.getObject uses filter.getObjectKey() rather than the encryption
dictionary object key and offset overload; retain the resulting object for
PDCryptFilter construction. In the IOException log, report filter.getObjectKey()
and include the caught exception details.
In `@src/main/java/org/verapdf/tools/StaticResources.java`:
- Line 61: Scope the thread-local Reader lifecycle: in
src/main/java/org/verapdf/tools/StaticResources.java#L61-L61, update
StaticResources.clear() to call reader.remove(); in
src/main/java/org/verapdf/io/Reader.java#L60-L68, make init() restore the
previous Reader if initialization fails and make close() remove the slot only
when it still references this Reader.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: 7a47b0ef-8dd5-4d7c-96c2-1d25c3dc082b
📒 Files selected for processing (3)
src/main/java/org/verapdf/io/Reader.javasrc/main/java/org/verapdf/pd/encryption/PDEncryption.javasrc/main/java/org/verapdf/tools/StaticResources.java
d46f996 to
706651e
Compare
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/main/java/org/verapdf/cos/COSDocument.java`:
- Around line 225-230: Update the object retrieval flow around the body cache
and this.reader.getObject(key) so that when this.body is null, a non-null newObj
is returned directly without calling this.body.set(...). Preserve caching
through this.body.set(...) when the body exists.
In `@src/main/java/org/verapdf/io/Reader.java`:
- Around line 145-158: Update Reader.decrypt so both getPDFSource().close() and
the document resource handler’s close() are attempted independently when
decryption is rejected. Capture any IOException from cleanup, attach it as a
suppressed exception to the intended InvalidPasswordException, and throw that
password exception after all cleanup has been attempted.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: 17b39154-dc0c-492a-8331-6f983e78509b
📒 Files selected for processing (3)
src/main/java/org/verapdf/cos/COSDocument.javasrc/main/java/org/verapdf/io/IReader.javasrc/main/java/org/verapdf/io/Reader.java
4f69dd1 to
96b3a7b
Compare
Summary by CodeRabbit