Bug 46386 - NullPointerException in InlineStackingLayoutManager
Summary: NullPointerException in InlineStackingLayoutManager
Status: NEW
Alias: None
Product: Fop - Now in Jira
Classification: Unclassified
Component: page-master/layout (show other bugs)
Version: 0.95
Hardware: PC Linux
: P3 normal
Target Milestone: ---
Assignee: fop-dev
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-12-12 06:27 UTC by Carsten Metzler
Modified: 2012-04-11 06:17 UTC (History)
2 users (show)



Attachments
fo file wher the problem happens too (gzipped) (6.04 KB, application/x-gzip)
2009-02-22 00:00 UTC, Stefan Kost
Details
Another short XSL-FO to reproduce the NPE (475 bytes, application/octet-stream)
2009-03-25 06:38 UTC, Pascal Sancho
Details

Note You need to log in before you can comment on or make changes to this bug.
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