Skip to content

Commit bc086be

Browse files
committed
Fix URL construction for JAR resources
1 parent 6a6227a commit bc086be

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

resource/src/main/java/io/smallrye/common/resource/JarFileResource.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public URL url() {
4040
// todo: Java 20+: URL.of(new URI("jar", null, base.toURI().toASCIIString() + "!/" + pathName()),
4141
// new ResourceURLStreamHandler(this));
4242
url = this.url = new URL(null,
43-
new URI("jar", null, base.toURI().toASCIIString() + "!/" + pathName()).toASCIIString(),
43+
new URI("jar", base.toURI().toASCIIString() + "!/" + pathName(), null).toASCIIString(),
4444
new ResourceURLStreamHandler(this));
4545
} catch (MalformedURLException | URISyntaxException e) {
4646
throw new IllegalArgumentException(e);

resource/src/test/java/io/smallrye/common/resource/JarFileResourceLoaderTests.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,15 @@ public void testOpenJar() throws IOException {
3636
assertNull(rl.findResource("missing"));
3737
Resource dir1_file_stored_txt = rl.findResource("dir1/file-stored.txt");
3838
assertNotNull(dir1_file_stored_txt);
39+
assertEquals("jar:memory:test.jar!/dir1/file-stored.txt", dir1_file_stored_txt.url().toString());
3940
assertEquals(FILE_TXT, dir1_file_stored_txt.asString(StandardCharsets.UTF_8));
4041
Resource dir1_file_deflated_txt = rl.findResource("dir1/file-deflated.txt");
4142
assertNotNull(dir1_file_deflated_txt);
4243
assertEquals(FILE_TXT, dir1_file_deflated_txt.asString(StandardCharsets.UTF_8));
4344
Resource dir1 = rl.findResource("dir1");
4445
assertNotNull(dir1);
4546
assertEquals(0, dir1.size());
47+
assertEquals("jar:memory:test.jar!/dir1", dir1.url().toString());
4648
try (DirectoryStream<Resource> ds = dir1.openDirectoryStream()) {
4749
Iterator<Resource> iterator = ds.iterator();
4850
assertTrue(iterator.hasNext());

0 commit comments

Comments
 (0)