Fix #1493
diff --git a/release-notes/VERSION b/release-notes/VERSION
index d804987..b36d662 100644
--- a/release-notes/VERSION
+++ b/release-notes/VERSION
@@ -1,5 +1,4 @@
Project: jackson-databind
-
------------------------------------------------------------------------
=== Releases ===
------------------------------------------------------------------------
@@ -17,6 +16,7 @@
#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)
diff --git a/src/main/java/com/fasterxml/jackson/databind/deser/impl/BeanPropertyMap.java b/src/main/java/com/fasterxml/jackson/databind/deser/impl/BeanPropertyMap.java
index fd30aaf..8031ee0 100644
--- a/src/main/java/com/fasterxml/jackson/databind/deser/impl/BeanPropertyMap.java
+++ b/src/main/java/com/fasterxml/jackson/databind/deser/impl/BeanPropertyMap.java
@@ -92,7 +92,7 @@
protected void init(Collection<SettableBeanProperty> props)
{
_size = props.size();
-
+
// First: calculate size of primary hash area
final int hashSize = findSize(_size);
_hashMask = hashSize-1;
@@ -423,7 +423,8 @@
* 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;
@@ -434,7 +435,9 @@
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;
diff --git a/src/test/java/com/fasterxml/jackson/databind/struct/TestUnwrapped.java b/src/test/java/com/fasterxml/jackson/databind/struct/TestUnwrapped.java
index 59ac4e0..dd373f6 100644
--- a/src/test/java/com/fasterxml/jackson/databind/struct/TestUnwrapped.java
+++ b/src/test/java/com/fasterxml/jackson/databind/struct/TestUnwrapped.java
@@ -97,6 +97,20 @@
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
@@ -192,45 +206,13 @@
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);
}
- */
}