Bug 56514 - NullPointerException in XSSFSimpleShape constructor
Summary: NullPointerException in XSSFSimpleShape constructor
Alias: None
Product: POI
Classification: Unclassified
Component: XSSF (show other bugs)
Version: 3.11-dev
Hardware: PC Windows Vista
: P2 normal (vote)
Target Milestone: ---
Assignee: POI Developers List
: 56218 (view as bug list)
Depends on:
Reported: 2014-05-12 13:32 UTC by Joachim Herrmann
Modified: 2015-03-23 21:27 UTC (History)
1 user (show)

test sample file (10.28 KB, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet)
2014-05-12 13:32 UTC, Joachim Herrmann
Unit test case (601 bytes, text/plain)
2014-05-12 13:33 UTC, Joachim Herrmann

Note You need to log in before you can comment on or make changes to this bug.
Description Joachim Herrmann 2014-05-12 13:32:58 UTC
Created attachment 31607 [details]
test sample file


I encountered a NullPointerException in XSSFDrawing.getShapes()

The cause is the constructor
  protected XSSFSimpleShape(XSSFDrawing drawing, CTShape ctShape) 
which runs the loop
  for(int i = 0; i < body.sizeOfPArray(); i++) 
without checking if the "body" variable is null

The attached test class "TestXSSFDrawingGetShapes.java" demonstrates the error with the attached test sample file "shapes.xlsx"

Kind Regards
Comment 1 Joachim Herrmann 2014-05-12 13:33:53 UTC
Created attachment 31608 [details]
Unit test case
Comment 2 Dominik Stadler 2014-05-16 07:12:14 UTC
Fixed in r1595127, a simple null-check in XSSFSimpleShape seems to make it work, I also checked that the resulting XLSX still looks sane in Excel.
Comment 3 Dominik Stadler 2015-03-23 21:27:04 UTC
*** Bug 56218 has been marked as a duplicate of this bug. ***