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

Regression in support for JsonProperty #239

Closed
tjwilson90 opened this Issue Jan 15, 2016 · 3 comments

Comments

Projects
None yet
3 participants
@tjwilson90

tjwilson90 commented Jan 15, 2016

Example:

import org.immutables.value.Value;

import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;

@Value.Immutable
@JsonSerialize(as = ImmutableFoo.class)
@JsonDeserialize(as = ImmutableFoo.class)
public abstract class Foo {

    @JsonProperty("bar")
    public abstract boolean isBar();

    public static void main(String[] args) throws Exception {
        ObjectMapper mapper = new ObjectMapper();
        Foo foo = mapper.readValue("{\"bar\": true}", Foo.class);
        System.out.println(mapper.writeValueAsString(foo));
    }
}

With immutables version 2.1.0 this works as expected (prints {"bar": true}).
With immutables version 2.1.7 this fails with an exception

Exception in thread "main" com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException: Unrecognized field "bar" (class ImmutableFoo$Json), not marked as ignorable (one known property: "isBar"])
 at [Source: {"bar": true}; line: 1, column: 13] (through reference chain: Json["bar"])
    at com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException.from(UnrecognizedPropertyException.java:51)
    at com.fasterxml.jackson.databind.DeserializationContext.reportUnknownProperty(DeserializationContext.java:839)
    at com.fasterxml.jackson.databind.deser.std.StdDeserializer.handleUnknownProperty(StdDeserializer.java:1045)
    at com.fasterxml.jackson.databind.deser.BeanDeserializerBase.handleUnknownProperty(BeanDeserializerBase.java:1352)
    at com.fasterxml.jackson.databind.deser.BeanDeserializerBase.handleUnknownVanilla(BeanDeserializerBase.java:1330)
    at com.fasterxml.jackson.databind.deser.BeanDeserializer.vanillaDeserialize(BeanDeserializer.java:264)
    at com.fasterxml.jackson.databind.deser.BeanDeserializer._deserializeOther(BeanDeserializer.java:161)
    at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:136)
    at com.fasterxml.jackson.databind.deser.BeanDeserializerBase.deserializeFromObjectUsingNonDefault(BeanDeserializerBase.java:1095)
    at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserializeFromObject(BeanDeserializer.java:296)
    at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:133)
    at com.fasterxml.jackson.databind.ObjectMapper._readMapAndClose(ObjectMapper.java:3736)
    at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:2726)
    at Foo.main(Foo.java:18)
@elucash

This comment has been minimized.

Member

elucash commented Jan 15, 2016

Thank you for reporting this! v2.1.8 containing the fix will be released shortly.
@ldriscoll can you, please, look at some point for see if this fix could have broken something.

@elucash elucash added this to the 2.1.8 milestone Jan 15, 2016

@elucash

This comment has been minimized.

Member

elucash commented Jan 16, 2016

Released in 2.1.8

@elucash elucash closed this Jan 26, 2016

@ldriscoll

This comment has been minimized.

Contributor

ldriscoll commented Jan 27, 2016

I'm not seeing any issues so far.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment