https://bz.apache.org/bugzilla/show_bug.cgi?id=65099

            Bug ID: 65099
           Summary: NPE in XWPFStyle.getUsedStyleList(XWPFStyle style,
                    List<XWPFStyle> usedStyleList)
           Product: POI
           Version: unspecified
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: XWPF
          Assignee: dev@poi.apache.org
          Reporter: yvan.luss...@obeo.fr
  Target Milestone: ---

With POI 4.1.0 the following code trigger a NPE on this document:

https://github.com/ObeoNetwork/M2Doc/blob/master/tests/org.obeonetwork.m2doc.tests/resources/userDoc/bug_387/bug_387-userContent.docx

final XWPFDocument inputDoc = ...;
List<XWPFStyle> usedStyleList = inputDoc.getStyles().getUsedStyleList(style);

The NPE:


java.lang.NullPointerException
        at
org.apache.poi.xwpf.usermodel.XWPFStyles.getUsedStyleList(XWPFStyles.java:223)
        at
org.apache.poi.xwpf.usermodel.XWPFStyles.getUsedStyleList(XWPFStyles.java:240)
        at
org.apache.poi.xwpf.usermodel.XWPFStyles.getUsedStyleList(XWPFStyles.java:213)
...

The code seems to check if an object is different from null then pass an other
object:

        if ((nextStyle != null) && (!usedStyleList.contains(nextStyle))) {
            usedStyleList.add(linkStyle);
            getUsedStyleList(linkStyle, usedStyleList);
        }

My guess is linkStyle should be replaced by nextStyle.

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@poi.apache.org
For additional commands, e-mail: dev-h...@poi.apache.org

Reply via email to