[Bug 65099] New: NPE in XWPFStyle.getUsedStyleList(XWPFStyle style, List<XWPFStyle> usedStyleList)

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

[Bug 65099] New: NPE in XWPFStyle.getUsedStyleList(XWPFStyle style, List<XWPFStyle> usedStyleList)

Bugzilla from bugzilla@apache.org
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: [hidden email]
          Reporter: [hidden email]
  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: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

[Bug 65099] NPE in XWPFStyle.getUsedStyleList(XWPFStyle style, List<XWPFStyle> usedStyleList)

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

--- Comment #1 from Dominik Stadler <[hidden email]> ---
This is handled in https://github.com/apache/poi/pull/216 as well.

--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

[Bug 65099] NPE in XWPFStyle.getUsedStyleList(XWPFStyle style, List<XWPFStyle> usedStyleList)

Bugzilla from bugzilla@apache.org
In reply to this post by Bugzilla from bugzilla@apache.org
https://bz.apache.org/bugzilla/show_bug.cgi?id=65099

Dominik Stadler <[hidden email]> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |NEEDINFO

--- Comment #2 from Dominik Stadler <[hidden email]> ---
The patch looks valid, but can you provide a bit more sample-code to reproduce
this so we can add a unit-test which verifies this in the future?

I tried with the following, but this works with the latest version of Apache
POI:

    @Test
    public void test65099() throws IOException {
        try (XWPFDocument doc =
XWPFTestDataSamples.openSampleDocument("65099.docx")) {
            XWPFStyles styles = doc.getStyles();
            assertNotNull(styles);

            XWPFStyle normal = styles.getStyle("Normal");
            assertNotNull(normal);

            XWPFStyle style1 = styles.getStyle("EdfTitre3Car");
            assertNotNull(style1);

            List<XWPFStyle> list = styles.getUsedStyleList(normal);
            assertNotNull(list);
            assertEquals(1, list.size());

            list = styles.getUsedStyleList(style1);
            assertNotNull(list);
            assertEquals(7, list.size());
        }
    }

--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

[Bug 65099] NPE in XWPFStyle.getUsedStyleList(XWPFStyle style, List<XWPFStyle> usedStyleList)

Bugzilla from bugzilla@apache.org
In reply to this post by Bugzilla from bugzilla@apache.org
https://bz.apache.org/bugzilla/show_bug.cgi?id=65099

--- Comment #3 from Yvan Lussaud <[hidden email]> ---
Yes I forgot the style initialization:

XWPFStyle style = document.getStyles().getStyle("TableauGrille41");
inputDoc.getStyles().getUsedStyleList(style);

This trigger the NPE with the linked document.

--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

[Bug 65099] NPE in XWPFStyle.getUsedStyleList(XWPFStyle style, List<XWPFStyle> usedStyleList)

Bugzilla from bugzilla@apache.org
In reply to this post by Bugzilla from bugzilla@apache.org
https://bz.apache.org/bugzilla/show_bug.cgi?id=65099

--- Comment #4 from Dominik Stadler <[hidden email]> ---
This is fixed via r1886063 now, should be included in the upcoming Apache POI
5.0.1.

--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]