Skip to content

fix(engine): empty pageBackgrounds clears; row weights/children mismatch is IAE (PR-7.3)#81

Merged
DemchaAV merged 1 commit into
developfrom
fix/pagebackgrounds-empty-and-row-weights
May 30, 2026
Merged

fix(engine): empty pageBackgrounds clears; row weights/children mismatch is IAE (PR-7.3)#81
DemchaAV merged 1 commit into
developfrom
fix/pagebackgrounds-empty-and-row-weights

Conversation

@DemchaAV
Copy link
Copy Markdown
Owner

Summary

Two v1.6.5 stabilization fixes flagged by the extended audit
(2026-05-30), shipped together because both are P1 engine guards
sitting on the same DocumentSession lifecycle:

  1. pageBackgrounds(emptyList()) now actually clears an earlier
    pageBackground(color) on the same builder. The Javadoc in
    GraphCompose.java
    promised that behaviour, but an
    if (!pageBackgrounds.isEmpty()) guard around the assignment
    silently treated the empty list as "leave the earlier value
    unchanged". The guard is removed.
  2. Row weights / children size mismatch is now an
    IllegalArgumentException
    with a descriptive message, both in
    LayoutCompiler#distributeRowSlotWidths
    and in
    NodeDefinitionSupport#measureRow.
    The previous code walked off the end of the weights list with a
    raw IndexOutOfBoundsException whenever a caller bypassed
    RowBuilder and built a RowNode directly. RowNode's canonical
    constructor already validated this at construction time; the new
    engine guards are defence-in-depth for any path that bypasses the
    constructor (reflection-based deserialization, etc.).

This is the last of three short branches unblocking the v1.6.5 cut
(alongside PR-7.1 #80
ci/exec-plugin-drift-fix and PR-7.2 #79
chore/byte-buddy-test-scope). Tracked in the private
release-readiness taskboard.

Why

Both behaviours had Javadoc / engine-contract drift that would have
turned into user-visible bugs the moment a v1.6.5 user composed a
template with a default pageBackground(color) and then explicitly
cleared it, or built a RowNode programmatically. The audit caught
them before they shipped; cheap to fix now, expensive to fix after
the public release.

Test plan

New regression tests:

  • PageBackgroundTest#pageBackgroundsWithEmptyListClearsEarlierPageBackgroundColor
    — builder pipeline pageBackground(LIGHT_GRAY).pageBackgrounds(List.of()) must emit zero page-background fragments.
  • RowBuilderTest#rowBuilderWeightsMismatchAtBuildFailsWithDescriptiveMessagenew RowBuilder().weights(1, 2).addParagraph(...) x 3 .build() throws IllegalStateException mentioning both weights and children.
  • RowBuilderTest#rowNodeConstructorRejectsWeightsThatDoNotMatchChildren — direct new RowNode(..., weights=[1,2,3], children=[a,b], ...) throws IllegalArgumentException with both sizes named.

Suite:

  • ./mvnw test -pl .1019 tests, 0 failures, 0 errors (~45 s, locally on JDK 17).

  • New tests pass locally

  • Full canonical suite green locally

  • CI green on PR (Guards / JDK 17/21/25 / Examples Smoke)

…tch is IAE

Two v1.6.5 stabilization fixes flagged by the extended audit
(2026-05-30):

1. GraphCompose.document().pageBackgrounds(emptyList()) now actually
   clears any earlier pageBackground(color), matching the builder's
   Javadoc. The previous `if (!pageBackgrounds.isEmpty())` guard meant
   an explicit empty list was silently treated as "leave unchanged".

2. LayoutCompiler#distributeRowSlotWidths and
   NodeDefinitionSupport#measureRow now reject a weights list whose
   size does not match the row's children with a descriptive
   IllegalArgumentException, instead of walking off the end of the
   list with an IndexOutOfBoundsException. RowNode's canonical
   constructor already validated this at construction; the new engine
   guards are defence-in-depth for any path that bypasses the
   constructor (reflection-based deserialization, etc.).

Test coverage:
- PageBackgroundTest#pageBackgroundsWithEmptyListClearsEarlierPageBackgroundColor
- RowBuilderTest#rowBuilderWeightsMismatchAtBuildFailsWithDescriptiveMessage
- RowBuilderTest#rowNodeConstructorRejectsWeightsThatDoNotMatchChildren

./mvnw test -pl . -> 1019 tests, 0 failures, 0 errors (~45s).

Part of v1.6.5 publish hygiene (PR-7.3).
@DemchaAV DemchaAV force-pushed the fix/pagebackgrounds-empty-and-row-weights branch from b4193cc to 481c572 Compare May 30, 2026 09:48
@DemchaAV DemchaAV merged commit f868499 into develop May 30, 2026
8 checks passed
@DemchaAV DemchaAV deleted the fix/pagebackgrounds-empty-and-row-weights branch May 30, 2026 09:51
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