The GitHub Actions job "Java CI with Gradle" on poi.git/trunk has succeeded.
Run started by GitHub user pjfanning (triggered by pjfanning).

Head commit for run:
b025d5b633b08cde9fa8d546aded68463b5decb5 / PJ Fanning 
<[email protected]>
Cache the TransformerFactory and skip unwanted comment lookups (#1241)

* Cache the TransformerFactory and skip unwanted comment lookups

XMLHelper.newTransformer() called TransformerFactory.newInstance() on
every invocation, repeating the JAXP provider lookup and the security
configuration each time. It is called once per part with relationships
on every OPC save (ZipPartMarshaller.marshallRelationshipPart) plus
once for the content types part. Measured locally, newInstance() plus
the configuration is ~87% of the call cost, so the factory is now built
once and reused. TransformerFactory is not guaranteed thread-safe and
the implementation is pluggable, so the creation call is synchronized;
the lock is free when uncontended and only guards the cheap identity
transformer creation, not the transform itself.

The other two factories in this class are already cached the same way.

XSSFExcelExtractor called cell.getCellComment() for every cell before
checking includeCellComments, so the default extraction path paid a
comment-table lookup per cell (and a linear VML shape scan for every
commented cell) only to discard the result.

Co-Authored-By: Claude Fable 5 <[email protected]>

* Document the thread-safety position of the cached XML factories

JAXP does not specify whether DocumentBuilderFactory or SAXParserFactory
may be used concurrently, so the previous "newDocumentBuilder is
thread-safe" comment claimed more than the spec gives. The JDK
implementations only read the factory's feature/attribute state when
creating a parser, and POI configures these factories once and never
mutates them, so sharing them is safe in practice - and guarding them
would serialize much hotter paths than the transformer one.

Co-Authored-By: Claude Fable 5 <[email protected]>

---------

Co-authored-by: Claude Fable 5 <[email protected]>

Report URL: https://github.com/apache/poi/actions/runs/33792427607

With regards,
GitHub Actions via GitBox


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

Reply via email to