Describe the bug
Mapping of a String to URL results in StackTrace to be written, in case the URL is malformed.
To Reproduce
public static record MyObject(URL myUrl) { }
@Test
void testInvalidUrl() {
var jsonString = """
{"myUrl":"This-Url-Is-Not-Valid"}
""";
var result = jsonb.fromJson(jsonString, MyObject.class);
assertNull(result.myUrl());
// Expected: No StackTrace written, but following StackTrace is written
/*
java.net.MalformedURLException: no protocol: This-Url-Is-Not-Valid
at java.base/java.net.URL.<init>(URL.java:735)
at java.base/java.net.URL.<init>(URL.java:630)
at java.base/java.net.URL.<init>(URL.java:566)
at org.eclipse.yasson.internal.deserializer.types.UrlDeserializer.deserializeStringValue(UrlDeserializer.java:34)
at org.eclipse.yasson.internal.deserializer.types.TypeDeserializer.deserialize(TypeDeserializer.java:37)
at org.eclipse.yasson.internal.deserializer.ValueExtractor.deserialize(ValueExtractor.java:47)
at org.eclipse.yasson.internal.deserializer.ValueExtractor.deserialize(ValueExtractor.java:24)
at org.eclipse.yasson.internal.deserializer.PositionChecker.deserialize(PositionChecker.java:85)
*/
}
@Test
void testValidUrl() {
var jsonString = """
{"myUrl":"https://example.com"}
""";
var result = jsonb.fromJson(jsonString, MyObject.class);
assertNotNull(result.myUrl());
}
Expected behavior
There is no stack trace written in all cases.
A debug log statement might be created, if debug log is enabled.
System information:
Additional context
Issue in org.eclipse.yasson.internal.deserializer.types.UrlDeserializer
Describe the bug
Mapping of a String to URL results in StackTrace to be written, in case the URL is malformed.
To Reproduce
public static record MyObject(URL myUrl) { }
Expected behavior
There is no stack trace written in all cases.
A debug log statement might be created, if debug log is enabled.
System information:
Additional context
Issue in org.eclipse.yasson.internal.deserializer.types.UrlDeserializer