Bug 53107 - NullPointer in AbstractWordUtils while transforming doc in html
Summary: NullPointer in AbstractWordUtils while transforming doc in html
Alias: None
Product: POI
Classification: Unclassified
Component: HWPF (show other bugs)
Version: 3.8-FINAL
Hardware: PC All
: P2 major (vote)
Target Milestone: ---
Assignee: POI Developers List
Depends on:
Reported: 2012-04-19 12:58 UTC by Benoit MAGGI
Modified: 2016-03-12 15:11 UTC (History)
0 users


Note You need to log in before you can comment on or make changes to this bug.
Description Benoit MAGGI 2012-04-19 12:58:54 UTC

I get a NullPointer while using poi in transforming doc in html.

The method getLevel (in ListTables) return a null while there is no null test in  AbstractWordUtils (there are other place with no test)  

My temporary patch is to return an empty ListLevel (return new ListLevel();) 
at the end of getLevel! The transformation works fine.

I don't know which one is the best practice :
  - return an empty object ?
  - test null after each call of getLevel(...) ?

Here some codes :

It comes from :
org.apache.poi.hwpf.converter.AbstractWordUtils L232 :

        final ListLevel listLevel = listTables.getLevel( listId,
                paragraph.getIlvl() );

        if ( listLevel.getNumberText() == null )
            return EMPTY;

org.apache.poi.hwpf.model.ListTables L224 :

  public ListLevel getLevel(int listID, int level)
    ListData lst = _listMap.get(Integer.valueOf(listID));
    if(level < lst.numLevels()) {
    	ListLevel lvl = lst.getLevels()[level];
    	return lvl;
	log.log(POILogger.WARN, "Requested level " + level + " which was greater than the maximum defined (" + lst.numLevels() + ")");
	return null;

Comment 1 Sergey Vladimirov 2012-11-05 12:11:51 UTC

Could you please provide an example file, so we can check if error is still present?

Comment 2 Dominik Stadler 2016-03-12 15:11:28 UTC
Long time without a reproducing file, therefore I am closing this for now as we cannot safely fix this without something to reproduce the problem. Please reopen this bug if this is still a problem for you and you can provide a way to reproduce this problem.