https://issues.apache.org/bugzilla/show_bug.cgi?id=53432

          Priority: P2
            Bug ID: 53432
          Assignee: [email protected]
           Summary: workbook.getAllPictures() throws NullPointerException
                    when called after adding an image to a workbook
                    without images
          Severity: normal
    Classification: Unclassified
                OS: Windows XP
          Reporter: [email protected]
          Hardware: PC
            Status: NEW
           Version: 3.9-dev
         Component: HSSF
           Product: POI

Created attachment 28953
  --> https://issues.apache.org/bugzilla/attachment.cgi?id=28953&action=edit
Test case, slightly modified snippet for adding an image from "quick guide".

Attached is the code to reproduce exception. This is basically snippet from
"Busy developers' guide" to add a picture except that saving workbook part is
skipped, instead there is a call to wb.getAllPictures() which throws
NullPointerException:

java.lang.NullPointerException
    at
org.apache.poi.hssf.record.AbstractEscherHolderRecord.decode(AbstractEscherHolderRecord.java:261)
    at
org.apache.poi.hssf.usermodel.HSSFWorkbook.getAllPictures(HSSFWorkbook.java:1639)
    at ExcelImageNpeTest.test(ExcelImageNpeTest.java:46)

This also happens if instead of creating a workbook you open existing one
without any images inside, add image and call getAllPictures(). 
This does not happen when opening a workbook without images and calling
getAllPictures() without adding an image. 
This does not happen when opening a workbook with images inside and adding a
new one (but getAllPictures().size() will return previous number of images,
i.e. will not take into account just added one).

Also happens with PNG images.
Does not happen with XSSF workbook.

Tested with 3.8 and build 20120613 from Jenkins.

-- 
You are receiving this mail because:
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to