Skip to content

Commit

Permalink
Fix #1493
Browse files Browse the repository at this point in the history
  • Loading branch information
cowtowncoder committed Jan 10, 2017
1 parent 7fe2d4f commit d7155de
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 43 deletions.
2 changes: 1 addition & 1 deletion release-notes/VERSION
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
Project: jackson-databind

------------------------------------------------------------------------
=== Releases ===
------------------------------------------------------------------------
Expand All @@ -17,6 +16,7 @@ Project: jackson-databind
#1456: `TypeFactory` type resolution broken in 2.7 for generic types
when using `constructType` with context
#1473: Add explicit deserializer for `StringBuilder` due to Java 9 changes
#1493: `ACCEPT_CASE_INSENSITIVE_PROPERTIES` fails with `@JsonUnwrapped`

2.8.5 (14-Nov-2016)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ public BeanPropertyMap withCaseInsensitivity(boolean state) {
protected void init(Collection<SettableBeanProperty> props)
{
_size = props.size();

// First: calculate size of primary hash area
final int hashSize = findSize(_size);
_hashMask = hashSize-1;
Expand Down Expand Up @@ -423,7 +423,8 @@ private final SettableBeanProperty _find2(String key, int slot, Object match)
* Specialized method for removing specified existing entry.
* NOTE: entry MUST exist, otherwise an exception is thrown.
*/
public void remove(SettableBeanProperty propToRm) {
public void remove(SettableBeanProperty propToRm)
{
ArrayList<SettableBeanProperty> props = new ArrayList<SettableBeanProperty>(_size);
String key = getPropertyName(propToRm);
boolean found = false;
Expand All @@ -434,7 +435,9 @@ public void remove(SettableBeanProperty propToRm) {
continue;
}
if (!found) {
found = key.equals(prop.getName());
// 09-Jan-2017, tatu: Important: must check name slot and NOT property name,
// as only former is lower-case in case-insensitive case
found = key.equals(_hashArea[i-1]);
if (found) {
// need to leave a hole here
_propsInOrder[_findFromOrdered(prop)] = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,20 @@ static class Outer {
private Inner inner;
}

// [databind#1493]: case-insensitive handling
static class Person {
@JsonUnwrapped(prefix = "businessAddress.")
public Address businessAddress;
}

static class Address {
public String street;
public String addon;
public String zip;
public String town;
public String country;
}

/*
/**********************************************************
/* Tests, serialization
Expand Down Expand Up @@ -192,45 +206,13 @@ public void testUnwrappedAsPropertyIndicator() throws Exception
assertTrue(actual.contains("Zebra"));
assertFalse(actual.contains("inner"));
}

// 22-Apr-2013, tatu: Commented out as it can't be simply fixed; requires implementing
// deep-update/merge. But leaving here to help with that effort, if/when it proceeds.

/*
// [databind#211]: Actually just variant of #160
static class Issue211Bean {
public String test1;
public String test2;
@JsonUnwrapped
public Issue211Unwrapped unwrapped;
}

static class Issue211Unwrapped {
public String test3;
public String test4;
}
public void testIssue211() throws Exception
// [databind#1493]: case-insensitive handling
public void testCaseInsensitiveUnwrap() throws Exception
{
Issue211Bean bean = new Issue211Bean();
bean.test1 = "Field 1";
bean.test2 = "Field 2";
Issue211Unwrapped tJackson2 = new Issue211Unwrapped();
tJackson2.test3 = "Field 3";
tJackson2.test4 = "Field 4";
bean.unwrapped = tJackson2;
final String JSON = "{\"test1\": \"Field 1 merged\", \"test3\": \"Field 3 merged\"}";
ObjectMapper o = new ObjectMapper();
Issue211Bean result = o.readerForUpdating(bean).withType(Issue211Bean.class).readValue(JSON);
assertSame(bean, result);
assertEquals("Field 1 merged", result.test1);
assertEquals("Field 2", result.test2);
assertNotNull(result.unwrapped);
assertEquals("Field 3 merged", result.unwrapped.test3);
assertEquals("Field 4", result.unwrapped.test4);
}
*/
ObjectMapper mapper = new ObjectMapper();
mapper.enable(MapperFeature.ACCEPT_CASE_INSENSITIVE_PROPERTIES);
Person p = mapper.readValue("{ }", Person.class);
assertNotNull(p);
}
}

0 comments on commit d7155de

Please sign in to comment.