Author: centic Date: Sat Dec 16 12:08:54 2023 New Revision: 1914706 URL: http://svn.apache.org/viewvc?rev=1914706&view=rev Log: Use revert() instead of close() when processing fails
Otherwise we might write partial changes to the underlying file which is unexpected. Modified: poi/trunk/poi-ooxml/src/main/java/org/apache/poi/ooxml/POIXMLDocumentPart.java Modified: poi/trunk/poi-ooxml/src/main/java/org/apache/poi/ooxml/POIXMLDocumentPart.java URL: http://svn.apache.org/viewvc/poi/trunk/poi-ooxml/src/main/java/org/apache/poi/ooxml/POIXMLDocumentPart.java?rev=1914706&r1=1914705&r2=1914706&view=diff ============================================================================== --- poi/trunk/poi-ooxml/src/main/java/org/apache/poi/ooxml/POIXMLDocumentPart.java (original) +++ poi/trunk/poi-ooxml/src/main/java/org/apache/poi/ooxml/POIXMLDocumentPart.java Sat Dec 16 12:08:54 2023 @@ -746,7 +746,7 @@ public class POIXMLDocumentPart { if (coreRel != null) { PackagePart pp = pkg.getPart(coreRel); if (pp == null) { - IOUtils.closeQuietly(pkg); + pkg.revert(); throw new POIXMLException("OOXML file structure broken/invalid - core document '" + coreRel.getTargetURI() + "' not found."); } return pp; @@ -754,16 +754,16 @@ public class POIXMLDocumentPart { coreRel = pkg.getRelationshipsByType(PackageRelationshipTypes.STRICT_CORE_DOCUMENT).getRelationship(0); if (coreRel != null) { - IOUtils.closeQuietly(pkg); + pkg.revert(); throw new POIXMLException("Strict OOXML isn't currently supported, please see bug #57699"); } - IOUtils.closeQuietly(pkg); + pkg.revert(); throw new POIXMLException("OOXML file structure broken/invalid - no core document found!"); } catch (POIXMLException e) { throw e; } catch (RuntimeException e) { - IOUtils.closeQuietly(pkg); + pkg.revert(); throw new POIXMLException("OOXML file structure broken/invalid", e); } } --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@poi.apache.org For additional commands, e-mail: commits-h...@poi.apache.org