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

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

commit 18484896c5f12df1805b0b5c536ac218187f333a
Author: Tilman Hausherr <til...@apache.org>
AuthorDate: Sat Aug 10 14:32:50 2024 +0200

    TIKA-4290: replace deprecated
---
 .../src/main/java/org/apache/tika/parser/epub/EpubParser.java       | 6 +++---
 .../src/main/java/org/apache/tika/parser/wacz/WACZParser.java       | 6 +++---
 .../test/java/org/apache/tika/config/TikaDetectorConfigTest.java    | 2 +-
 .../src/test/java/org/apache/tika/mime/OneOffMimeTest.java          | 2 +-
 .../apache/tika/parser/pkg/CompositeZipContainerDetectorTest.java   | 6 +++---
 5 files changed, 11 insertions(+), 11 deletions(-)

diff --git 
a/tika-parsers/tika-parsers-standard/tika-parsers-standard-modules/tika-parser-miscoffice-module/src/main/java/org/apache/tika/parser/epub/EpubParser.java
 
b/tika-parsers/tika-parsers-standard/tika-parsers-standard-modules/tika-parser-miscoffice-module/src/main/java/org/apache/tika/parser/epub/EpubParser.java
index 43569c0ed..a67cb5c14 100644
--- 
a/tika-parsers/tika-parsers-standard/tika-parsers-standard-modules/tika-parser-miscoffice-module/src/main/java/org/apache/tika/parser/epub/EpubParser.java
+++ 
b/tika-parsers/tika-parsers-standard/tika-parsers-standard-modules/tika-parser-miscoffice-module/src/main/java/org/apache/tika/parser/epub/EpubParser.java
@@ -154,7 +154,7 @@ public class EpubParser extends AbstractParser {
             throws IOException, TikaException, SAXException {
         ZipArchiveInputStream zip = new ZipArchiveInputStream(stream, "UTF-8", 
false, true, false);
 
-        ZipArchiveEntry entry = zip.getNextZipEntry();
+        ZipArchiveEntry entry = zip.getNextEntry();
         SAXException sax = null;
         while (entry != null) {
             if (entry.getName().equals("mimetype")) {
@@ -179,7 +179,7 @@ public class EpubParser extends AbstractParser {
                     }
                 }
             }
-            entry = zip.getNextZipEntry();
+            entry = zip.getNextEntry();
         }
         if (sax != null) {
             throw sax;
@@ -216,7 +216,7 @@ public class EpubParser extends AbstractParser {
         }
         ZipFile zipFile = null;
         try {
-            zipFile = new ZipFile(tis.getPath().toFile());
+            zipFile = ZipFile.builder().setFile(tis.getPath().toFile()).get();
         } catch (IOException e) {
             ParserUtils.recordParserFailure(this, e, metadata);
             return trySalvage(tis.getPath(), bodyHandler, xhtml, metadata, 
context);
diff --git 
a/tika-parsers/tika-parsers-standard/tika-parsers-standard-modules/tika-parser-webarchive-module/src/main/java/org/apache/tika/parser/wacz/WACZParser.java
 
b/tika-parsers/tika-parsers-standard/tika-parsers-standard-modules/tika-parser-webarchive-module/src/main/java/org/apache/tika/parser/wacz/WACZParser.java
index 7697a98b8..c81f8c89e 100644
--- 
a/tika-parsers/tika-parsers-standard/tika-parsers-standard-modules/tika-parser-webarchive-module/src/main/java/org/apache/tika/parser/wacz/WACZParser.java
+++ 
b/tika-parsers/tika-parsers-standard/tika-parsers-standard-modules/tika-parser-webarchive-module/src/main/java/org/apache/tika/parser/wacz/WACZParser.java
@@ -86,8 +86,8 @@ public class WACZParser extends AbstractParser {
     private void processStream(InputStream stream, XHTMLContentHandler xhtml, 
Metadata metadata,
                                EmbeddedDocumentExtractor ex) throws 
SAXException, IOException {
         try (ZipArchiveInputStream zais = new ZipArchiveInputStream(
-                new CloseShieldInputStream(stream))) {
-            ZipArchiveEntry zae = zais.getNextZipEntry();
+                CloseShieldInputStream.wrap(stream))) {
+            ZipArchiveEntry zae = zais.getNextEntry();
             while (zae != null) {
                 String name = zae.getName();
                 if (name.startsWith("archive/")) {
@@ -99,7 +99,7 @@ public class WACZParser extends AbstractParser {
                 }
                 //TODO -- process pages (jsonl); process indexes?!
 
-                zae = zais.getNextZipEntry();
+                zae = zais.getNextEntry();
             }
         }
     }
diff --git 
a/tika-parsers/tika-parsers-standard/tika-parsers-standard-package/src/test/java/org/apache/tika/config/TikaDetectorConfigTest.java
 
b/tika-parsers/tika-parsers-standard/tika-parsers-standard-package/src/test/java/org/apache/tika/config/TikaDetectorConfigTest.java
index fc573a8f0..9473c6035 100644
--- 
a/tika-parsers/tika-parsers-standard/tika-parsers-standard-package/src/test/java/org/apache/tika/config/TikaDetectorConfigTest.java
+++ 
b/tika-parsers/tika-parsers-standard/tika-parsers-standard-package/src/test/java/org/apache/tika/config/TikaDetectorConfigTest.java
@@ -109,7 +109,7 @@ public class TikaDetectorConfigTest extends 
AbstractTikaConfigTest {
         // Now check they detect PST files correctly
         try (TikaInputStream outer = TikaInputStream
                 .get(getResourceAsStream("/test-documents/testPST.pst"))) {
-            try (TikaInputStream stream = 
TikaInputStream.get(outer.getFile())) {
+            try (TikaInputStream stream = 
TikaInputStream.get(outer.getPath())) {
 
                 assertEquals(OutlookPSTParser.MS_OUTLOOK_PST_MIMETYPE,
                         detectorWX.detect(stream, new Metadata()));
diff --git 
a/tika-parsers/tika-parsers-standard/tika-parsers-standard-package/src/test/java/org/apache/tika/mime/OneOffMimeTest.java
 
b/tika-parsers/tika-parsers-standard/tika-parsers-standard-package/src/test/java/org/apache/tika/mime/OneOffMimeTest.java
index fb0ad4b54..f5aecbe68 100644
--- 
a/tika-parsers/tika-parsers-standard/tika-parsers-standard-package/src/test/java/org/apache/tika/mime/OneOffMimeTest.java
+++ 
b/tika-parsers/tika-parsers-standard/tika-parsers-standard-package/src/test/java/org/apache/tika/mime/OneOffMimeTest.java
@@ -67,7 +67,7 @@ public class OneOffMimeTest extends TikaTest {
         Metadata metadata = new Metadata();
         metadata.set(TikaCoreProperties.RESOURCE_NAME_KEY, 
p.getFileName().toString());
         assertEquals(expected,
-                getRecursiveMetadata(new 
UnsynchronizedByteArrayInputStream(new byte[0]),
+                
getRecursiveMetadata(UnsynchronizedByteArrayInputStream.builder().setByteArray(new
 byte[0]).get(),
                         metadata,
                         new ParseContext(), 
true).get(0).get(Metadata.CONTENT_TYPE));
     }
diff --git 
a/tika-parsers/tika-parsers-standard/tika-parsers-standard-package/src/test/java/org/apache/tika/parser/pkg/CompositeZipContainerDetectorTest.java
 
b/tika-parsers/tika-parsers-standard/tika-parsers-standard-package/src/test/java/org/apache/tika/parser/pkg/CompositeZipContainerDetectorTest.java
index cba520834..710f947c3 100644
--- 
a/tika-parsers/tika-parsers-standard/tika-parsers-standard-package/src/test/java/org/apache/tika/parser/pkg/CompositeZipContainerDetectorTest.java
+++ 
b/tika-parsers/tika-parsers-standard/tika-parsers-standard-package/src/test/java/org/apache/tika/parser/pkg/CompositeZipContainerDetectorTest.java
@@ -150,7 +150,7 @@ public class CompositeZipContainerDetectorTest extends 
TikaTest {
                 tikaStream += System.currentTimeMillis() - start;
 
                 start = System.currentTimeMillis();
-                try (InputStream is = TikaInputStream.get(z)) {
+                try (InputStream is = TikaInputStream.get(z.toPath())) {
                     MediaType mt = detector.detect(is, new Metadata());
                     mediaTypeSet.add(mt);
                 }
@@ -189,7 +189,7 @@ public class CompositeZipContainerDetectorTest extends 
TikaTest {
                 }
                 tikaStream += System.currentTimeMillis() - start;
                 start = System.currentTimeMillis();
-                try (InputStream is = TikaInputStream.get(z)) {
+                try (InputStream is = TikaInputStream.get(z.toPath())) {
                     getRecursiveMetadata(is, true);
                 }
                 tikaStreamWFile += System.currentTimeMillis() - start;
@@ -207,7 +207,7 @@ public class CompositeZipContainerDetectorTest extends 
TikaTest {
             throws Exception {
         List<File> zips = new ArrayList<>();
         for (File f : 
Paths.get(getResourceAsUri("/test-documents")).toFile().listFiles()) {
-            try (InputStream is = TikaInputStream.get(f)) {
+            try (InputStream is = TikaInputStream.get(f.toPath())) {
                 MediaType mt = detector.detect(is, new Metadata());
                 if (registry.isSpecializationOf(mt, 
MediaType.APPLICATION_ZIP)) {
                     zips.add(f);

Reply via email to