You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tika.apache.org by ta...@apache.org on 2020/11/19 12:59:02 UTC

[tika] branch main updated: Replace two redundant methods in OPCPackageDetector (#381)

This is an automated email from the ASF dual-hosted git repository.

tallison pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tika.git


The following commit(s) were added to refs/heads/main by this push:
     new 673e665  Replace two redundant methods in OPCPackageDetector (#381)
673e665 is described below

commit 673e665312c79534b32b05122e31a61dd2c5e7d4
Author: Lee <55...@users.noreply.github.com>
AuthorDate: Thu Nov 19 20:58:53 2020 +0800

    Replace two redundant methods in OPCPackageDetector (#381)
    
    Remove two private methods : `closeQuietly(ZipFile)`, `closeQuietly(ZipEntrySource)`.
    Replace call with method `closeQuietly(Closeable)` from commons-compress.
---
 .../detect/microsoft/ooxml/OPCPackageDetector.java | 24 ++--------------------
 1 file changed, 2 insertions(+), 22 deletions(-)

diff --git a/tika-parser-modules/tika-parser-microsoft-module/src/main/java/org/apache/tika/detect/microsoft/ooxml/OPCPackageDetector.java b/tika-parser-modules/tika-parser-microsoft-module/src/main/java/org/apache/tika/detect/microsoft/ooxml/OPCPackageDetector.java
index bf00156..03dbda5 100644
--- a/tika-parser-modules/tika-parser-microsoft-module/src/main/java/org/apache/tika/detect/microsoft/ooxml/OPCPackageDetector.java
+++ b/tika-parser-modules/tika-parser-microsoft-module/src/main/java/org/apache/tika/detect/microsoft/ooxml/OPCPackageDetector.java
@@ -52,6 +52,8 @@ import java.util.Set;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.regex.Pattern;
 
+import static org.apache.commons.compress.utils.IOUtils.closeQuietly;
+
 public class OPCPackageDetector implements ZipContainerDetector {
 
 
@@ -245,28 +247,6 @@ public class OPCPackageDetector implements ZipContainerDetector {
         return MediaType.parse(docType);
     }
 
-    private static void closeQuietly(ZipFile zipFile) {
-        if (zipFile == null) {
-            return;
-        }
-        try {
-            zipFile.close();
-        } catch (IOException e) {
-
-        }
-    }
-
-    private static void closeQuietly(ZipEntrySource zipEntrySource) {
-        if (zipEntrySource == null) {
-            return;
-        }
-        try {
-            zipEntrySource.close();
-        } catch (IOException e) {
-            //swallow
-        }
-    }
-
     @Override
     public MediaType streamingDetectUpdate(ZipArchiveEntry zae, InputStream zis, StreamingDetectContext detectContext) {
         String name = zae.getName();