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

ArrayIndexOutOfBoundsException on impossible non-static inner class constructor #1501

Closed
khogeland opened this issue Jan 23, 2017 · 4 comments
Milestone

Comments

@khogeland
Copy link
Member

khogeland commented Jan 23, 2017

Minimal repro:

public class Something {
    public InnerSomething a;

    @JsonCreator
    public Something(@JsonProperty("a") InnerSomething a) {}

    class InnerSomething {
        @JsonCreator
        public InnerSomething() {}
    }

}
        ObjectMapper mapper = new ObjectMapper();
        String ser = mapper.writeValueAsString(new Something(null));
        mapper.readValue(ser, Something.class);

Fails like this:

java.lang.ArrayIndexOutOfBoundsException: -1

	at com.fasterxml.jackson.databind.deser.impl.PropertyValueBuffer.assignParameter(PropertyValueBuffer.java:210)
	at com.fasterxml.jackson.databind.deser.BeanDeserializer._deserializeUsingPropertyBased(BeanDeserializer.java:380)
	at com.fasterxml.jackson.databind.deser.BeanDeserializerBase.deserializeFromObjectUsingNonDefault(BeanDeserializerBase.java:1123)
	at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserializeFromObject(BeanDeserializer.java:298)
	at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:133)
	at com.fasterxml.jackson.databind.ObjectMapper._readMapAndClose(ObjectMapper.java:3807)
	at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:2797)

Validation is missing for this impossible constructor. Works as expected when InnerSomething is static.

@cowtowncoder
Copy link
Member

Definitely feels like this is related to #1502 too, errors seem to vary slightly based on minor differences.

@cowtowncoder
Copy link
Member

Interesting: fails on 2.7, 2.8 branches, but on master.

@cowtowncoder cowtowncoder added this to the 2.7.9 milestone Jan 25, 2017
@cowtowncoder
Copy link
Member

And the reason for failure was that of not delegating various methods from InnerClassProperty to underlying CreatorProperty; something that was actually fixed for master (by creating a "delegating" base class for such properties).
I suspect this will resolve #1502 and/or #1503 but will check them separately.

@cowtowncoder
Copy link
Member

One additional note: actual test case will not actually pass due to complications of trying to pass inner class as creator parameter (it would, however, work as "regular" property). This may or may not be fixable, but at least exception message is more descriptive.

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

No branches or pull requests

2 participants