Skip to content

Commit

Permalink
Merge pull request #367 from dmlloyd/fs-exists
Browse files Browse the repository at this point in the history
Do not return a resource for non-existent filesystem files
  • Loading branch information
dmlloyd authored Oct 30, 2024
2 parents 7ecc8cf + 2a12f5e commit e1865ed
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import java.net.MalformedURLException;
import java.net.URL;
import java.nio.file.FileSystem;
import java.nio.file.Files;
import java.nio.file.Path;

import io.smallrye.common.constraint.Assert;
Expand Down Expand Up @@ -41,7 +42,11 @@ public PathResourceLoader(final FileSystem fs) {

public Resource findResource(final String path) {
String canon = ResourceUtils.canonicalizeRelativePath(path);
return new PathResource(canon, base.resolve(canon));
Path filePath = base.resolve(canon);
if (!Files.exists(filePath)) {
return null;
}
return new PathResource(canon, filePath);
}

public URL baseUrl() {
Expand Down

0 comments on commit e1865ed

Please sign in to comment.