]> source.dussan.org Git - poi.git/commitdiff
Fix bug #51949 - Avoid NPE on double close of ZipFileZipEntrySource
authorNick Burch <nick@apache.org>
Wed, 5 Oct 2011 21:29:32 +0000 (21:29 +0000)
committerNick Burch <nick@apache.org>
Wed, 5 Oct 2011 21:29:32 +0000 (21:29 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1179452 13f79535-47bb-0310-9956-ffa450edef68

src/documentation/content/xdocs/status.xml
src/ooxml/java/org/apache/poi/openxml4j/util/ZipFileZipEntrySource.java

index b391783ff2cefcbe133bac42f380e0aa485b6233..45c89496038a30111590caf8676874c1be4cc908 100644 (file)
@@ -34,6 +34,7 @@
 
     <changes>
         <release version="3.8-beta5" date="2011-??-??">
+           <action dev="poi-developers" type="fix">51949 - Avoid NPE on double close of ZipFileZipEntrySource</action>
            <action dev="poi-developers" type="fix">51950 - XWPF fix for footnotes not always being present in a document</action>
            <action dev="poi-developers" type="fix">51963 - Correct AreaReference handling of references containing a sheet name which includes a comma</action>
            <action dev="poi-developers" type="fix">51955 - XSSFReader supplied StylesTables need to have the theme data available</action>
index 1a0d36695d067e23f5258d0f6dba2ad11966a7b6..5c2b7b35e4e6b57ae55007a1d698726e9dc4e8b9 100644 (file)
@@ -28,21 +28,23 @@ import java.util.zip.ZipFile;
  *  normal ZipFile implementation is.
  */
 public class ZipFileZipEntrySource implements ZipEntrySource {
-       private ZipFile zipArchive;
-       public ZipFileZipEntrySource(ZipFile zipFile) {
-               this.zipArchive = zipFile;
-       }
-       
-       public void close() throws IOException {
-               zipArchive.close();
-               zipArchive = null;
-       }
-       
-       public Enumeration<? extends ZipEntry> getEntries() {
-               return zipArchive.entries();
-       }
-       
-       public InputStream getInputStream(ZipEntry entry) throws IOException {
-               return zipArchive.getInputStream(entry);
-       }
+   private ZipFile zipArchive;
+   public ZipFileZipEntrySource(ZipFile zipFile) {
+      this.zipArchive = zipFile;
+   }
+
+   public void close() throws IOException {
+      if(zipArchive != null) {
+         zipArchive.close();
+      }
+      zipArchive = null;
+   }
+
+   public Enumeration<? extends ZipEntry> getEntries() {
+      return zipArchive.entries();
+   }
+
+   public InputStream getInputStream(ZipEntry entry) throws IOException {
+      return zipArchive.getInputStream(entry);
+   }
 }