Skip to content

Commit

Permalink
Fix #2001 remove renamed properties from ignored (#2002)
Browse files Browse the repository at this point in the history
  • Loading branch information
jskierbi authored and cowtowncoder committed May 2, 2018
1 parent 3010de7 commit 9e72a25
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -790,6 +790,11 @@ protected void _renameProperties(Map<String, POJOPropertyBuilder> props)
}
// replace the creatorProperty too, if there is one
_updateCreatorProperty(prop, _creatorProperties);

// New name of property was ignored previously - remove from ignored [#2001]
if (_ignoredPropertyNames != null) {
_ignoredPropertyNames.remove(name);
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package com.fasterxml.jackson.databind.introspect;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.BaseMapTest;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.junit.Test;

import java.beans.ConstructorProperties;
import java.io.IOException;

// Tests for [databind#2001]
public class IgnoredFieldPresentInCreatorProperty2001Test extends BaseMapTest {

static public class Foo {

@JsonIgnore
public String query;

@JsonCreator
@ConstructorProperties("rawQuery")
public Foo(@JsonProperty("query") String rawQuery) {
query = rawQuery;
}
}

public void testIgnoredFieldPresentInPropertyCreator() throws IOException {
Foo deserialized = new ObjectMapper().readValue("{\"query\": \"bar\"}", Foo.class);
assertEquals("bar", deserialized.query);
}
}

0 comments on commit 9e72a25

Please sign in to comment.