Backport #2001 fix for 2.9(.6)
diff --git a/release-notes/CREDITS-2.x b/release-notes/CREDITS-2.x
index 5792c75..3e77eac 100644
--- a/release-notes/CREDITS-2.x
+++ b/release-notes/CREDITS-2.x
@@ -775,3 +775,8 @@
Ondrej Zizka (OndraZizk@github)
* Reported #1999: "Duplicate property" issue should mention which class it complains about
(2.9.6)
+
+Jakub Skierbiszewski (jskierbi@github)
+ * Reported, contributed fix for #2001: Deserialization issue with `@JsonIgnore` and
+ `@JsonCreator` + `@JsonProperty` for same property name
+ (2.9.6)
diff --git a/release-notes/VERSION-2.x b/release-notes/VERSION-2.x
index 8eceed3..80c90dd 100644
--- a/release-notes/VERSION-2.x
+++ b/release-notes/VERSION-2.x
@@ -18,6 +18,9 @@
(reported by SBKila@github)
#1999: "Duplicate property" issue should mention which class it complains about
(reported by Ondrej Z)
+#2001: Deserialization issue with `@JsonIgnore` and `@JsonCreator` + `@JsonProperty`
+ for same property name
+ (reported, fix contributed by Jakub S)
#2019: Abstract Type mapping in 2.9 fails when multiple modules are registered
(reported by asger82@github)
diff --git a/src/main/java/com/fasterxml/jackson/databind/introspect/POJOPropertiesCollector.java b/src/main/java/com/fasterxml/jackson/databind/introspect/POJOPropertiesCollector.java
index 0dc1bbe..f7609a7 100644
--- a/src/main/java/com/fasterxml/jackson/databind/introspect/POJOPropertiesCollector.java
+++ b/src/main/java/com/fasterxml/jackson/databind/introspect/POJOPropertiesCollector.java
@@ -822,6 +822,12 @@
}
// replace the creatorProperty too, if there is one
_updateCreatorProperty(prop, _creatorProperties);
+ // [databind#2001]: New name of property was ignored previously? Remove from ignored
+ // 01-May-2018, tatu: I have a feeling this will need to be revisited at some point,
+ // to avoid removing some types of removals, possibly. But will do for now.
+ if (_ignoredPropertyNames != null) {
+ _ignoredPropertyNames.remove(name);
+ }
}
}
}
diff --git a/src/test/java/com/fasterxml/jackson/databind/introspect/IgnoredFieldPresentInCreatorProperty2001Test.java b/src/test/java/com/fasterxml/jackson/databind/introspect/IgnoredFieldPresentInCreatorProperty2001Test.java
new file mode 100644
index 0000000..a551c0a
--- /dev/null
+++ b/src/test/java/com/fasterxml/jackson/databind/introspect/IgnoredFieldPresentInCreatorProperty2001Test.java
@@ -0,0 +1,27 @@
+package com.fasterxml.jackson.databind.introspect;
+
+import java.beans.ConstructorProperties;
+
+import com.fasterxml.jackson.annotation.*;
+
+import com.fasterxml.jackson.databind.BaseMapTest;
+
+public class IgnoredFieldPresentInCreatorProperty2001Test extends BaseMapTest
+{
+ static public class Foo {
+ @JsonIgnore
+ public String query;
+
+ // 01-May-2018, tatu: Important! Without this there is no problem
+ @ConstructorProperties("rawQuery")
+ @JsonCreator
+ public Foo(@JsonProperty("query") String rawQuery) {
+ query = rawQuery;
+ }
+ }
+
+ public void testIgnoredFieldPresentInPropertyCreator() throws Exception {
+ Foo deserialized = newObjectMapper().readValue("{\"query\": \"bar\"}", Foo.class);
+ assertEquals("bar", deserialized.query);
+ }
+}