Skip to content

Commit be11363

Browse files
committed
Fix #1003
1 parent 19ba372 commit be11363

File tree

2 files changed

+12
-24
lines changed

2 files changed

+12
-24
lines changed

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

+7-18
Original file line numberDiff line numberDiff line change
@@ -714,7 +714,13 @@ protected Object deserializeWithExternalTypeId(JsonParser p, DeserializationCont
714714
return deserializeUsingPropertyBasedWithExternalTypeId(p, ctxt);
715715
}
716716
if (_delegateDeserializer != null) {
717-
return deserializeUsingDelegateWithExternalTypeId(p, ctxt);
717+
/* 24-Nov-2015, tatu: Use of delegating creator needs to have precedence, and basically
718+
* external type id handling just has to be ignored, as they would relate to target
719+
* type and not delegate type. Whether this works as expected is another story, but
720+
* there's no other way to really mix these conflicting features.
721+
*/
722+
return _valueInstantiator.createUsingDelegate(ctxt,
723+
_delegateDeserializer.deserialize(p, ctxt));
718724
}
719725

720726
return deserializeWithExternalTypeId(p, ctxt, _valueInstantiator.createUsingDefault(ctxt));
@@ -855,21 +861,4 @@ protected Object deserializeUsingPropertyBasedWithExternalTypeId(JsonParser p, D
855861
return null; // never gets here
856862
}
857863
}
858-
859-
/**
860-
* @since 2.7
861-
*/
862-
protected Object deserializeUsingDelegateWithExternalTypeId(JsonParser p, DeserializationContext ctxt)
863-
throws IOException
864-
{
865-
// 24-Nov-2015, tatu: Something along these lines would normally work, in absence
866-
// of external type id:
867-
/*
868-
Object delegate = _delegateDeserializer.deserialize(p, ctxt);
869-
return _valueInstantiator.createUsingDelegate(ctxt, delegate);
870-
*/
871-
872-
throw ctxt.instantiationException(handledType(),
873-
"Combination of External Type Id, Delegating Creator not yet supported");
874-
}
875864
}

src/test/java/com/fasterxml/jackson/failing/DelegatingExternalProperty1003Test.java renamed to src/test/java/com/fasterxml/jackson/databind/creators/DelegatingExternalProperty1003Test.java

+5-6
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package com.fasterxml.jackson.failing;
1+
package com.fasterxml.jackson.databind.creators;
22

33
import com.fasterxml.jackson.annotation.*;
44

@@ -35,8 +35,10 @@ static class Delegate {
3535
public interface Hero { }
3636

3737
static class Superman implements Hero {
38+
String name = "superman";
39+
3840
public String getName() {
39-
return "superman";
41+
return name;
4042
}
4143
}
4244

@@ -46,11 +48,8 @@ public void testExtrnalPropertyDelegatingCreator() throws Exception
4648

4749
final String json = mapper.writeValueAsString(new HeroBattle(new Superman()));
4850

49-
//System.err.println("JSON: "+json);
5051
final HeroBattle battle = mapper.readValue(json, HeroBattle.class);
5152

52-
assert battle.getHero() instanceof Superman;
53+
assertTrue(battle.getHero() instanceof Superman);
5354
}
54-
55-
5655
}

0 commit comments

Comments
 (0)