diff --git a/spring-boot-project/spring-boot-parent/build.gradle b/spring-boot-project/spring-boot-parent/build.gradle index 66bcecfd7f..62a46fb129 100644 --- a/spring-boot-project/spring-boot-parent/build.gradle +++ b/spring-boot-project/spring-boot-parent/build.gradle @@ -47,7 +47,7 @@ bom { ] } } - library("Commons Compress", "1.25.0") { + library("Commons Compress", "1.27.1") { group("org.apache.commons") { modules = [ "commons-compress" diff --git a/spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/main/java/org/springframework/boot/buildpack/platform/io/ZipFileTarArchive.java b/spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/main/java/org/springframework/boot/buildpack/platform/io/ZipFileTarArchive.java index c1d3b10021..5ea6a459a8 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/main/java/org/springframework/boot/buildpack/platform/io/ZipFileTarArchive.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/main/java/org/springframework/boot/buildpack/platform/io/ZipFileTarArchive.java @@ -64,7 +64,7 @@ public class ZipFileTarArchive implements TarArchive { public void writeTo(OutputStream outputStream) throws IOException { TarArchiveOutputStream tar = new TarArchiveOutputStream(outputStream); tar.setLongFileMode(TarArchiveOutputStream.LONGFILE_POSIX); - try (ZipFile zipFile = new ZipFile(this.zip)) { + try (ZipFile zipFile = ZipFile.builder().setFile(this.zip).get()) { Enumeration entries = zipFile.getEntries(); while (entries.hasMoreElements()) { ZipArchiveEntry zipEntry = entries.nextElement(); @@ -75,7 +75,7 @@ public class ZipFileTarArchive implements TarArchive { } private void assertArchiveHasEntries(File file) { - try (ZipFile zipFile = new ZipFile(file)) { + try (ZipFile zipFile = ZipFile.builder().setFile(file).get()) { Assert.state(zipFile.getEntries().hasMoreElements(), () -> "Archive file '" + file + "' is not valid"); } catch (IOException ex) { diff --git a/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/test/java/org/springframework/boot/gradle/tasks/bundling/AbstractBootArchiveIntegrationTests.java b/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/test/java/org/springframework/boot/gradle/tasks/bundling/AbstractBootArchiveIntegrationTests.java index 202172abf4..d2050ddc8f 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/test/java/org/springframework/boot/gradle/tasks/bundling/AbstractBootArchiveIntegrationTests.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/test/java/org/springframework/boot/gradle/tasks/bundling/AbstractBootArchiveIntegrationTests.java @@ -579,7 +579,9 @@ abstract class AbstractBootArchiveIntegrationTests { void defaultDirAndFileModesAreUsed() throws IOException { BuildResult result = this.gradleBuild.build(this.taskName); assertThat(result.task(":" + this.taskName).getOutcome()).isEqualTo(TaskOutcome.SUCCESS); - try (ZipFile jarFile = new ZipFile(new File(this.gradleBuild.getProjectDir(), "build/libs").listFiles()[0])) { + try (ZipFile jarFile = ZipFile.builder() + .setFile(new File(this.gradleBuild.getProjectDir(), "build/libs").listFiles()[0]) + .get()) { Enumeration entries = jarFile.getEntries(); while (entries.hasMoreElements()) { ZipArchiveEntry entry = entries.nextElement(); @@ -605,7 +607,9 @@ abstract class AbstractBootArchiveIntegrationTests { "upgrading_version_8.html#unix_file_permissions_deprecated") .build(this.taskName); assertThat(result.task(":" + this.taskName).getOutcome()).isEqualTo(TaskOutcome.SUCCESS); - try (ZipFile jarFile = new ZipFile(new File(this.gradleBuild.getProjectDir(), "build/libs").listFiles()[0])) { + try (ZipFile jarFile = ZipFile.builder() + .setFile(new File(this.gradleBuild.getProjectDir(), "build/libs").listFiles()[0]) + .get()) { Enumeration entries = jarFile.getEntries(); while (entries.hasMoreElements()) { ZipArchiveEntry entry = entries.nextElement(); diff --git a/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/test/java/org/springframework/boot/gradle/tasks/bundling/AbstractBootArchiveTests.java b/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/test/java/org/springframework/boot/gradle/tasks/bundling/AbstractBootArchiveTests.java index 2c9c2213b5..eb800b7bce 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/test/java/org/springframework/boot/gradle/tasks/bundling/AbstractBootArchiveTests.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/test/java/org/springframework/boot/gradle/tasks/bundling/AbstractBootArchiveTests.java @@ -330,7 +330,7 @@ abstract class AbstractBootArchiveTests { File archiveFile = this.task.getArchiveFile().get().getAsFile(); assertThat(Files.readAllBytes(archiveFile.toPath())) .startsWith(new DefaultLaunchScript(null, properties).toByteArray()); - try (ZipFile zipFile = new ZipFile(archiveFile)) { + try (ZipFile zipFile = ZipFile.builder().setFile(archiveFile).get()) { assertThat(zipFile.getEntries().hasMoreElements()).isTrue(); } try { @@ -460,7 +460,7 @@ abstract class AbstractBootArchiveTests { this.task.classpath(classpathDirectory); executeTask(); File archivePath = this.task.getArchiveFile().get().getAsFile(); - try (ZipFile zip = new ZipFile(archivePath)) { + try (ZipFile zip = ZipFile.builder().setFile(archivePath).get()) { Enumeration entries = zip.getEntries(); while (entries.hasMoreElements()) { ZipArchiveEntry entry = entries.nextElement(); diff --git a/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/test/java/org/springframework/boot/gradle/testkit/PluginClasspathGradleBuild.java b/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/test/java/org/springframework/boot/gradle/testkit/PluginClasspathGradleBuild.java index 14d1700b43..c1d90b5205 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/test/java/org/springframework/boot/gradle/testkit/PluginClasspathGradleBuild.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/test/java/org/springframework/boot/gradle/testkit/PluginClasspathGradleBuild.java @@ -80,6 +80,7 @@ public class PluginClasspathGradleBuild extends GradleBuild { new File(pathOfJarContaining("org.jetbrains.kotlin.daemon.client.KotlinCompilerClient")), new File(pathOfJarContaining(KotlinCompilerPluginSupportPlugin.class)), new File(pathOfJarContaining(LanguageSettings.class)), + new File(pathOfJarContaining("org.apache.commons.io.Charsets")), new File(pathOfJarContaining(ArchiveEntry.class)), new File(pathOfJarContaining(BuildRequest.class)), new File(pathOfJarContaining(HttpClientConnectionManager.class)), new File(pathOfJarContaining(HttpRequest.class)), diff --git a/spring-boot-project/spring-boot-tools/spring-boot-loader-tools/src/test/java/org/springframework/boot/loader/tools/RepackagerTests.java b/spring-boot-project/spring-boot-tools/spring-boot-loader-tools/src/test/java/org/springframework/boot/loader/tools/RepackagerTests.java index 239c0cc381..660958ab6e 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-loader-tools/src/test/java/org/springframework/boot/loader/tools/RepackagerTests.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-loader-tools/src/test/java/org/springframework/boot/loader/tools/RepackagerTests.java @@ -162,7 +162,7 @@ class RepackagerTests extends AbstractPackagerTests { assertThat(new String(bytes)).startsWith("ABC"); assertThat(hasLauncherClasses(source)).isFalse(); assertThat(hasLauncherClasses(this.destination)).isTrue(); - try (ZipFile zipFile = new ZipFile(this.destination)) { + try (ZipFile zipFile = ZipFile.builder().setFile(this.destination).get()) { assertThat(zipFile.getEntries().hasMoreElements()).isTrue(); } try { @@ -267,7 +267,7 @@ class RepackagerTests extends AbstractPackagerTests { @Override protected Collection getAllPackagedEntries() throws IOException { List result = new ArrayList<>(); - try (ZipFile zip = new ZipFile(this.destination)) { + try (ZipFile zip = ZipFile.builder().setFile(this.destination).get()) { Enumeration entries = zip.getEntries(); while (entries.hasMoreElements()) { result.add(entries.nextElement()); @@ -285,7 +285,7 @@ class RepackagerTests extends AbstractPackagerTests { @Override protected String getPackagedEntryContent(String name) throws IOException { - try (ZipFile zip = new ZipFile(this.destination)) { + try (ZipFile zip = ZipFile.builder().setFile(this.destination).get()) { ZipArchiveEntry entry = zip.getEntry(name); if (entry == null) { return null;