Skip to content

Commit af51660

Browse files
committed
Merge pull request #44309 from nosan
* pr/44309: Handle absolute files on Windows Closes gh-44309
2 parents 09ac085 + 183b9e6 commit af51660

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

spring-boot-project/spring-boot/src/main/java/org/springframework/boot/io/ApplicationResourceLoader.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -216,10 +216,7 @@ public Resource getResource(String location) {
216216
private Resource resolveFile(Resource resource) {
217217
try {
218218
File file = resource.getFile();
219-
if (file.isAbsolute()) {
220-
return resource;
221-
}
222-
return new ApplicationResource(new File(this.workingDirectory.toFile(), file.getPath()).getPath());
219+
return new ApplicationResource(this.workingDirectory.resolve(file.toPath()));
223220
}
224221
catch (FileNotFoundException ex) {
225222
return resource;
@@ -254,6 +251,10 @@ private static final class ApplicationResource extends FileSystemResource implem
254251
super(path);
255252
}
256253

254+
ApplicationResource(Path path) {
255+
super(path);
256+
}
257+
257258
@Override
258259
public String getPathWithinContext() {
259260
return getPath();

0 commit comments

Comments
 (0)