Bug 65120 - [PATCH] PartAlreadyExistsException when creating cell comments
Summary: [PATCH] PartAlreadyExistsException when creating cell comments
Status: RESOLVED FIXED
Alias: None
Product: POI
Classification: Unclassified
Component: XSSF (show other bugs)
Version: 4.1.2-FINAL
Hardware: PC All
: P2 normal (vote)
Target Milestone: ---
Assignee: POI Developers List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-02-02 15:56 UTC by Raúl Wegmann
Modified: 2021-02-02 21:15 UTC (History)
1 user (show)



Attachments
patch including test (2.28 KB, patch)
2021-02-02 16:06 UTC, Raúl Wegmann
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Raúl Wegmann 2021-02-02 15:56:43 UTC
When creating a new VML drawing (as part of creating a cell comment), the number assigned to the part file only takes the current number of parts into account, but this "ID" might already been taken if one of the parts has been previously removed (i.e. by deleting a sheet).

org.apache.poi.openxml4j.exceptions.PartAlreadyExistsException: A part with the name '/xl/drawings/vmlDrawing2.vml' already exists : Packages shall not contain equivalent part names and package implementers shall neither create nor recognize packages with equivalent part names. [M1.12]
	at org.apache.poi.openxml4j.opc.OPCPackage.createPart(OPCPackage.java:840)
	at org.apache.poi.openxml4j.opc.OPCPackage.createPart(OPCPackage.java:803)
	at org.apache.poi.ooxml.POIXMLDocumentPart.createRelationship(POIXMLDocumentPart.java:586)
	at org.apache.poi.xssf.usermodel.XSSFSheet.getVMLDrawing(XSSFSheet.java:606)
	at org.apache.poi.xssf.usermodel.XSSFDrawing.createCellComment(XSSFDrawing.java:371)
	at org.apache.poi.xssf.usermodel.XSSFDrawing.createCellComment(XSSFDrawing.java:78)

When assigning the number to a new part, it must be checked for uniqueness.

The attached patch uses the same solution in the XSSFSheet.getVMLDrawing() method as already implemented in XSSFSheet.createDrawingPatriarch().
Comment 1 Raúl Wegmann 2021-02-02 16:06:11 UTC
Created attachment 37724 [details]
patch including test
Comment 2 PJ Fanning 2021-02-02 21:15:00 UTC
thanks - applied using r1886143 (the gradle change has since been reverted)