Skip to content

Commit

Permalink
Close jar to allow it to be cleaned up after test execution
Browse files Browse the repository at this point in the history
  • Loading branch information
wilkinsona committed Dec 14, 2023
1 parent 1d64976 commit 85cfa47
Showing 1 changed file with 8 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,14 @@ void doesNotCloseJarFromCachedConnection() throws Exception {
File jarFile = createResourcesJar("test-resources.jar");
TrackedURLStreamHandler handler = new TrackedURLStreamHandler(true);
URL url = new URL("jar", null, 0, jarFile.toURI().toURL().toString() + "!/", handler);
new StaticResourceJars().getUrlsFrom(url);
assertThatNoException()
.isThrownBy(() -> ((JarURLConnection) handler.getConnection()).getJarFile().getComment());
try {
new StaticResourceJars().getUrlsFrom(url);
assertThatNoException()
.isThrownBy(() -> ((JarURLConnection) handler.getConnection()).getJarFile().getComment());
}
finally {
((JarURLConnection) handler.getConnection()).getJarFile().close();
}
}

@Test
Expand Down

0 comments on commit 85cfa47

Please sign in to comment.