Add getL and getstreamLength methods to GFPDInlineImage - #738
Conversation
📝 WalkthroughWalkthroughChangesInline image stream length
Estimated code review effort: 3 (Moderate) | ~20 minutes 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 |
update OperatorParser and GFOp_EI for rule 6.1.9-2
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (1)
validation-model/src/main/java/org/verapdf/gf/model/impl/operator/inlineimage/GFOp_EI.java (1)
48-53: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winVerify the public constructor contract before removing the overload.
GFOp_EIis still public, but the current constructor only acceptsLong dataStreamLengthand assigns it tolong, so passingnullwill throw on autounboxing. Rename the parameter tolong, or keep a delegating overload if callers need the older nullable signature.🤖 Prompt for 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. In `@validation-model/src/main/java/org/verapdf/gf/model/impl/operator/inlineimage/GFOp_EI.java` around lines 48 - 53, Update the public GFOp_EI constructor contract to use primitive long dataStreamLength if null is not supported, or retain a delegating Long overload when existing callers require nullable input; ensure assignment to the field cannot trigger unintended null unboxing.
🤖 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
`@validation-model/src/main/java/org/verapdf/gf/model/factory/operators/OperatorParser.java`:
- Around line 628-636: Update the inline-image handling in OperatorParser so a
getStreamLength() IOException is not converted into the valid value 0. Propagate
the parse failure or pass an explicit unknown length that GFOp_EI and downstream
consumers handle, while preserving normal length metadata on successful reads.
In
`@validation-model/src/main/java/org/verapdf/gf/model/impl/pd/images/GFPDInlineImage.java`:
- Around line 164-171: Restore API alignment for GFPDInlineImage.getL() and
getstreamLength(): use accessor names available on the declared
org.verapdf.pd.images.PDInlineImage dependency and ensure the implemented model
interface declares matching methods. Update the related interfaces,
implementation, and dependency version together as needed; do not merely remove
`@Override` annotations, and preserve the intended inline-image length behavior.
---
Nitpick comments:
In
`@validation-model/src/main/java/org/verapdf/gf/model/impl/operator/inlineimage/GFOp_EI.java`:
- Around line 48-53: Update the public GFOp_EI constructor contract to use
primitive long dataStreamLength if null is not supported, or retain a delegating
Long overload when existing callers require nullable input; ensure assignment to
the field cannot trigger unintended null unboxing.
🪄 Autofix (Beta)
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: 6449423a-f008-4617-a4d2-58a9211450ec
📒 Files selected for processing (3)
validation-model/src/main/java/org/verapdf/gf/model/factory/operators/OperatorParser.javavalidation-model/src/main/java/org/verapdf/gf/model/impl/operator/inlineimage/GFOp_EI.javavalidation-model/src/main/java/org/verapdf/gf/model/impl/pd/images/GFPDInlineImage.java
| long streamLength = 0; | ||
| try { | ||
| streamLength = ((ASMemoryInStream) rawOperator.getImageData()).getStreamLength(); | ||
| } catch (IOException e) { | ||
| LOGGER.log(Level.SEVERE, "Error during computing inline image data stream length", e); | ||
| } | ||
| processedOperators.add(new GFOp_BI(new ArrayList<>())); | ||
| processedOperators.add(new GFOp_ID(arguments)); | ||
| processedOperators.add(new GFOp_EI(arguments, resourcesHandler, gs.getFillColorSpace())); | ||
| processedOperators.add(new GFOp_EI(arguments, resourcesHandler, gs.getFillColorSpace(), streamLength)); |
There was a problem hiding this comment.
🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win
Do not convert a length-read failure into a valid zero length.
When getStreamLength() throws, the parser still creates GFOp_EI with 0, so downstream validation receives concrete but incorrect stream-length metadata. Propagate the parse failure or preserve an explicit “unknown” state handled by consumers; do not silently use zero.
🤖 Prompt for 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.
In
`@validation-model/src/main/java/org/verapdf/gf/model/factory/operators/OperatorParser.java`
around lines 628 - 636, Update the inline-image handling in OperatorParser so a
getStreamLength() IOException is not converted into the valid value 0. Propagate
the parse failure or pass an explicit unknown length that GFOp_EI and downstream
consumers handle, while preserving normal length metadata on successful reads.
update OperatorParser and GFOp_EI for rule 6.1.9-2
Summary by CodeRabbit