diff --git a/src/documentation/content/xdocs/status.xml b/src/documentation/content/xdocs/status.xml index cea8287434..f8ee55fdde 100644 --- a/src/documentation/content/xdocs/status.xml +++ b/src/documentation/content/xdocs/status.xml @@ -34,6 +34,7 @@ + 48571 - properly close all IO streams created in OPCPackage 48572 - always copy all declared inner classes and interfaces when generating poi-ooxml-schemas Low Level record support for the ExtRst (phonetic text) part of Unicode Strings. No usermodel access to it as yet though. record.UnicodeString has moved to record.common.UnicodeString, to live with the other record-part classes, as it isn't a full record. diff --git a/src/ooxml/java/org/apache/poi/openxml4j/opc/OPCPackage.java b/src/ooxml/java/org/apache/poi/openxml4j/opc/OPCPackage.java index e67055838d..fe2c3e2799 100644 --- a/src/ooxml/java/org/apache/poi/openxml4j/opc/OPCPackage.java +++ b/src/ooxml/java/org/apache/poi/openxml4j/opc/OPCPackage.java @@ -367,6 +367,7 @@ public abstract class OPCPackage implements RelationshipSource { } } else if (this.output != null) { save(this.output); + output.close(); } } finally { l.writeLock().unlock(); @@ -433,8 +434,10 @@ public abstract class OPCPackage implements RelationshipSource { PackageRelationshipTypes.THUMBNAIL); // Copy file data to the newly created part - StreamHelper.copyStream(new FileInputStream(path), thumbnailPart + FileInputStream is = new FileInputStream(path); + StreamHelper.copyStream(is, thumbnailPart .getOutputStream()); + is.close(); } /** @@ -1302,6 +1305,7 @@ public abstract class OPCPackage implements RelationshipSource { throw new IOException(e.getLocalizedMessage()); } this.save(fos); + fos.close(); } /**