Bug 55850 - [PATCH] Null Pointer Exception when exporting xml data from an excel document
Summary: [PATCH] Null Pointer Exception when exporting xml data from an excel document
Status: RESOLVED FIXED
Alias: None
Product: POI
Classification: Unclassified
Component: XSSF (show other bugs)
Version: 3.9-FINAL
Hardware: PC All
: P2 normal (vote)
Target Milestone: ---
Assignee: POI Developers List
URL:
Keywords: PatchAvailable
Depends on:
Blocks:
 
Reported: 2013-12-06 08:16 UTC by Marc
Modified: 2013-12-08 08:38 UTC (History)
0 users



Attachments
File which causes a NPE when exporting xml data from (12.17 KB, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet)
2013-12-06 08:16 UTC, Marc
Details
Patch for NPE (10.09 KB, application/x-gzip)
2013-12-06 09:08 UTC, Marc
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Marc 2013-12-06 08:16:16 UTC
Created attachment 31097 [details]
File which causes a NPE when exporting xml data from

I created a simple excel document with a mapped xml schema. I then tried to export the xml data from the excel sheet. This failed with a null pointer exception.

Here is the stacktrace:

java.lang.NullPointerException
	at org.apache.poi.xssf.extractor.XSSFExportToXml.indexOfElementInComplexType(XSSFExportToXml.java:430)
	at org.apache.poi.xssf.extractor.XSSFExportToXml.compare(XSSFExportToXml.java:411)
	at org.apache.poi.xssf.extractor.XSSFExportToXml.compare(XSSFExportToXml.java:77)
	at java.util.TimSort.countRunAndMakeAscending(TimSort.java:324)
	at java.util.TimSort.sort(TimSort.java:203)
	at java.util.TimSort.sort(TimSort.java:173)
	at java.util.Arrays.sort(Arrays.java:659)
	at java.util.Collections.sort(Collections.java:217)
	at org.apache.poi.xssf.extractor.XSSFExportToXml.exportToXML(XSSFExportToXml.java:157)

This is the code which calls the poi api:

XSSFMap map = mapInfo.getXSSFMapById(1);
XSSFExportToXml exporter = new XSSFExportToXml(map);
ByteArrayOutputStream os = new ByteArrayOutputStream();
exporter.exportToXML(os, true); // It fails here with a NPE
String xmlData = os.toString("UTF-8");


And I also attached the excel file.
Comment 1 Marc 2013-12-06 09:08:24 UTC
Created attachment 31099 [details]
Patch for NPE

including Unit Test
Comment 2 Dominik Stadler 2013-12-08 08:38:37 UTC
Committed as r1549007, good catch, thanks a lot for the Patch!