Browse Source

Delete unpacked jars when the JVM exits

Update `JarFileArchive` so that any unpacked files are now deleted when
the JVM exits.

Closes gh-25773
pull/26093/head
Phillip Webb 5 years ago
parent
commit
ec21202d54
  1. 1
      spring-boot-project/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/archive/JarFileArchive.java

1
spring-boot-project/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/archive/JarFileArchive.java

@ -158,6 +158,7 @@ public class JarFileArchive implements Archive { @@ -158,6 +158,7 @@ public class JarFileArchive implements Archive {
private void unpack(JarEntry entry, Path path) throws IOException {
createFile(path);
path.toFile().deleteOnExit();
try (InputStream inputStream = this.jarFile.getInputStream(entry);
OutputStream outputStream = Files.newOutputStream(path, StandardOpenOption.WRITE,
StandardOpenOption.TRUNCATE_EXISTING)) {

Loading…
Cancel
Save