Skip to content

Commit ba45be2

Browse files
committed
Backport #2001 fix for 2.9(.6)
1 parent f2d2c31 commit ba45be2

File tree

4 files changed

+41
-0
lines changed

4 files changed

+41
-0
lines changed

release-notes/CREDITS-2.x

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -775,3 +775,8 @@ Freddy Boucher (freddyboucher@github)
775775
Ondrej Zizka (OndraZizk@github)
776776
* Reported #1999: "Duplicate property" issue should mention which class it complains about
777777
(2.9.6)
778+
779+
Jakub Skierbiszewski (jskierbi@github)
780+
* Reported, contributed fix for #2001: Deserialization issue with `@JsonIgnore` and
781+
`@JsonCreator` + `@JsonProperty` for same property name
782+
(2.9.6)

release-notes/VERSION-2.x

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ Project: jackson-databind
1818
(reported by SBKila@github)
1919
#1999: "Duplicate property" issue should mention which class it complains about
2020
(reported by Ondrej Z)
21+
#2001: Deserialization issue with `@JsonIgnore` and `@JsonCreator` + `@JsonProperty`
22+
for same property name
23+
(reported, fix contributed by Jakub S)
2124
#2019: Abstract Type mapping in 2.9 fails when multiple modules are registered
2225
(reported by asger82@github)
2326

src/main/java/com/fasterxml/jackson/databind/introspect/POJOPropertiesCollector.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -822,6 +822,12 @@ protected void _renameProperties(Map<String, POJOPropertyBuilder> props)
822822
}
823823
// replace the creatorProperty too, if there is one
824824
_updateCreatorProperty(prop, _creatorProperties);
825+
// [databind#2001]: New name of property was ignored previously? Remove from ignored
826+
// 01-May-2018, tatu: I have a feeling this will need to be revisited at some point,
827+
// to avoid removing some types of removals, possibly. But will do for now.
828+
if (_ignoredPropertyNames != null) {
829+
_ignoredPropertyNames.remove(name);
830+
}
825831
}
826832
}
827833
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
package com.fasterxml.jackson.databind.introspect;
2+
3+
import java.beans.ConstructorProperties;
4+
5+
import com.fasterxml.jackson.annotation.*;
6+
7+
import com.fasterxml.jackson.databind.BaseMapTest;
8+
9+
public class IgnoredFieldPresentInCreatorProperty2001Test extends BaseMapTest
10+
{
11+
static public class Foo {
12+
@JsonIgnore
13+
public String query;
14+
15+
// 01-May-2018, tatu: Important! Without this there is no problem
16+
@ConstructorProperties("rawQuery")
17+
@JsonCreator
18+
public Foo(@JsonProperty("query") String rawQuery) {
19+
query = rawQuery;
20+
}
21+
}
22+
23+
public void testIgnoredFieldPresentInPropertyCreator() throws Exception {
24+
Foo deserialized = newObjectMapper().readValue("{\"query\": \"bar\"}", Foo.class);
25+
assertEquals("bar", deserialized.query);
26+
}
27+
}

0 commit comments

Comments
 (0)