Bug 50574 - [PATCH] Content overflow onto second ODD page causes NullPointerException
Summary: [PATCH] Content overflow onto second ODD page causes NullPointerException
Status: NEEDINFO
Alias: None
Product: Fop - Now in Jira
Classification: Unclassified
Component: page-master/layout (show other bugs)
Version: 1.0
Hardware: All All
: P3 normal
Target Milestone: ---
Assignee: fop-dev
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-01-11 17:21 UTC by Lance Knorr
Modified: 2012-04-08 08:57 UTC (History)
1 user (show)



Attachments
XSL-FO demonstrating the odd page content overflow (8.58 KB, text/plain)
2011-01-11 17:21 UTC, Lance Knorr
Details
possible fix? (1.68 KB, patch)
2011-02-11 12:56 UTC, Andreas L. Delmelle
Details | Diff
minor change (1.60 KB, patch)
2011-02-11 13:09 UTC, Andreas L. Delmelle
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Lance Knorr 2011-01-11 17:21:50 UTC
Created attachment 26480 [details]
XSL-FO demonstrating the odd page content overflow

I have a scenario where I print mailing labels on the back of each piece of paper (even pages).  When content is too much on page 1, it should overflow onto page 3 (while mailing labels print on both page 2 and page 4).

ISSUE:
In FOP 1.0 when the content overflows page 1 to flow onto the next ODD page, a java.lang.NullPointerException is thrown.  This functionality did work in FOP 0.95.

Attached a simple XSL-FO to demonstrate this.

Thanks.

lance

Here's the exception:
java.lang.NullPointerException
	at org.apache.fop.layoutmgr.PageBreakingAlgorithm.filterActiveNodes(PageBreakingAlgorithm.java:1028)
	at org.apache.fop.layoutmgr.BreakingAlgorithm.findBreakingPoints(BreakingAlgorithm.java:527)
	at org.apache.fop.layoutmgr.BreakingAlgorithm.findBreakingPoints(BreakingAlgorithm.java:439)
	at org.apache.fop.layoutmgr.AbstractBreaker.doLayout(AbstractBreaker.java:369)
	at org.apache.fop.layoutmgr.PageBreaker.doLayout(PageBreaker.java:85)
	at org.apache.fop.layoutmgr.PageSequenceLayoutManager.activateLayout(PageSequenceLayoutManager.java:107)
	at org.apache.fop.area.AreaTreeHandler.endPageSequence(AreaTreeHandler.java:238)
	at org.apache.fop.fo.pagination.PageSequence.endOfNode(PageSequence.java:120)
	at org.apache.fop.fo.FOTreeBuilder$MainFOHandler.endElement(FOTreeBuilder.java:349)
	at org.apache.fop.fo.FOTreeBuilder.endElement(FOTreeBuilder.java:177)
	at org.apache.xalan.transformer.TransformerIdentityImpl.endElement(TransformerIdentityImpl.java:1050)
	at org.apache.xerces.parsers.AbstractSAXParser.endElement(Unknown Source)
	at org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanEndElement(Unknown Source)
	at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)
	at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
	at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
	at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
	at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
	at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
	at org.apache.xerces.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source)
	at org.apache.xalan.transformer.TransformerIdentityImpl.transform(TransformerIdentityImpl.java:452)
Comment 1 Andreas L. Delmelle 2011-02-11 11:37:24 UTC
The difference is that 0.95 did not yet support alternating page-ipd. In this scenario it did not show, since the narrower pages were empty.
 
For future reference, from a technical perspective the issue is the double restart that is triggered without content in between (actually: restart - overflow - restart). The first restart works like a charm, and kicks off from a SpaceHandlingBreakPosition as expected, but the overflow triggered by the second (empty) page, leaves us with no active node. Hence, NPE in PageBreakingAlgorithm.filterActiveNodes().

Adding the proposed fix for bug 49835, the NPE is avoided, but in that case, it becomes apparent that the SpaceHandlingBreakPosition is consumed, and the new blockList after the second restart, starts with a TableContentPosition, from which no restart is possible...

In addition to the fix for bug 49835, my first idea would be to:
- store the last restart point in AbstractBreaker as a member
- in case a restart is not triggered from a SpaceHandlingBreakPosition, and that position immediately follows the previous restart point, restart from the stored one, as that is an indication there was not enough room to fit any content on the next page(s).

Still left to verify whether this approach could resolve the issue. Stay tuned...
Comment 2 Andreas L. Delmelle 2011-02-11 12:56:22 UTC
Created attachment 26643 [details]
possible fix?


This patch to fop.layoutmgr.AbstractBreaker, in conjunction with the patch attached to Bugzilla 49835 seems to resolve the issue, and passes the unit tests. Not entirely sure if this is airtight, though, hence the question-marks in the code comment...
Comment 3 Andreas L. Delmelle 2011-02-11 13:09:12 UTC
Created attachment 26644 [details]
minor change


Actually, that second condition was not necessary I believe... might even have caused mayhem at some point (?)
Comment 4 Andreas L. Delmelle 2011-03-29 20:37:53 UTC
*** Bug 50985 has been marked as a duplicate of this bug. ***
Comment 5 Glenn Adams 2012-04-07 01:37:10 UTC
resetting severity from major to normal pending further review
Comment 6 Glenn Adams 2012-04-07 01:43:16 UTC
resetting P2 open bugs to P3 pending further review
Comment 7 Glenn Adams 2012-04-08 08:57:26 UTC
(In reply to comment #3)
> Created attachment 26644 [details]
> minor change
> 
> Actually, that second condition was not necessary I believe... might even have
> caused mayhem at some point (?)

andreas, should this patch be applied?