From 3bfb3d37626990819ba66fc5cb26a702235b5de5 Mon Sep 17 00:00:00 2001 From: Jason Harrop Date: Mon, 5 Oct 2026 09:13:06 +1100 Subject: [PATCH] FOP-3349: A line that overflows on the float re-layout pass is reported, not a NullPointerException LineLayoutManager.LineBreakingAlgorithm.updateData2 reported an overflowing line through curChildLM.getFObj(). On the float re-layout pass (PageBreaker.handleFloatLayout) curChildLM is null, so a line overflowing beside a float wider than the measure threw a NullPointerException and the document failed. It is now reported against the line manager's own FO, as it already was when the child had no FO. The code only reports; layout does not change. Test: float_overflow_relayout.xml, which threw the NullPointerException before. Co-Authored-By: Claude Opus 5.5 --- .../layoutmgr/inline/LineLayoutManager.java | 3 +- .../float_overflow_relayout.xml | 46 +++++++++++++++++++ 2 files changed, 48 insertions(+), 1 deletion(-) create mode 100644 fop/test/layoutengine/standard-testcases/float_overflow_relayout.xml diff --git a/fop-core/src/main/java/org/apache/fop/layoutmgr/inline/LineLayoutManager.java b/fop-core/src/main/java/org/apache/fop/layoutmgr/inline/LineLayoutManager.java index 4477801f2cd..db590bfaa76 100644 --- a/fop-core/src/main/java/org/apache/fop/layoutmgr/inline/LineLayoutManager.java +++ b/fop-core/src/main/java/org/apache/fop/layoutmgr/inline/LineLayoutManager.java @@ -400,7 +400,8 @@ public void updateData2(KnuthNode bestActiveNode, InlineLevelEventProducer eventProducer = InlineLevelEventProducer.Provider.get( getFObj().getUserAgent().getEventBroadcaster()); - if (curChildLM.getFObj() == null) { + // curChildLM is null on the float re-layout pass (PageBreaker.handleFloatLayout) + if (curChildLM == null || curChildLM.getFObj() == null) { eventProducer.lineOverflows(this, getFObj().getName(), bestActiveNode.line, -lack, getFObj().getLocator()); } else { diff --git a/fop/test/layoutengine/standard-testcases/float_overflow_relayout.xml b/fop/test/layoutengine/standard-testcases/float_overflow_relayout.xml new file mode 100644 index 00000000000..b013744e4ce --- /dev/null +++ b/fop/test/layoutengine/standard-testcases/float_overflow_relayout.xml @@ -0,0 +1,46 @@ + + + + + +

+ This test checks a line that overflows beside a float wider than the measure. On the float + re-layout pass the line breaking algorithm reported the overflow through curChildLM, which + is null there, and FOP threw a NullPointerException instead of reporting it. +

+
+ + + + + + + + + + + block childOverflowing ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ + + + + + + + + +