Skip to content

Commit e8c108e

Browse files
committed
Merge branch '2.8'
2 parents 24b5821 + 9a083ad commit e8c108e

File tree

5 files changed

+25
-8
lines changed

5 files changed

+25
-8
lines changed

release-notes/CREDITS

+5
Original file line numberDiff line numberDiff line change
@@ -613,6 +613,11 @@ Marco Catania ([email protected])
613613
* Contributed #1597: Escape JSONP breaking characters
614614
(2.8.9)
615615

616+
Andrew Joseph (apjoseph@github)
617+
* Reported #1629 `FromStringDeserializer` ignores registered `DeserializationProblemHandler`
618+
for `java.util.UUID`
619+
(2.8.9)
620+
616621
Connor Kuhn (ckuhn@github)
617622
* Contributed #1341: FAIL_ON_MISSING_EXTERNAL_TYPE_ID_PROPERTY
618623
(2.9.0)

release-notes/VERSION

+3
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,9 @@ Project: jackson-databind
9494
(reported by Javy L)
9595
#1597: Escape JSONP breaking characters
9696
(contributed by Marco C)
97+
#1629: `FromStringDeserializer` ignores registered `DeserializationProblemHandler`
98+
for `java.util.UUID`
99+
(reported by Andrew J)
97100

98101
2.8.8.1 (19-Apr-2017)
99102

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

+7-5
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.*;
1718
import com.fasterxml.jackson.databind.exc.InvalidFormatException;
1819
import com.fasterxml.jackson.databind.util.ClassUtil;
@@ -138,10 +139,10 @@ public T deserialize(JsonParser p, DeserializationContext ctxt) throws IOExcepti
138139
}
139140
Exception cause = null;
140141
try {
141-
T result = _deserialize(text, ctxt);
142-
if (result != null) {
143-
return result;
144-
}
142+
// 19-May-2017, tatu: Used to require non-null result (assuming `null`
143+
// indicated error; but that seems wrong. Should be able to return
144+
// `null` as value.
145+
return _deserialize(text, ctxt);
145146
} catch (IllegalArgumentException | MalformedURLException e) {
146147
cause = e;
147148
}
@@ -302,7 +303,8 @@ protected Object _deserialize(String value, DeserializationContext ctxt) throws
302303
case STD_STRING_BUILDER:
303304
return new StringBuilder(value);
304305
}
305-
throw new IllegalArgumentException();
306+
VersionUtil.throwInternal();
307+
return null;
306308
}
307309

308310
@Override

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

+3-3
Original file line numberDiff line numberDiff line change
@@ -189,13 +189,13 @@ protected Object _parse(String key, DeserializationContext ctxt) throws Exceptio
189189
case TYPE_LOCALE:
190190
try {
191191
return _deser._deserialize(key, ctxt);
192-
} catch (IOException e) {
192+
} catch (IllegalArgumentException e) {
193193
return _weirdKey(ctxt, key, e);
194194
}
195195
case TYPE_CURRENCY:
196196
try {
197197
return _deser._deserialize(key, ctxt);
198-
} catch (IOException e) {
198+
} catch (IllegalArgumentException e) {
199199
return _weirdKey(ctxt, key, e);
200200
}
201201
case TYPE_DATE:
@@ -229,7 +229,7 @@ protected Object _parse(String key, DeserializationContext ctxt) throws Exceptio
229229
case TYPE_BYTE_ARRAY:
230230
try {
231231
return ctxt.getConfig().getBase64Variant().decode(key);
232-
} catch (Exception e) {
232+
} catch (IllegalArgumentException e) {
233233
return _weirdKey(ctxt, key, e);
234234
}
235235
default:

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

+7
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import java.io.IOException;
44
import java.util.Map;
5+
import java.util.UUID;
56

67
import com.fasterxml.jackson.annotation.JsonTypeInfo;
78
import com.fasterxml.jackson.core.JsonParser;
@@ -261,6 +262,12 @@ public void testWeirdStringHandling() throws Exception
261262
;
262263
SingleValuedEnum result = mapper.readValue("\"B\"", SingleValuedEnum.class);
263264
assertEquals(SingleValuedEnum.A, result);
265+
266+
// also, write [databind#1629] try this
267+
mapper = new ObjectMapper()
268+
.addHandler(new WeirdStringHandler(null));
269+
UUID result2 = mapper.readValue(quote("not a uuid!"), UUID.class);
270+
assertNull(result2);
264271
}
265272

266273
public void testInvalidTypeId() throws Exception

0 commit comments

Comments
 (0)