Skip to content

Commit 5ea8878

Browse files
committed
Backport #486 in 2.3 as well
1 parent f56ca05 commit 5ea8878

File tree

2 files changed

+25
-22
lines changed

2 files changed

+25
-22
lines changed

src/main/java/com/fasterxml/jackson/databind/deser/BeanDeserializer.java

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -127,12 +127,8 @@ public Object deserialize(JsonParser jp, DeserializationContext ctxt)
127127
}
128128

129129
protected final Object _deserializeOther(JsonParser jp, DeserializationContext ctxt,
130-
JsonToken t)
131-
throws IOException, JsonProcessingException
130+
JsonToken t) throws IOException
132131
{
133-
if (t == null) {
134-
return _missingToken(jp, ctxt);
135-
}
136132
// and then others, generally requiring use of @JsonCreator
137133
switch (t) {
138134
case VALUE_STRING:
@@ -142,7 +138,7 @@ protected final Object _deserializeOther(JsonParser jp, DeserializationContext c
142138
case VALUE_NUMBER_FLOAT:
143139
return deserializeFromDouble(jp, ctxt);
144140
case VALUE_EMBEDDED_OBJECT:
145-
return jp.getEmbeddedObject();
141+
return deserializeFromEmbedded(jp, ctxt);
146142
case VALUE_TRUE:
147143
case VALUE_FALSE:
148144
return deserializeFromBoolean(jp, ctxt);

src/main/java/com/fasterxml/jackson/databind/deser/BeanDeserializerBase.java

Lines changed: 23 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -967,8 +967,7 @@ protected Object _handleTypedObjectId(JsonParser jp, DeserializationContext ctxt
967967
*/
968968
@SuppressWarnings("resource") // TokenBuffers don't need close, nor parser thereof
969969
protected Object _convertObjectId(JsonParser jp, DeserializationContext ctxt,
970-
Object rawId, JsonDeserializer<Object> idDeser)
971-
throws IOException, JsonProcessingException
970+
Object rawId, JsonDeserializer<Object> idDeser) throws IOException
972971
{
973972
TokenBuffer buf = new TokenBuffer(jp);
974973
if (rawId instanceof String) {
@@ -979,6 +978,8 @@ protected Object _convertObjectId(JsonParser jp, DeserializationContext ctxt,
979978
buf.writeNumber(((Integer) rawId).intValue());
980979
} else {
981980
// should we worry about UUIDs? They should be fine, right?
981+
// 07-Aug-2014, tatu: Maybe, but not necessarily; had issues with
982+
// Smile format; [Smile#19], possibly related.
982983
buf.writeObject(rawId);
983984
}
984985
JsonParser bufParser = buf.asParser();
@@ -1045,8 +1046,7 @@ protected Object deserializeWithObjectId(JsonParser jp, DeserializationContext c
10451046
* Method called in cases where it looks like we got an Object Id
10461047
* to parse and use as a reference.
10471048
*/
1048-
protected Object deserializeFromObjectId(JsonParser jp, DeserializationContext ctxt)
1049-
throws IOException, JsonProcessingException
1049+
protected Object deserializeFromObjectId(JsonParser jp, DeserializationContext ctxt) throws IOException
10501050
{
10511051
Object id = _objectIdReader.readObjectReference(jp, ctxt);
10521052
ReadableObjectId roid = ctxt.findObjectId(id, _objectIdReader.generator);
@@ -1060,8 +1060,7 @@ protected Object deserializeFromObjectId(JsonParser jp, DeserializationContext c
10601060
}
10611061

10621062
protected Object deserializeFromObjectUsingNonDefault(JsonParser jp,
1063-
DeserializationContext ctxt)
1064-
throws IOException, JsonProcessingException
1063+
DeserializationContext ctxt) throws IOException
10651064
{
10661065
if (_delegateDeserializer != null) {
10671066
return _valueInstantiator.createUsingDelegate(ctxt,
@@ -1084,8 +1083,7 @@ protected abstract Object _deserializeUsingPropertyBased(final JsonParser jp,
10841083
throws IOException, JsonProcessingException;
10851084

10861085
@SuppressWarnings("incomplete-switch")
1087-
public Object deserializeFromNumber(JsonParser jp, DeserializationContext ctxt)
1088-
throws IOException, JsonProcessingException
1086+
public Object deserializeFromNumber(JsonParser jp, DeserializationContext ctxt) throws IOException
10891087
{
10901088
// First things first: id Object Id is used, most likely that's it
10911089
if (_objectIdReader != null) {
@@ -1127,8 +1125,7 @@ public Object deserializeFromNumber(JsonParser jp, DeserializationContext ctxt)
11271125
throw ctxt.instantiationException(getBeanClass(), "no suitable creator method found to deserialize from JSON integer number");
11281126
}
11291127

1130-
public Object deserializeFromString(JsonParser jp, DeserializationContext ctxt)
1131-
throws IOException, JsonProcessingException
1128+
public Object deserializeFromString(JsonParser jp, DeserializationContext ctxt) throws IOException
11321129
{
11331130
// First things first: id Object Id is used, most likely that's it
11341131
if (_objectIdReader != null) {
@@ -1155,8 +1152,7 @@ public Object deserializeFromString(JsonParser jp, DeserializationContext ctxt)
11551152
* number.
11561153
*/
11571154
@SuppressWarnings("incomplete-switch")
1158-
public Object deserializeFromDouble(JsonParser jp, DeserializationContext ctxt)
1159-
throws IOException, JsonProcessingException
1155+
public Object deserializeFromDouble(JsonParser jp, DeserializationContext ctxt) throws IOException
11601156
{
11611157
switch (jp.getNumberType()) {
11621158
case FLOAT: // no separate methods for taking float...
@@ -1182,8 +1178,7 @@ public Object deserializeFromDouble(JsonParser jp, DeserializationContext ctxt)
11821178
/**
11831179
* Method called to deserialize POJO value from a JSON boolean value (true, false)
11841180
*/
1185-
public Object deserializeFromBoolean(JsonParser jp, DeserializationContext ctxt)
1186-
throws IOException, JsonProcessingException
1181+
public Object deserializeFromBoolean(JsonParser jp, DeserializationContext ctxt) throws IOException
11871182
{
11881183
if (_delegateDeserializer != null) {
11891184
if (!_valueInstantiator.canCreateFromBoolean()) {
@@ -1198,8 +1193,7 @@ public Object deserializeFromBoolean(JsonParser jp, DeserializationContext ctxt)
11981193
return _valueInstantiator.createFromBoolean(ctxt, value);
11991194
}
12001195

1201-
public Object deserializeFromArray(JsonParser jp, DeserializationContext ctxt)
1202-
throws IOException, JsonProcessingException
1196+
public Object deserializeFromArray(JsonParser jp, DeserializationContext ctxt) throws IOException
12031197
{
12041198
if (_delegateDeserializer != null) {
12051199
try {
@@ -1214,6 +1208,19 @@ public Object deserializeFromArray(JsonParser jp, DeserializationContext ctxt)
12141208
}
12151209
throw ctxt.mappingException(getBeanClass());
12161210
}
1211+
1212+
public Object deserializeFromEmbedded(JsonParser jp, DeserializationContext ctxt) throws IOException
1213+
{
1214+
// First things first: id Object Id is used, most likely that's it; specifically,
1215+
// true for UUIDs when written as binary (with Smile, other binary formats)
1216+
if (_objectIdReader != null) {
1217+
return deserializeFromObjectId(jp, ctxt);
1218+
}
1219+
1220+
// TODO: maybe add support for ValueInstantiator, embedded?
1221+
1222+
return jp.getEmbeddedObject();
1223+
}
12171224

12181225
/*
12191226
/**********************************************************

0 commit comments

Comments
 (0)