Skip to content

Add getL and getstreamLength methods to GFPDInlineImage - #738

Merged
MaximPlusov merged 1 commit into
integrationfrom
l-key
Jul 28, 2026
Merged

Add getL and getstreamLength methods to GFPDInlineImage#738
MaximPlusov merged 1 commit into
integrationfrom
l-key

Conversation

@LonelyMidoriya

@LonelyMidoriya LonelyMidoriya commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

update OperatorParser and GFOp_EI for rule 6.1.9-2

Summary by CodeRabbit

  • Bug Fixes
    • Improved inline image handling by preserving and exposing image data stream length.
    • Added fallback handling when stream length cannot be determined, preventing processing failures.
    • Ensured inline image metadata is consistently available through the validation model.

@LonelyMidoriya LonelyMidoriya self-assigned this Jul 22, 2026
@coderabbitai

coderabbitai Bot commented Jul 22, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Changes

Inline image stream length

Layer / File(s) Summary
Compute and propagate inline image length
validation-model/src/main/java/org/verapdf/gf/model/factory/operators/OperatorParser.java, validation-model/src/main/java/org/verapdf/gf/model/impl/operator/inlineimage/GFOp_EI.java
Inline image stream length is computed with ASMemoryInStream, handled on IOException, and passed through GFOp_EI into PDInlineImage.
Expose inline image length properties
validation-model/src/main/java/org/verapdf/gf/model/impl/pd/images/GFPDInlineImage.java
getL() and getstreamLength() delegate to the wrapped inline image object.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Suggested reviewers: maximplusov

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes a real part of the change by adding methods to GFPDInlineImage.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch l-key

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.

update OperatorParser and GFOp_EI for rule 6.1.9-2

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 win

Verify the public constructor contract before removing the overload.

GFOp_EI is still public, but the current constructor only accepts Long dataStreamLength and assigns it to long, so passing null will throw on autounboxing. Rename the parameter to long, 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

📥 Commits

Reviewing files that changed from the base of the PR and between 811bc9a and c427ad7.

📒 Files selected for processing (3)
  • validation-model/src/main/java/org/verapdf/gf/model/factory/operators/OperatorParser.java
  • validation-model/src/main/java/org/verapdf/gf/model/impl/operator/inlineimage/GFOp_EI.java
  • validation-model/src/main/java/org/verapdf/gf/model/impl/pd/images/GFPDInlineImage.java

Comment on lines +628 to +636
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));

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🗄️ 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.

@MaximPlusov
MaximPlusov merged commit dc12304 into integration Jul 28, 2026
9 of 14 checks passed
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.

2 participants