Author: fanningpj
Date: Thu Mar 20 11:54:19 2025
New Revision: 1924495
URL: http://svn.apache.org/viewvc?rev=1924495&view=rev
Log:
[bug-69618] ZipPackage save should check that intermediate steps succeed
Modified:
poi/trunk/poi-ooxml/src/main/java/org/apache/poi/openxml4j/opc/ZipPackage.java
poi/trunk/poi-ooxml/src/main/java/org/apache/poi/openxml4j/opc/internal/marshallers/ZipPartMarshaller.java
Modified:
poi/trunk/poi-ooxml/src/main/java/org/apache/poi/openxml4j/opc/ZipPackage.java
URL:
http://svn.apache.org/viewvc/poi/trunk/poi-ooxml/src/main/java/org/apache/poi/openxml4j/opc/ZipPackage.java?rev=1924495&r1=1924494&r2=1924495&view=diff
==============================================================================
---
poi/trunk/poi-ooxml/src/main/java/org/apache/poi/openxml4j/opc/ZipPackage.java
(original)
+++
poi/trunk/poi-ooxml/src/main/java/org/apache/poi/openxml4j/opc/ZipPackage.java
Thu Mar 20 11:54:19 2025
@@ -632,7 +632,7 @@ public final class ZipPackage extends OP
*
* @param outputStream
* The stream use to save this package.
- *
+ * @throws OpenXML4JRuntimeException if there is an error while saving the
package.
* @see #save(OutputStream)
*/
@Override
@@ -671,13 +671,19 @@ public final class ZipPackage extends OP
// Save content type part.
LOG.atDebug().log("Save content types part");
- this.contentTypeManager.save(zos);
+ if (!this.contentTypeManager.save(zos)) {
+ throw new OpenXML4JRuntimeException(
+ "Fail to save: content types part");
+ }
// Save package relationships part.
LOG.atDebug().log("Save package relationships");
- ZipPartMarshaller.marshallRelationshipPart(this.getRelationships(),
+ if
(!ZipPartMarshaller.marshallRelationshipPart(this.getRelationships(),
PackagingURIHelper.PACKAGE_RELATIONSHIPS_ROOT_PART_NAME,
- zos);
+ zos)) {
+ throw new OpenXML4JRuntimeException(
+ "Fail to save: package relationships part");
+ }
// Save parts.
for (PackagePart part : getParts()) {
Modified:
poi/trunk/poi-ooxml/src/main/java/org/apache/poi/openxml4j/opc/internal/marshallers/ZipPartMarshaller.java
URL:
http://svn.apache.org/viewvc/poi/trunk/poi-ooxml/src/main/java/org/apache/poi/openxml4j/opc/internal/marshallers/ZipPartMarshaller.java?rev=1924495&r1=1924494&r2=1924495&view=diff
==============================================================================
---
poi/trunk/poi-ooxml/src/main/java/org/apache/poi/openxml4j/opc/internal/marshallers/ZipPartMarshaller.java
(original)
+++
poi/trunk/poi-ooxml/src/main/java/org/apache/poi/openxml4j/opc/internal/marshallers/ZipPartMarshaller.java
Thu Mar 20 11:54:19 2025
@@ -104,7 +104,7 @@ public final class ZipPartMarshaller imp
PackagePartName relationshipPartName = PackagingURIHelper
.getRelationshipPartName(part.getPartName());
- marshallRelationshipPart(part.getRelationships(),
+ return marshallRelationshipPart(part.getRelationships(),
relationshipPartName, zos);
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]