diff --git a/spring-boot-project/spring-boot-tools/spring-boot-loader/src/test/java/org/springframework/boot/loader/jar/JarFileTests.java b/spring-boot-project/spring-boot-tools/spring-boot-loader/src/test/java/org/springframework/boot/loader/jar/JarFileTests.java index 3b29fd2290..57df8ce4fb 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-loader/src/test/java/org/springframework/boot/loader/jar/JarFileTests.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-loader/src/test/java/org/springframework/boot/loader/jar/JarFileTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2019 the original author or authors. + * Copyright 2012-2020 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. @@ -595,11 +595,12 @@ class JarFileTests { jarOutputStream.write(new byte[] { (byte) 1 }); jarOutputStream.closeEntry(); } - JarFile jarFile = new JarFile(file); - Enumeration entries = jarFile.entries(); - JarEntry entry = entries.nextElement(); - assertThat(entry.getLastModifiedTime().toInstant()).isEqualTo(Instant.EPOCH); - assertThat(entry.getName()).isEqualTo("1.dat"); + try (JarFile jar = new JarFile(file)) { + Enumeration entries = jar.entries(); + JarEntry entry = entries.nextElement(); + assertThat(entry.getLastModifiedTime().toInstant()).isEqualTo(Instant.EPOCH); + assertThat(entry.getName()).isEqualTo("1.dat"); + } } private int getJavaVersion() {