Skip to content

Commit

Permalink
Use file urls for unpacked jars
Browse files Browse the repository at this point in the history
Update `JarFileArchive` so that unpacked jars use `file:` URLs rather
than `jar:file:`. This aligns with the behavior of Spring Boot 3.1 and
allows calls to `class.getSigners()` to work again.

Fixes gh-38833
  • Loading branch information
philwebb committed Dec 17, 2023
1 parent 3d42dc7 commit 88429b6
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ private URL getUnpackedNestedJarUrl(JarEntry jarEntry) throws IOException {
if (!Files.exists(path) || Files.size(path) != jarEntry.getSize()) {
unpack(jarEntry, path);
}
return JarUrl.create(path.toFile());
return path.toUri().toURL();
}

private Path getTempUnpackDirectory() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,8 @@ void getClassPathUrlsWhenHasUnpackCommentUnpacksAndReturnsUrls() throws Exceptio
assertThat(urls).hasSize(1);
URL url = urls.iterator().next();
assertThat(url).isNotEqualTo(JarUrl.create(this.file, "nested.jar"));
assertThat(url.toString()).startsWith("jar:file:").endsWith("/nested.jar!/");
// The unpack URL must be a raw file URL (see gh-38833)
assertThat(url.toString()).startsWith("file:").endsWith("/nested.jar").doesNotStartWith("jar:");
}

@Test
Expand Down

0 comments on commit 88429b6

Please sign in to comment.