Bug 58552 - NPE at XWPFStyles.getUsedStyleList()
Summary: NPE at XWPFStyles.getUsedStyleList()
Status: NEW
Alias: None
Product: POI
Classification: Unclassified
Component: XWPF (show other bugs)
Version: 3.15-dev
Hardware: PC All
: P2 major (vote)
Target Milestone: ---
Assignee: POI Developers List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-10-26 18:05 UTC by Stanislav Kashirin
Modified: 2016-03-16 21:29 UTC (History)
0 users



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Stanislav Kashirin 2015-10-26 18:05:33 UTC
I tried to find used styles of style, which have 'next style', but has no 'link style', using XWPFStyles.getUsedStyleList(XWPFStyle) method and got NPE at 174 line. 

https://github.com/apache/poi/blob/REL_3_11_BRANCH/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFStyles.java#L191

This part of code looks really suspicious:

		String nextStyleID = style.getNextStyleID();
		XWPFStyle nextStyle = getStyle(nextStyleID);
		if((nextStyle!=null)&&(!usedStyleList.contains(nextStyle))){
			usedStyleList.add(linkStyle);
			getUsedStyleList(linkStyle, usedStyleList);
		}	

Probably this is a bug, and author mentioned that:

usedStyleList.add(nextStyle);
getUsedStyleList(nextStyle, usedStyleList);

So, trunk version of this class contains same part of code too.
Comment 1 Stanislav Kashirin 2016-03-16 21:29:24 UTC
https://github.com/apache/poi/blob/trunk/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFStyles.java#L245

Current version has same piece of code.