Skip to content

Commit

Permalink
Fix #1595 for 2.8.9
Browse files Browse the repository at this point in the history
  • Loading branch information
cowtowncoder committed May 4, 2017
1 parent dec4a48 commit 4a2b1ae
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 63 deletions.
4 changes: 4 additions & 0 deletions release-notes/CREDITS
Original file line number Diff line number Diff line change
Expand Up @@ -601,6 +601,10 @@ Ivo Studens ([email protected])
when loading modules using `ObjectMapper.findModules()`
(2.8.9)

Javy Luo (AnywnYu@github)
* Reported #1595: `JsonIgnoreProperties.allowSetters` is not working in Jackson 2.8
(2.8.9)

Marco Catania ([email protected])
* Contributed #1597: Escape JSONP breaking characters
(2.8.9)
Expand Down
2 changes: 2 additions & 0 deletions release-notes/VERSION
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ Project: jackson-databind

2.8.9 (not yet released)

#1595: `JsonIgnoreProperties.allowSetters` is not working in Jackson 2.8
(reported by Javy L)
#1597: Escape JSONP breaking characters
(contributed by Marco C)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -492,7 +492,7 @@ protected void addBeanProps(DeserializationContext ctxt,
boolean ignoreAny = ignorals.getIgnoreUnknown();
builder.setIgnoreUnknownProperties(ignoreAny);
// Or explicit/implicit definitions?
ignored = ignorals.getIgnored();
ignored = ignorals.findIgnoredForDeserialization();
for (String propName : ignored) {
builder.addIgnorable(propName);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,19 +27,4 @@ public void testIgnorePropDeser1575() throws Exception
Person result = mapper.readValue(st, Person.class);
assertEquals("admin", result.name);
}

/*
public void testIgnorePropSer1575() throws Exception
{
ObjectMapper mapper = new ObjectMapper();
Person input = new Person();
input.name = "Bob";
// 24-Mar-2017, tatu: This shouldn't cause issues... but does as of now:
// input.personZ = input;
String json = mapper.writeValueAsString(input);
assertNotNull(json);
}
*/
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
package com.fasterxml.jackson.databind.filter;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
import com.fasterxml.jackson.databind.BaseMapTest;
import com.fasterxml.jackson.databind.ObjectMapper;

public class IgnorePropertyOnDeser1217Test extends BaseMapTest
public class IgnorePropertyOnDeserTest extends BaseMapTest
{
// [databind#1217]
static class IgnoreObject {
public int x = 1;
public int y = 2;
Expand All @@ -19,15 +21,30 @@ final static class TestIgnoreObject {
public IgnoreObject obj2;
}

// [databind#1595]
@JsonIgnoreProperties(value = {"name"}, allowSetters = true)
@JsonPropertyOrder(alphabetic=true)
static class Simple1595 {
private int id;
private String name;

public int getId() { return id; }
public void setId(int id) { this.id = id; }

public String getName() { return name; }
public void setName(String name) { this.name = name; }
}

/*
/****************************************************************
/* Unit tests
/****************************************************************
*/

private final ObjectMapper MAPPER = new ObjectMapper();

public void testIgnoreOnProperty() throws Exception

// [databind#1217]
public void testIgnoreOnProperty1217() throws Exception
{
TestIgnoreObject result = MAPPER.readValue(
aposToQuotes("{'obj':{'x': 10, 'y': 20}, 'obj2':{'x': 10, 'y': 20}}"),
Expand All @@ -48,7 +65,7 @@ public void testIgnoreOnProperty() throws Exception
assertEquals(2, result1.obj2.y);
}

public void testIgnoreViaConfigOverride() throws Exception
public void testIgnoreViaConfigOverride1217() throws Exception
{
ObjectMapper mapper = new ObjectMapper();
mapper.configOverride(Point.class)
Expand All @@ -58,4 +75,17 @@ public void testIgnoreViaConfigOverride() throws Exception
assertEquals(1, p.x);
assertEquals(0, p.y);
}

// [databind#1595]
public void testIgnoreGetterNotSetter1595() throws Exception
{
ObjectMapper mapper = new ObjectMapper();
Simple1595 config = new Simple1595();
config.setId(123);
config.setName("jack");
String json = mapper.writeValueAsString(config);
assertEquals(aposToQuotes("{'id':123}"), json);
Simple1595 des = mapper.readValue(aposToQuotes("{'id':123,'name':'jack'}"), Simple1595.class);
assertEquals("jack", des.getName());
}
}

This file was deleted.

0 comments on commit 4a2b1ae

Please sign in to comment.