Bug 52425 - [PATCH] Error adding Comments into cloned Sheets
Summary: [PATCH] Error adding Comments into cloned Sheets
Alias: None
Product: POI
Classification: Unclassified
Component: XSSF (show other bugs)
Version: 3.14-FINAL
Hardware: PC Windows XP
: P2 normal with 16 votes (vote)
Target Milestone: ---
Assignee: POI Developers List
Keywords: PatchAvailable
Depends on:
Blocks: 55814
  Show dependency tree
Reported: 2012-01-05 09:01 UTC by Stefan Helfert
Modified: 2017-11-04 13:46 UTC (History)
1 user (show)

Testprogram (1.86 KB, text/java)
2012-01-05 09:01 UTC, Stefan Helfert
Testfile (9.22 KB, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet)
2016-08-15 07:28 UTC, Daniel
Patch (7.81 KB, application/tar+gzip)
2016-08-17 11:32 UTC, Daniel

Note You need to log in before you can comment on or make changes to this bug.
Description Stefan Helfert 2012-01-05 09:01:15 UTC
Created attachment 28121 [details]


im facing a problem to add comments in a cloned sheet.

Adding comments to a new created sheet is no problem, but if I want to add comments to a cloned sheet a get the following NullPointerException.

Exception in thread "main" java.lang.NullPointerException
	at org.apache.poi.xssf.usermodel.XSSFDrawing.createCellComment(XSSFDrawing.java:294)
	at org.apache.poi.xssf.usermodel.XSSFDrawing.createCellComment(XSSFDrawing.java:50)
	at src.CloneBug.addComments(CloneBug.java:50)
	at src.CloneBug.main(CloneBug.java:32)

The command:
XSSFVMLDrawing vml = sheet.getVMLDrawing(true);
in line 293 is returning a null-Object.

Furthermore this Exception is occuring only after the second comment. The first comment is not running into this exception. But after opening the document after adding the first comment, the comment is not there. Cell-Value is set but not comment is present.

File to reproduce the exception is attached.
Comment 1 Dominik Stadler 2013-08-25 18:23:49 UTC
Please attach the xlsx-file mentioned in the Bug.
Comment 2 Thibaud Raison 2013-08-29 17:01:41 UTC
Same error in the same condition.
The first comment creates the VMLDrawing.
The second failed to load the right VMLDrawing.

Looking at the code, the drawing is null because the search did not ends, because of the (second) break in line 420. The search ends as soon as the first VMLDrawing is not the right one.

for(POIXMLDocumentPart p : getRelations()){
    if(p instanceof XSSFVMLDrawing) {
        XSSFVMLDrawing dr = (XSSFVMLDrawing)p;
        String drId = dr.getPackageRelationship().getId();
            drawing = dr;
        break; // line 420
if(drawing == null){
    logger.log(POILogger.ERROR, "Can't find VML drawing with id=" + ctDrawing.getId() + " in the list of the sheet's relationships");
Comment 3 Dominik Stadler 2013-08-29 18:19:15 UTC
Can you share your sample document so we can put a reproducer test in place together with a fix?
Comment 4 Dominik Stadler 2015-03-18 19:18:37 UTC
No response for a long time on this one and I could not reproduce this with another sample file. Therefore I am resolfing this for now, please reopen this bug with the required information if you are still affected by it with recent releases of POI, e.g. 3.12-beta1.
Comment 5 Daniel 2016-08-15 07:28:24 UTC
Created attachment 34151 [details]

Testfile which can be used with the previous posted Testprogram.
Comment 6 Daniel 2016-08-15 07:32:22 UTC
Issue still exists, tested on version 3.14 --> reopening bug
Comment 7 Daniel 2016-08-17 11:32:12 UTC
Created attachment 34158 [details]

Patch with testcase
Comment 8 Javen O'Neal 2016-09-11 04:06:21 UTC
Thanks for the patch! Applied in r1760221. Will likely be included in POI 3.15 final.