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

jackson-databind 2.9.0-pr1 breaks builder deserialization #1557

Closed
stevenschlansker opened this issue Mar 13, 2017 · 3 comments · Fixed by #1558
Closed

jackson-databind 2.9.0-pr1 breaks builder deserialization #1557

stevenschlansker opened this issue Mar 13, 2017 · 3 comments · Fixed by #1558
Milestone

Comments

@stevenschlansker
Copy link

For a Builder like,

@AutoValue
@JsonDeserialize(builder = AutoValue_Restaurant.Builder.class)
@JsonNaming(PropertyNamingStrategy.UpperCamelCaseStrategy.class)
public abstract class Restaurant {
    Restaurant() { }

    @JsonProperty("RID")
    public abstract long getRID();

    @AutoValue.Builder
    @JsonNaming(PropertyNamingStrategy.UpperCamelCaseStrategy.class)
    @JsonPOJOBuilder(withPrefix="set")
    public abstract static class Builder {
        @JsonProperty("RID")
        public abstract Builder setRID(long rid);
    }
}

This code worked with 2.8 branch, but updating the 2.9.0-pr1 (to test out #1402) breaks it. It seems that commit e452793 changed the default behavior of AnnotationInspector#findPOJOBuilderConfig() to returning a default value rather than null.

We end up with a ParameterNamesAnnotationIntrospector stacked on top of a JacksonAnnotationIntrospector. Previously, AnnotationIntrospectorPair#findPOJOBuilderConfig would try the former, get null, then fallback to the latter. Now it gets a bogus empty configuration from the former and never gets the correct configuration from the latter.

@stevenschlansker
Copy link
Author

Ugly hack workaround:

diff --git a/src/main/java/com/fasterxml/jackson/databind/introspect/AnnotationIntrospectorPair.java b/src/main/java/com/fasterxml/jackson/databind/introspect/AnnotationIntrospectorPair.java
index 408f2c9..6afe3de 100644
--- a/src/main/java/com/fasterxml/jackson/databind/introspect/AnnotationIntrospectorPair.java
+++ b/src/main/java/com/fasterxml/jackson/databind/introspect/AnnotationIntrospectorPair.java
@@ -705,7 +705,7 @@ public class AnnotationIntrospectorPair
     @Override
     public JsonPOJOBuilder.Value findPOJOBuilderConfig(AnnotatedClass ac) {
         JsonPOJOBuilder.Value result = _primary.findPOJOBuilderConfig(ac);
-        return (result == null) ? _secondary.findPOJOBuilderConfig(ac) : result;
+        return (result == null || result == JsonPOJOBuilder.Value.empty()) ? _secondary.findPOJOBuilderConfig(ac) : result;
     }
     
     // // // Deserialization: method annotations

@cowtowncoder
Copy link
Member

I'd love to fix this, but I would need a reproduction that does not rely on auto-value lib itself: generated sources are ok but ideally simpified example.

@cowtowncoder
Copy link
Member

Fixed via @stevenschlansker 's patch, will be in 2.9.0.pr2.

@cowtowncoder cowtowncoder added this to the 2.9.0.pr2 milestone Mar 15, 2017
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 a pull request may close this issue.

2 participants