From 8540edb04a3259cd410b56e9403140d2075e55d8 Mon Sep 17 00:00:00 2001 From: Yegor Kozlov Date: Sun, 24 Jan 2010 13:26:19 +0000 Subject: [PATCH] properly close all IO streams created in OPCPackage, see Bugzilla 48571 git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@902565 13f79535-47bb-0310-9956-ffa450edef68 --- src/documentation/content/xdocs/status.xml | 1 + src/ooxml/java/org/apache/poi/openxml4j/opc/OPCPackage.java | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) 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(); } /** -- 2.39.5