Bug 46386

Summary: NullPointerException in InlineStackingLayoutManager
Product: Fop - Now in Jira Reporter: Carsten Metzler <carsten.metzler>
Component: page-master/layoutAssignee: fop-dev
Status: NEW ---    
Severity: normal CC: carsten.metzler, mathieu.malaterre
Priority: P3    
Version: 0.95   
Target Milestone: ---   
Hardware: PC   
OS: Linux   
Attachments: fo file wher the problem happens too (gzipped)
Another short XSL-FO to reproduce the NPE

Description Carsten Metzler 2008-12-12 06:27:51 UTC
In the org.apache.fop.layoutmgr.inline.InlineStackingLayoutManager an NullPointerException is thrown in the "applyChanges"-method, when the variables prevLM AND currLM both are null.

line 333-338: 
            currLM = (InlineLevelLayoutManager) oldElement.getLayoutManager();

            // initialize prevLM
            if (prevLM == null) {
                prevLM = currLM;
            }

The getLayoutManager-method of the ListElement-class returns null when no position is set, so currLM is null. If prevLM is null, too, prevLM is set to currLM - so both are null. In the following code the applyChanges-method is called on prevLM without null-check.

As workaround I inserted the following code after line 338:

            if(prevLM == null && currLM == null) {
            	continue;
            }
Comment 1 Andreas L. Delmelle 2008-12-12 10:10:36 UTC
Thanks for the report, and the proposed quick-fix.

I doubt that it's the cleanest way to address the issue, so we probably won't solve it that way. 
AFAIK a ListElement should always have an associated LM. IIC, there should really be no ListElements with a null LM...

Is there any chance you could attach a small FO that reproduces the issue, so we can investigate this closer?
Comment 2 Carsten Metzler 2008-12-15 03:49:45 UTC
I reduced our FO to one fo:block. The problem seems to be the combination of the fo:block with hyphenate="true" and the containing empty fo:inline with an id-attribute:

<?xml version="1.0" encoding="UTF-8"?>
<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
        <fo:layout-master-set>
                <fo:simple-page-master margin-right="30pt" margin-left="71pt" margin-bottom="23pt" margin-top="23pt" page-width="21cm" page-height="29.7cm" master-name="page">
                        <fo:region-body overflow="hidden" margin-bottom="50pt" margin-top="82pt"/>
                        <fo:region-before extent="30pt"/>
                        <fo:region-after extent="27pt"/>
                </fo:simple-page-master>
        </fo:layout-master-set>
        <fo:page-sequence country="DE" language="de" master-reference="page">
                <fo:flow flow-name="xsl-region-body">
                        <fo:block hyphenate="true">
                                <fo:inline>Test</fo:inline>
                                <fo:inline id="1" />
                        </fo:block>
                </fo:flow>
        </fo:page-sequence>
</fo:root>
Comment 3 Stefan Kost 2009-02-22 00:00:45 UTC
Created attachment 23291 [details]
fo file wher the problem happens too (gzipped)

I get this for fo files generated from docbook xslt.
Comment 4 Pascal Sancho 2009-03-25 06:38:39 UTC
Created attachment 23415 [details]
Another short XSL-FO to reproduce the NPE

The same behaviour occured both with FOP 0.95 and FOP TRUNK (rev 757712).

If I remove either hyphenate property (from fo:block) or border property (from fo:inline), the NPE doesn't occur.

Short XSL-FO attached reveals this behaviour.

Note that there is no break opportunity anywhere.
Comment 5 Vincent Hennebert 2010-02-18 12:11:57 UTC
Bug #48765 mentions a similar issue and may be related.
Comment 6 Glenn Adams 2012-04-07 01:37:25 UTC
resetting severity from major to normal pending further review
Comment 7 Glenn Adams 2012-04-07 01:44:12 UTC
resetting P2 open bugs to P3 pending further review
Comment 8 Glenn Adams 2012-04-11 06:17:45 UTC
change status from ASSIGNED to NEW for consistency