You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tika.apache.org by ju...@apache.org on 2011/09/01 17:07:10 UTC

svn commit: r1164106 - /tika/trunk/tika-parsers/src/main/java/org/apache/tika/parser/pkg/ZipContainerDetector.java

Author: jukka
Date: Thu Sep  1 15:07:10 2011
New Revision: 1164106

URL: http://svn.apache.org/viewvc?rev=1164106&view=rev
Log:
TIKA-701: Fix problems with TemporaryFiles

Remember to close the ZipFile instance used for type detection

Modified:
    tika/trunk/tika-parsers/src/main/java/org/apache/tika/parser/pkg/ZipContainerDetector.java

Modified: tika/trunk/tika-parsers/src/main/java/org/apache/tika/parser/pkg/ZipContainerDetector.java
URL: http://svn.apache.org/viewvc/tika/trunk/tika-parsers/src/main/java/org/apache/tika/parser/pkg/ZipContainerDetector.java?rev=1164106&r1=1164105&r2=1164106&view=diff
==============================================================================
--- tika/trunk/tika-parsers/src/main/java/org/apache/tika/parser/pkg/ZipContainerDetector.java (original)
+++ tika/trunk/tika-parsers/src/main/java/org/apache/tika/parser/pkg/ZipContainerDetector.java Thu Sep  1 15:07:10 2011
@@ -68,18 +68,21 @@ public class ZipContainerDetector implem
         if (tis != null) {
             try {
                 ZipFile zip = new ZipFile(tis.getFile());
-
-                MediaType type = detectOpenDocument(zip);
-                if (type == null) {
-                    type = detectOfficeOpenXML(zip, tis);
-                }
-                if (type == null) {
-                    type = detectIWork(zip);
-                }
-                if (type != null) {
-                    return type;
-                } else if (zip.getEntry("META-INF/MANIFEST.MF") != null) {
-                    return MediaType.application("java-archive");
+                try {
+                    MediaType type = detectOpenDocument(zip);
+                    if (type == null) {
+                        type = detectOfficeOpenXML(zip, tis);
+                    }
+                    if (type == null) {
+                        type = detectIWork(zip);
+                    }
+                    if (type != null) {
+                        return type;
+                    } else if (zip.getEntry("META-INF/MANIFEST.MF") != null) {
+                        return MediaType.application("java-archive");
+                    }
+                } finally {
+                    zip.close();
                 }
             } catch (IOException ignore) {
             }