Skip to content

Commit 07b479e

Browse files
committed
FileUrlResource creates same class from createRelative
Issue: SPR-16140
1 parent a75dd2d commit 07b479e

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

spring-core/src/main/java/org/springframework/core/io/FileUrlResource.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,14 @@ public FileUrlResource(String location) throws MalformedURLException {
7070
}
7171

7272

73+
@Override
74+
public Resource createRelative(String relativePath) throws MalformedURLException {
75+
if (relativePath.startsWith("/")) {
76+
relativePath = relativePath.substring(1);
77+
}
78+
return new FileUrlResource(new URL(getURL(), relativePath));
79+
}
80+
7381
@Override
7482
public boolean isWritable() {
7583
try {

spring-core/src/main/java/org/springframework/core/io/UrlResource.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ public InputStream getInputStream() throws IOException {
183183
* This implementation returns the underlying URL reference.
184184
*/
185185
@Override
186-
public URL getURL() throws IOException {
186+
public URL getURL() {
187187
return this.url;
188188
}
189189

0 commit comments

Comments
 (0)