Skip to content

Commit

Permalink
Fix #1003
Browse files Browse the repository at this point in the history
  • Loading branch information
cowtowncoder committed Nov 25, 2015
1 parent 19ba372 commit be11363
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -714,7 +714,13 @@ protected Object deserializeWithExternalTypeId(JsonParser p, DeserializationCont
return deserializeUsingPropertyBasedWithExternalTypeId(p, ctxt);
}
if (_delegateDeserializer != null) {
return deserializeUsingDelegateWithExternalTypeId(p, ctxt);
/* 24-Nov-2015, tatu: Use of delegating creator needs to have precedence, and basically
* external type id handling just has to be ignored, as they would relate to target
* type and not delegate type. Whether this works as expected is another story, but
* there's no other way to really mix these conflicting features.
*/
return _valueInstantiator.createUsingDelegate(ctxt,
_delegateDeserializer.deserialize(p, ctxt));
}

return deserializeWithExternalTypeId(p, ctxt, _valueInstantiator.createUsingDefault(ctxt));
Expand Down Expand Up @@ -855,21 +861,4 @@ protected Object deserializeUsingPropertyBasedWithExternalTypeId(JsonParser p, D
return null; // never gets here
}
}

/**
* @since 2.7
*/
protected Object deserializeUsingDelegateWithExternalTypeId(JsonParser p, DeserializationContext ctxt)
throws IOException
{
// 24-Nov-2015, tatu: Something along these lines would normally work, in absence
// of external type id:
/*
Object delegate = _delegateDeserializer.deserialize(p, ctxt);
return _valueInstantiator.createUsingDelegate(ctxt, delegate);
*/

throw ctxt.instantiationException(handledType(),
"Combination of External Type Id, Delegating Creator not yet supported");
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.fasterxml.jackson.failing;
package com.fasterxml.jackson.databind.creators;

import com.fasterxml.jackson.annotation.*;

Expand Down Expand Up @@ -35,8 +35,10 @@ static class Delegate {
public interface Hero { }

static class Superman implements Hero {
String name = "superman";

public String getName() {
return "superman";
return name;
}
}

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

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

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

assert battle.getHero() instanceof Superman;
assertTrue(battle.getHero() instanceof Superman);
}


}

0 comments on commit be11363

Please sign in to comment.