Bug 44916

Summary: HSSFSheet instance, getDrawingPatriarch NullPointerException
Product: POI Reporter: Lon Binder <apache>
Component: HSSFAssignee: POI Developers List <dev>
Severity: normal    
Priority: P2    
Version: 3.0-FINAL   
Target Milestone: ---   
Hardware: PC   
OS: Windows Vista   
Attachments: patch to fix bug 44916

Description Lon Binder 2008-05-01 07:18:53 UTC
In POI 3.0.2-FINAL:

After creating a drawing patriarch on a sheet, retrieving the patriarch via the "getDrawingPatriarch" method may cause a NullPointerException, due to an unset, unchecked rawData value in AbstractEscherHolderRecord.

"convertRawBytesToEscherRecords()" Line 99:
  convertToEscherRecords(0, rawData.length, rawData);
                               |- Not checked for null, causes NPE

To reproduce:
1. Create drawing patriarch
  HSSFPatriarch patr = sheet.createDrawingPatriarch();

2. Use patriarch
  HSSFClientAnchor anchor = new HSSFClientAnchor(0,0, 600,245, (short)1,1, (short)1,2);
  patr.createPicture(anchor, loadImage(LOGO_PATH, HSSFWorkbook.PICTURE_TYPE_JPEG));

3. Try to re-use patriarch later
  HSSFPatriarch existingPatr = sheet.getDrawingPatriarch();

4. Kaboom.
Comment 1 Josh Micich 2008-05-01 08:44:35 UTC
Easy to reproduce. As it turns out, step 2 is not required to get the NPE

added disabled junit for this bug in svn r652561

Comment 2 pierre tholence 2010-01-28 05:02:50 UTC
Created attachment 24900 [details]
patch to fix bug 44916

fixed the bug and enable the junit test
Comment 3 Nick Burch 2010-05-27 12:28:03 UTC
Thanks. Committed with some tweaks in r948880.