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 2024/03/25 16:22:33 UTC

(tika) branch TIKA-4221-branch_2x created (now fce7bd6c6)

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

tallison pushed a change to branch TIKA-4221-branch_2x
in repository https://gitbox.apache.org/repos/asf/tika.git


      at fce7bd6c6 TIKA-4221 -- temporary workaround for COMPRESS-675

This branch includes the following new commits:

     new fce7bd6c6 TIKA-4221 -- temporary workaround for COMPRESS-675

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



(tika) 01/01: TIKA-4221 -- temporary workaround for COMPRESS-675

Posted by ta...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

tallison pushed a commit to branch TIKA-4221-branch_2x
in repository https://gitbox.apache.org/repos/asf/tika.git

commit fce7bd6c6a4f94f172762ce8a39681b8b7381302
Author: tallison <ta...@apache.org>
AuthorDate: Mon Mar 25 12:22:18 2024 -0400

    TIKA-4221 -- temporary workaround for COMPRESS-675
---
 .../apache/tika/parser/pkg/CompressorParser.java   | 60 ++++++++++++++++++++--
 1 file changed, 57 insertions(+), 3 deletions(-)

diff --git a/tika-parsers/tika-parsers-standard/tika-parsers-standard-modules/tika-parser-pkg-module/src/main/java/org/apache/tika/parser/pkg/CompressorParser.java b/tika-parsers/tika-parsers-standard/tika-parsers-standard-modules/tika-parser-pkg-module/src/main/java/org/apache/tika/parser/pkg/CompressorParser.java
index 791a368ce..deb49e17b 100644
--- a/tika-parsers/tika-parsers-standard/tika-parsers-standard-modules/tika-parser-pkg-module/src/main/java/org/apache/tika/parser/pkg/CompressorParser.java
+++ b/tika-parsers/tika-parsers-standard/tika-parsers-standard-modules/tika-parser-pkg-module/src/main/java/org/apache/tika/parser/pkg/CompressorParser.java
@@ -56,7 +56,7 @@ import org.apache.commons.compress.compressors.snappy.FramedSnappyCompressorInpu
 import org.apache.commons.compress.compressors.snappy.SnappyCompressorInputStream;
 import org.apache.commons.compress.compressors.xz.XZCompressorInputStream;
 import org.apache.commons.compress.compressors.z.ZCompressorInputStream;
-import org.apache.commons.io.input.CloseShieldInputStream;
+import org.apache.commons.io.input.ClosedInputStream;
 import org.xml.sax.ContentHandler;
 import org.xml.sax.SAXException;
 
@@ -170,10 +170,10 @@ public class CompressorParser extends AbstractParser {
         // any associated resources, but the underlying document stream
         // should not be closed
         if (stream.markSupported()) {
-            stream = new CloseShieldInputStream(stream);
+            stream = new TikaCloseShieldInputStream(stream);
         } else {
             // Ensure that the stream supports the mark feature
-            stream = new BufferedInputStream(new CloseShieldInputStream(stream));
+            stream = new BufferedInputStream(new TikaCloseShieldInputStream(stream));
         }
 
         CompressorInputStream cis;
@@ -267,4 +267,58 @@ public class CompressorParser extends AbstractParser {
         return this.decompressConcatenated;
     }
 
+    //TODO -- get rid of this workaround once TIKA-4221/COMPRESS-675 are fixed
+    private class TikaCloseShieldInputStream extends InputStream {
+
+        private InputStream stream;
+        public TikaCloseShieldInputStream(InputStream stream) {
+            this.stream = stream;
+        }
+
+        @Override
+        public void close() throws IOException {
+            this.stream = ClosedInputStream.INSTANCE;
+        }
+
+
+        @Override
+        public int read(byte[] b) throws IOException {
+            return stream.read(b);
+        }
+
+        @Override
+        public int read(byte[] b, int off, int len) throws IOException {
+            return stream.read(b, off, len);
+        }
+
+        @Override
+        public long skip(long n) throws IOException {
+            return stream.skip(n);
+        }
+
+        @Override
+        public int available() throws IOException {
+            return stream.available();
+        }
+
+        @Override
+        public synchronized void mark(int readlimit) {
+            stream.mark(readlimit);
+        }
+
+        @Override
+        public synchronized void reset() throws IOException {
+            stream.reset();
+        }
+
+        @Override
+        public boolean markSupported() {
+            return stream.markSupported();
+        }
+
+        @Override
+        public int read() throws IOException {
+            return stream.read();
+        }
+    }
 }