Skip to content

Commit 8ceb8fa

Browse files
committed
Merge branch '2.8'
2 parents 95ee512 + e2476e0 commit 8ceb8fa

File tree

5 files changed

+13
-10
lines changed

5 files changed

+13
-10
lines changed

release-notes/CREDITS

+4
Original file line numberDiff line numberDiff line change
@@ -618,6 +618,10 @@ Andrew Joseph (apjoseph@github)
618618
for `java.util.UUID`
619619
(2.8.9)
620620

621+
Joe Littlejohn (joelittlejohn@github)
622+
* Contributed #1642: Support `READ_UNKNOWN_ENUM_VALUES_AS_NULL` with `@JsonCreator`
623+
(2.8.9)
624+
621625
Connor Kuhn (ckuhn@github)
622626
* Contributed #1341: FAIL_ON_MISSING_EXTERNAL_TYPE_ID_PROPERTY
623627
(2.9.0)

release-notes/VERSION

+2
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,8 @@ Project: jackson-databind
9999
#1629: `FromStringDeserializer` ignores registered `DeserializationProblemHandler`
100100
for `java.util.UUID`
101101
(reported by Andrew J)
102+
#1642: Support `READ_UNKNOWN_ENUM_VALUES_AS_NULL` with `@JsonCreator`
103+
(contributed by Joe L)
102104

103105
2.8.8.1 (19-Apr-2017)
104106

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

+1-2
Original file line numberDiff line numberDiff line change
@@ -134,12 +134,11 @@ public Object deserialize(JsonParser p, DeserializationContext ctxt) throws IOEx
134134
return _factory.callOnWith(_valueClass, value);
135135
} catch (Exception e) {
136136
Throwable t = ClassUtil.throwRootCauseIfIOE(e);
137-
137+
// [databind#1642]:
138138
if (ctxt.isEnabled(DeserializationFeature.READ_UNKNOWN_ENUM_VALUES_AS_NULL) &&
139139
t instanceof IllegalArgumentException) {
140140
return null;
141141
}
142-
143142
return ctxt.handleInstantiationProblem(_valueClass, value, t);
144143
}
145144
}

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

+5-8
Original file line numberDiff line numberDiff line change
@@ -146,18 +146,15 @@ public T deserialize(JsonParser p, DeserializationContext ctxt) throws IOExcepti
146146
} catch (IllegalArgumentException | MalformedURLException e) {
147147
cause = e;
148148
}
149+
// note: `cause` can't be null
149150
String msg = "not a valid textual representation";
150-
if (cause != null) {
151-
String m2 = cause.getMessage();
152-
if (m2 != null) {
153-
msg = msg + ", problem: "+m2;
154-
}
151+
String m2 = cause.getMessage();
152+
if (m2 != null) {
153+
msg = msg + ", problem: "+m2;
155154
}
156155
// 05-May-2016, tatu: Unlike most usage, this seems legit, so...
157156
JsonMappingException e = ctxt.weirdStringException(text, _valueClass, msg);
158-
if (cause != null) {
159-
e.initCause(cause);
160-
}
157+
e.initCause(cause);
161158
throw e;
162159
// nothing to do here, yet? We'll fail anyway
163160
}

src/test/java/com/fasterxml/jackson/databind/deser/jdk/EnumDeserializationTest.java

+1
Original file line numberDiff line numberDiff line change
@@ -334,6 +334,7 @@ public void testAllowUnknownEnumValuesReadAsNull() throws Exception
334334

335335
// Ability to ignore unknown Enum values:
336336

337+
// [databind#1642]
337338
public void testAllowUnknownEnumValuesReadAsNullWithCreatorMethod() throws Exception
338339
{
339340
// can not use shared mapper when changing configs...

0 commit comments

Comments
 (0)