commit
2b7320be1a
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2012-2023 the original author or authors.
|
||||
* Copyright 2012-2024 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.
|
||||
|
@ -38,6 +38,7 @@ import java.util.List;
|
|||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import org.springframework.boot.loader.net.util.UrlDecoder;
|
||||
import org.springframework.boot.loader.ref.Cleaner;
|
||||
|
||||
/**
|
||||
|
@ -76,7 +77,7 @@ class NestedUrlConnection extends URLConnection {
|
|||
|
||||
private NestedLocation parseNestedLocation(URL url) throws MalformedURLException {
|
||||
try {
|
||||
return NestedLocation.parse(url.getPath());
|
||||
return NestedLocation.parse(UrlDecoder.decode(url.getPath()));
|
||||
}
|
||||
catch (IllegalArgumentException ex) {
|
||||
throw new MalformedURLException(ex.getMessage());
|
||||
|
|
|
@ -121,13 +121,7 @@ class NestedUrlConnectionTests {
|
|||
@Test
|
||||
void getInputStreamReturnsContentOfNestedJar() throws Exception {
|
||||
NestedUrlConnection connection = new NestedUrlConnection(this.url);
|
||||
try (InputStream actual = connection.getInputStream()) {
|
||||
try (ZipContent zipContent = ZipContent.open(this.jarFile.toPath())) {
|
||||
try (InputStream expected = zipContent.getEntry("nested.jar").openContent().asInputStream()) {
|
||||
assertThat(actual).hasSameContentAs(expected);
|
||||
}
|
||||
}
|
||||
}
|
||||
assertHasSameContentAsNestedJar(connection);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -163,6 +157,29 @@ class NestedUrlConnectionTests {
|
|||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
void createDecodesUrlPath() throws Exception {
|
||||
File withSpace = new File(this.temp, "te st");
|
||||
withSpace.mkdirs();
|
||||
this.jarFile = new File(withSpace, "test.jar");
|
||||
TestJar.create(this.jarFile);
|
||||
this.url = new URL("nested:" + this.jarFile.toURI().getRawPath() + "/!nested.jar");
|
||||
assertThat(this.url.toString()).contains("%20");
|
||||
NestedUrlConnection connection = new NestedUrlConnection(this.url);
|
||||
assertHasSameContentAsNestedJar(connection);
|
||||
assertThat(connection.getLastModified()).isEqualTo(this.jarFile.lastModified());
|
||||
}
|
||||
|
||||
private void assertHasSameContentAsNestedJar(NestedUrlConnection connection) throws IOException {
|
||||
try (InputStream actual = connection.getInputStream()) {
|
||||
try (ZipContent zipContent = ZipContent.open(this.jarFile.toPath())) {
|
||||
try (InputStream expected = zipContent.getEntry("nested.jar").openContent().asInputStream()) {
|
||||
assertThat(actual).hasSameContentAs(expected);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private long withoutNanos(long epochMilli) {
|
||||
return Instant.ofEpochMilli(epochMilli).with(ChronoField.NANO_OF_SECOND, 0).toEpochMilli();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue