Skip to content

Commit 9a083ad

Browse files
committed
Fix #1629
1 parent edaa4ad commit 9a083ad

File tree

4 files changed

+17
-8
lines changed

4 files changed

+17
-8
lines changed

release-notes/CREDITS

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -609,6 +609,11 @@ Marco Catania (catanm@github.com)
609609
* Contributed #1597: Escape JSONP breaking characters
610610
(2.8.9)
611611

612+
Andrew Joseph (apjoseph@github)
613+
* Reported #1629 `FromStringDeserializer` ignores registered `DeserializationProblemHandler`
614+
for `java.util.UUID`
615+
(2.8.9)
616+
612617
Connor Kuhn (ckuhn@github)
613618
* Contributed #1341: FAIL_ON_MISSING_EXTERNAL_TYPE_ID_PROPERTY
614619
(2.9.0)

release-notes/VERSION

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ Project: jackson-databind
99
(reported by Javy L)
1010
#1597: Escape JSONP breaking characters
1111
(contributed by Marco C)
12+
#1629: `FromStringDeserializer` ignores registered `DeserializationProblemHandler`
13+
for `java.util.UUID`
14+
(reported by Andrew J)
1215

1316
2.8.8.1 (19-Apr-2017)
1417

src/main/java/com/fasterxml/jackson/databind/deser/std/FromStringDeserializer.java

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
import java.util.regex.Pattern;
1414

1515
import com.fasterxml.jackson.core.*;
16+
import com.fasterxml.jackson.core.util.VersionUtil;
1617
import com.fasterxml.jackson.databind.DeserializationContext;
1718
import com.fasterxml.jackson.databind.JavaType;
1819
import com.fasterxml.jackson.databind.JsonMappingException;
@@ -112,10 +113,10 @@ public T deserialize(JsonParser p, DeserializationContext ctxt) throws IOExcepti
112113
}
113114
Exception cause = null;
114115
try {
115-
T result = _deserialize(text, ctxt);
116-
if (result != null) {
117-
return result;
118-
}
116+
// 19-May-2017, tatu: Used to require non-null result (assuming `null`
117+
// indicated error; but that seems wrong. Should be able to return
118+
// `null` as value.
119+
return _deserialize(text, ctxt);
119120
} catch (IllegalArgumentException iae) {
120121
cause = iae;
121122
} catch (MalformedURLException me) {
@@ -277,7 +278,8 @@ protected Object _deserialize(String value, DeserializationContext ctxt) throws
277278
case STD_STRING_BUILDER:
278279
return new StringBuilder(value);
279280
}
280-
throw new IllegalArgumentException();
281+
VersionUtil.throwInternal();
282+
return null;
281283
}
282284

283285
@Override

src/test/java/com/fasterxml/jackson/databind/filter/ProblemHandlerTest.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -242,11 +242,10 @@ public void testWeirdStringHandling() throws Exception
242242
assertEquals(SingleValuedEnum.A, result);
243243

244244
// also, write [databind#1629] try this
245-
UUID defaultUUID = UUID.nameUUIDFromBytes("abc".getBytes());
246245
mapper = new ObjectMapper()
247-
.addHandler(new WeirdStringHandler(defaultUUID));
246+
.addHandler(new WeirdStringHandler(null));
248247
UUID result2 = mapper.readValue(quote("not a uuid!"), UUID.class);
249-
assertEquals(defaultUUID, result2);
248+
assertNull(result2);
250249
}
251250

252251
public void testInvalidTypeId() throws Exception

0 commit comments

Comments
 (0)