fix(engine): empty pageBackgrounds clears; row weights/children mismatch is IAE (PR-7.3)#81
Merged
Conversation
…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).
b4193cc to
481c572
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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:
pageBackgrounds(emptyList())now actually clears an earlierpageBackground(color)on the same builder. The Javadoc inGraphCompose.java
promised that behaviour, but an
if (!pageBackgrounds.isEmpty())guard around the assignmentsilently treated the empty list as "leave the earlier value
unchanged". The guard is removed.
weights/childrensize mismatch is now anIllegalArgumentExceptionwith a descriptive message, both inLayoutCompiler#distributeRowSlotWidths
and in
NodeDefinitionSupport#measureRow.
The previous code walked off the end of the
weightslist with araw
IndexOutOfBoundsExceptionwhenever a caller bypassedRowBuilderand built aRowNodedirectly.RowNode's canonicalconstructor 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-fixand PR-7.2 #79chore/byte-buddy-test-scope). Tracked in the privaterelease-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 explicitlycleared it, or built a
RowNodeprogrammatically. The audit caughtthem 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#rowBuilderWeightsMismatchAtBuildFailsWithDescriptiveMessage—new RowBuilder().weights(1, 2).addParagraph(...) x 3 .build()throwsIllegalStateExceptionmentioning bothweightsandchildren.RowBuilderTest#rowNodeConstructorRejectsWeightsThatDoNotMatchChildren— directnew RowNode(..., weights=[1,2,3], children=[a,b], ...)throwsIllegalArgumentExceptionwith 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)