diff --git a/spring-boot-project/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/jar/JarFile.java b/spring-boot-project/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/jar/JarFile.java index 65450ce395..81386386f9 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/jar/JarFile.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/jar/JarFile.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2022 the original author or authors. + * Copyright 2012-2021 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -128,6 +128,9 @@ public class JarFile extends AbstractJarFile implements Iterable manifestSupplier) throws IOException { super(rootFile.getFile()); + if (System.getSecurityManager() == null) { + super.close(); + } this.rootFile = rootFile; this.pathFromRoot = pathFromRoot; CentralDirectoryParser parser = new CentralDirectoryParser(); @@ -139,7 +142,8 @@ public class JarFile extends AbstractJarFile implements Iterable container = createContainer(javaRuntime, "spring-boot-loader-tests-app")) { + try (GenericContainer container = createContainer(javaRuntime)) { container.start(); System.out.println(this.output.toUtf8String()); assertThat(this.output.toUtf8String()).contains(">>>>> 287649 BYTES from").doesNotContain("WARNING:") @@ -59,32 +59,17 @@ class LoaderIntegrationTests { } } - @ParameterizedTest - @MethodSource("javaRuntimes") - void runSignedJarWhenUnpacked(JavaRuntime javaRuntime) { - try (GenericContainer container = createContainer(javaRuntime, - "spring-boot-loader-tests-signed-jar-unpack-app")) { - container.start(); - System.out.println(this.output.toUtf8String()); - assertThat(this.output.toUtf8String()).contains("Legion of the Bouncy Castle"); - } - } - - private GenericContainer createContainer(JavaRuntime javaRuntime, String name) { + private GenericContainer createContainer(JavaRuntime javaRuntime) { return javaRuntime.getContainer().withLogConsumer(this.output) - .withCopyFileToContainer(findApplication(name), "/app.jar") + .withCopyFileToContainer(MountableFile.forHostPath(findApplication().toPath()), "/app.jar") .withStartupCheckStrategy(new OneShotStartupCheckStrategy().withTimeout(Duration.ofMinutes(5))) .withCommand("java", "-jar", "app.jar"); } - private MountableFile findApplication(String name) { - return MountableFile.forHostPath(findJarFile(name).toPath()); - } - - private File findJarFile(String name) { - String path = String.format("build/%1$s/build/libs/%1$s.jar", name); - File jar = new File(path); - Assert.state(jar.isFile(), () -> "Could not find " + path + ". Have you built it?"); + private File findApplication() { + String name = String.format("build/%1$s/build/libs/%1$s.jar", "spring-boot-loader-tests-app"); + File jar = new File(name); + Assert.state(jar.isFile(), () -> "Could not find " + name + ". Have you built it?"); return jar; }