Skip to content

Commit 85cfa47

Browse files
committed
Close jar to allow it to be cleaned up after test execution
See gh-38766
1 parent 1d64976 commit 85cfa47

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/servlet/server/StaticResourceJarsTests.java

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,9 +96,14 @@ void doesNotCloseJarFromCachedConnection() throws Exception {
9696
File jarFile = createResourcesJar("test-resources.jar");
9797
TrackedURLStreamHandler handler = new TrackedURLStreamHandler(true);
9898
URL url = new URL("jar", null, 0, jarFile.toURI().toURL().toString() + "!/", handler);
99-
new StaticResourceJars().getUrlsFrom(url);
100-
assertThatNoException()
101-
.isThrownBy(() -> ((JarURLConnection) handler.getConnection()).getJarFile().getComment());
99+
try {
100+
new StaticResourceJars().getUrlsFrom(url);
101+
assertThatNoException()
102+
.isThrownBy(() -> ((JarURLConnection) handler.getConnection()).getJarFile().getComment());
103+
}
104+
finally {
105+
((JarURLConnection) handler.getConnection()).getJarFile().close();
106+
}
102107
}
103108

104109
@Test

0 commit comments

Comments
 (0)