https://bz.apache.org/bugzilla/show_bug.cgi?id=60288

            Bug ID: 60288
           Summary: Quadratic complexity:
                    org.apache.poi.POIXMLDocumentPart#findExistingRelation
                    (POIXMLDocumentPart part)
           Product: POI
           Version: 3.14-FINAL
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: XSSF
          Assignee: dev@poi.apache.org
          Reporter: tim.helmstedt@trademark.vision

Created attachment 34395
  --> https://bz.apache.org/bugzilla/attachment.cgi?id=34395&action=edit
Test Case

This was found through adding 2000 images to a sheet via
org.apache.poi.xssf.usermodel.XSSFWorkbook#addPicture(byte[], int).  This isn't
the only path to findExistingRelation so there's likely more ways to hit this
issue. Attached is a test case which exercises this path.

The source of the quadratic slowdown comes from the defensive copy we do in
org.apache.poi.openxml4j.opc.PackagePart#getRelationships. In
findExistingRelation we iterate over this copy, and for each element we end up
incurring another defensive copy via getRelatedPart->isRelationshipExists.

I can't see a clear reason why
org.apache.poi.openxml4j.opc.PackagePart#isRelationshipExists should create a
copy of _relationships, since we're not leaking them - just returning a
boolean. Using the field directly solves my issue and won't have any functional
impact as we're not filtering at this stage.

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

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@poi.apache.org
For additional commands, e-mail: dev-h...@poi.apache.org

Reply via email to