Bug 44916 - HSSFSheet instance, getDrawingPatriarch NullPointerException
Summary: HSSFSheet instance, getDrawingPatriarch NullPointerException
Alias: None
Product: POI
Classification: Unclassified
Component: HSSF (show other bugs)
Version: 3.0-FINAL
Hardware: PC Windows Vista
: P2 normal with 1 vote (vote)
Target Milestone: ---
Assignee: POI Developers List
Depends on:
Reported: 2008-05-01 07:18 UTC by Lon Binder
Modified: 2010-05-27 12:28 UTC (History)
0 users

patch to fix bug 44916 (3.54 KB, patch)
2010-01-28 05:02 UTC, pierre tholence
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
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.