Bug 60584

Summary: NPE with missing Drawing in XSSFReader
Product: POI Reporter: Tim Allison <tallison>
Component: XSSFAssignee: POI Developers List <dev>
Status: RESOLVED FIXED    
Severity: normal    
Priority: P2    
Version: 3.16-dev   
Target Milestone: ---   
Hardware: PC   
OS: All   

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
                      continue;
                  }
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.

r1778664