From: PJ Fanning Date: Wed, 5 Jun 2024 18:51:17 +0000 (+0000) Subject: ZipFile deprecation warnings X-Git-Tag: REL_5_3_0~11 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=ca64f86ff8e613ab98c1a395bfc8e3e572e8833a;p=poi.git ZipFile deprecation warnings git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1918179 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/poi-ooxml/src/main/java/org/apache/poi/poifs/crypt/temp/AesZipFileZipEntrySource.java b/poi-ooxml/src/main/java/org/apache/poi/poifs/crypt/temp/AesZipFileZipEntrySource.java index 4384f0f6dc..2969bbf581 100644 --- a/poi-ooxml/src/main/java/org/apache/poi/poifs/crypt/temp/AesZipFileZipEntrySource.java +++ b/poi-ooxml/src/main/java/org/apache/poi/poifs/crypt/temp/AesZipFileZipEntrySource.java @@ -64,7 +64,7 @@ public final class AesZipFileZipEntrySource implements ZipEntrySource { private AesZipFileZipEntrySource(File tmpFile, Cipher ci) throws IOException { this.tmpFile = tmpFile; - this.zipFile = new ZipFile(tmpFile); + this.zipFile = ZipFile.builder().setFile(tmpFile).get(); this.ci = ci; this.closed = false; } diff --git a/poi-ooxml/src/test/java/org/apache/poi/openxml4j/util/TestZipSecureFile.java b/poi-ooxml/src/test/java/org/apache/poi/openxml4j/util/TestZipSecureFile.java index 064b0825f3..5d81c23091 100644 --- a/poi-ooxml/src/test/java/org/apache/poi/openxml4j/util/TestZipSecureFile.java +++ b/poi-ooxml/src/test/java/org/apache/poi/openxml4j/util/TestZipSecureFile.java @@ -34,7 +34,8 @@ class TestZipSecureFile { // ClassCastException in ZipFile now // The relevant change in the JDK is http://hg.openjdk.java.net/jdk/jdk10/rev/85ea7e83af30#l5.66 - try (ZipFile thresholdInputStream = new ZipFile(XSSFTestDataSamples.getSampleFile("template.xlsx"))) { + try (ZipFile thresholdInputStream = + ZipFile.builder().setFile(XSSFTestDataSamples.getSampleFile("template.xlsx")).get()) { try (ZipSecureFile secureFile = new ZipSecureFile(XSSFTestDataSamples.getSampleFile("template.xlsx"))) { Enumeration entries = thresholdInputStream.getEntries(); while (entries.hasMoreElements()) { diff --git a/poi-ooxml/src/test/java/org/apache/poi/xssf/usermodel/TestXSSFBugs.java b/poi-ooxml/src/test/java/org/apache/poi/xssf/usermodel/TestXSSFBugs.java index 09d2120c76..2bd719b1cd 100644 --- a/poi-ooxml/src/test/java/org/apache/poi/xssf/usermodel/TestXSSFBugs.java +++ b/poi-ooxml/src/test/java/org/apache/poi/xssf/usermodel/TestXSSFBugs.java @@ -1887,7 +1887,7 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues { @Test void test54764WithSAXHelper() throws Exception { File testFile = XSSFTestDataSamples.getSampleFile("54764.xlsx"); - try (ZipFile zip = new ZipFile(testFile)) { + try (ZipFile zip = ZipFile.builder().setFile(testFile).get()) { ZipArchiveEntry ze = zip.getEntry("xl/sharedStrings.xml"); XMLReader reader = XMLHelper.newXMLReader(); SAXParseException e = assertThrows(SAXParseException.class, @@ -1900,7 +1900,7 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues { @Test void test54764WithDocumentHelper() throws Exception { File testFile = XSSFTestDataSamples.getSampleFile("54764.xlsx"); - try (ZipFile zip = new ZipFile(testFile)) { + try (ZipFile zip = ZipFile.builder().setFile(testFile).get()) { ZipArchiveEntry ze = zip.getEntry("xl/sharedStrings.xml"); SAXParseException e = assertThrows(SAXParseException.class, () -> DocumentHelper.readDocument(zip.getInputStream(ze))); @@ -3908,7 +3908,7 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues { private static void readByCommonsCompress(File temp_excel_poi) throws IOException { /* read by commons-compress*/ - try (ZipFile zipFile = new ZipFile(temp_excel_poi)) { + try (ZipFile zipFile = ZipFile.builder().setFile(temp_excel_poi).get()) { ZipArchiveEntry entry = zipFile.getEntry("xl/workbook.xml"); InputStream inputStream = zipFile.getInputStream(entry);