Skip to content

Commit f2ce463

Browse files
author
Jakub Skierbiszewski
committed
Fix FasterXML#2001 remove renamed properties from ignored
1 parent 5c95315 commit f2ce463

File tree

2 files changed

+37
-0
lines changed

2 files changed

+37
-0
lines changed

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -822,6 +822,11 @@ protected void _renameProperties(Map<String, POJOPropertyBuilder> props)
822822
}
823823
// replace the creatorProperty too, if there is one
824824
_updateCreatorProperty(prop, _creatorProperties);
825+
826+
// New name of property was ignored previously - remove from ignored [#2001]
827+
if (_ignoredPropertyNames != null) {
828+
_ignoredPropertyNames.remove(name);
829+
}
825830
}
826831
}
827832
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
package com.fasterxml.jackson.databind.introspect;
2+
3+
import com.fasterxml.jackson.annotation.JsonCreator;
4+
import com.fasterxml.jackson.annotation.JsonIgnore;
5+
import com.fasterxml.jackson.annotation.JsonProperty;
6+
import com.fasterxml.jackson.databind.BaseMapTest;
7+
import com.fasterxml.jackson.databind.ObjectMapper;
8+
import org.junit.Test;
9+
10+
import java.beans.ConstructorProperties;
11+
import java.io.IOException;
12+
13+
// Tests for [databind#2001]
14+
public class IgnoredFieldPresentInCreatorProperty2001Test extends BaseMapTest {
15+
16+
static public class Foo {
17+
18+
@JsonIgnore
19+
public String query;
20+
21+
@JsonCreator
22+
@ConstructorProperties("rawQuery")
23+
public Foo(@JsonProperty("query") String rawQuery) {
24+
query = rawQuery;
25+
}
26+
}
27+
28+
public void testIgnoredFieldPresentInPropertyCreator() throws IOException {
29+
Foo deserialized = new ObjectMapper().readValue("{\"query\": \"bar\"}", Foo.class);
30+
assertEquals("bar", deserialized.query);
31+
}
32+
}

0 commit comments

Comments
 (0)