Fix handling of file: paths to non-existent files

For setAsText, if the text argument is a file: URL for a path that does not exist, Paths.get(text) is called where text is a file: URL, which doesn't work - the result is an InvalidPathException.

To fix this issue, also check that the resource isn't a file before calling Paths.get(). That way, resources that are files skip to the other branch.
This commit is contained in:
Craig Andrews
2021-02-20 01:05:13 -05:00
committed by Juergen Hoeller
parent dee12db50a
commit ebf6fff312
2 changed files with 25 additions and 1 deletions

View File

@@ -97,7 +97,7 @@ public class PathEditor extends PropertyEditorSupport {
if (resource == null) {
setValue(null);
}
else if (!resource.exists() && nioPathCandidate) {
else if (!resource.isFile() && !resource.exists() && nioPathCandidate) {
setValue(Paths.get(text).normalize());
}
else {