Bug 60584 - NPE with missing Drawing in XSSFReader
Summary: NPE with missing Drawing in XSSFReader
Alias: None
Product: POI
Classification: Unclassified
Component: XSSF (show other bugs)
Version: 3.16-dev
Hardware: PC All
: P2 normal (vote)
Target Milestone: ---
Assignee: POI Developers List
Depends on:
Reported: 2017-01-13 13:40 UTC by Tim Allison
Modified: 2017-01-13 20:55 UTC (History)
0 users


Note You need to log in before you can comment on or make changes to this bug.
Description Tim Allison 2017-01-13 13:40:38 UTC
On TIKA-2134, Seva Alekseyev submitted an example xlsx file that triggers an NPE when a shape is missing from the file.

Excel appears to silently ignore shape relationships that don't include the file.  

Caused by: java.lang.NullPointerException
	at org.apache.poi.xssf.usermodel.XSSFDrawing.<init>(XSSFDrawing.java:89)
	at org.apache.poi.xssf.usermodel.XSSFDrawing.<init>(XSSFDrawing.java:97)
	at org.apache.poi.xssf.eventusermodel.XSSFReader$SheetIterator.getShapes(XSSFReader.java:322)
	at org.apache.tika.parser.microsoft.ooxml.XSSFExcelExtractorDecorator.buildXHTML(XSSFExcelExtractorDecorator.java:162)
Comment 1 Tim Allison 2017-01-13 13:41:23 UTC
Any objections if we add a null check in getShapes()

                  PackagePart drawingsPart = sheetPkg.getPackage().getPart(drawingsName);
                  if (drawingsPart == null) {
                      //parts can go missing; Excel ignores them silently -- TIKA-2134/POI 60584
Comment 2 Javen O'Neal 2017-01-13 17:35:22 UTC
Looks fine to me. Is this a rare cases that would warrant a log.info or log.warn level entry?
Comment 3 Tim Allison 2017-01-13 20:55:36 UTC
Thank you, Javen.  Added logging: warn.