Skip to content

Commit 8166ed2

Browse files
committed
Merge pull request #1240 from benson-basis/paths-fix
Allow Paths with no :.
2 parents 6e57ea1 + eae91d9 commit 8166ed2

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

src/main/java/com/fasterxml/jackson/databind/ext/NioPathDeserializer.java

+11-5
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,17 @@ public Path deserialize(JsonParser p, DeserializationContext ctxt) throws IOExce
3030
ctxt.reportMappingException(Path.class, p.getCurrentToken());
3131
}
3232
final String value = p.getText();
33-
try {
34-
URI uri = new URI(value);
35-
return Paths.get(uri);
36-
} catch (URISyntaxException e) {
37-
return (Path) ctxt.handleInstantiationProblem(handledType(), value, e);
33+
if (value.contains(":")) {
34+
try {
35+
URI uri = new URI(value);
36+
return Paths.get(uri);
37+
} catch (URISyntaxException e) {
38+
return (Path) ctxt.handleInstantiationProblem(handledType(), value, e);
39+
}
40+
} else {
41+
// If someone gives us an input with no : at all, treat as local path, instead of failing
42+
// with invalid URI.
43+
return Paths.get(value);
3844
}
3945
}
4046
}

0 commit comments

Comments
 (0)