Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix forward reference in hierarchies #610

Merged

Conversation

zeitos
Copy link
Contributor

@zeitos zeitos commented Nov 10, 2014

Fix a Forward reference problem when having inheritance.

if you revert the code in AbstractDeserializer the test fails with:


com.fasterxml.jackson.databind.JsonMappingException: Could not resolve Object Id [willBeForwardReferenced] -- unresolved forward-reference? (through reference chain: com.fasterxml.jackson.databind.deser.ForwardReferenceContainerClass["frc"])
    at com.fasterxml.jackson.databind.JsonMappingException.wrapWithPath(JsonMappingException.java:210)
    at com.fasterxml.jackson.databind.JsonMappingException.wrapWithPath(JsonMappingException.java:177)
    at com.fasterxml.jackson.databind.deser.BeanDeserializerBase.wrapAndThrow(BeanDeserializerBase.java:1436)
    at com.fasterxml.jackson.databind.deser.BeanDeserializer.vanillaDeserialize(BeanDeserializer.java:240)
    at com.fasterxml.jackson.databind.deser.BeanDeserializer._deserializeOther(BeanDeserializer.java:151)
    at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:126)
    at com.fasterxml.jackson.databind.jsontype.impl.AsPropertyTypeDeserializer._deserializeTypedForId(AsPropertyTypeDeserializer.java:124)
    at com.fasterxml.jackson.databind.jsontype.impl.AsPropertyTypeDeserializer.deserializeTypedFromObject(AsPropertyTypeDeserializer.java:95)
    at com.fasterxml.jackson.databind.deser.BeanDeserializerBase.deserializeWithType(BeanDeserializerBase.java:956)
    at com.fasterxml.jackson.databind.deser.impl.TypeWrappedDeserializer.deserialize(TypeWrappedDeserializer.java:42)
    at com.fasterxml.jackson.databind.ObjectMapper._readMapAndClose(ObjectMapper.java:3259)
    at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:2346)
    at com.fasterxml.jackson.databind.deser.TestForwardReference.testForwardRef(TestForwardReference.java:31)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:84)
    at org.junit.runner.JUnitCore.run(JUnitCore.java:160)
    at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:74)
    at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:211)
    at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:67)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at com.intellij.rt.execution.application.AppMain.main(AppMain.java:134)
Caused by: java.lang.IllegalStateException: Could not resolve Object Id [willBeForwardReferenced] -- unresolved forward-reference?
    at com.fasterxml.jackson.databind.deser.AbstractDeserializer._deserializeFromObjectId(AbstractDeserializer.java:198)
    at com.fasterxml.jackson.databind.deser.AbstractDeserializer.deserializeWithType(AbstractDeserializer.java:122)
    at com.fasterxml.jackson.databind.deser.SettableBeanProperty.deserialize(SettableBeanProperty.java:527)
    at com.fasterxml.jackson.databind.deser.impl.ObjectIdReferenceProperty.deserializeSetAndReturn(ObjectIdReferenceProperty.java:70)
    at com.fasterxml.jackson.databind.deser.impl.ObjectIdReferenceProperty.deserializeAndSet(ObjectIdReferenceProperty.java:62)
    at com.fasterxml.jackson.databind.deser.BeanDeserializer.vanillaDeserialize(BeanDeserializer.java:238)

@cowtowncoder
Copy link
Member

Excellent, thank you for the contribution!

One practical thing we need before merging in the first contribution is to get a filled Contributor License Agreement (CLA). It can be found from here:

https://github.com/FasterXML/jackson/blob/master/contributor-agreement.pdf

and it's just one page; and we only need it filled once and can then merge any number of contributions.
Apologies for the extra process.

Would it be possible to get that filled in, scanned and sent to info at fasterxml.com?

cowtowncoder added a commit that referenced this pull request Nov 12, 2014
@cowtowncoder cowtowncoder merged commit 2a2ae59 into FasterXML:master Nov 12, 2014
cowtowncoder added a commit that referenced this pull request Nov 12, 2014
@cowtowncoder
Copy link
Member

Once again, thank you for contributing this -- very important fix. Will be in 2.4.4.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants