Skip to content

Commit 4e71662

Browse files
committed
Fix #1878
1 parent 8cfe3ee commit 4e71662

File tree

3 files changed

+13
-12
lines changed

3 files changed

+13
-12
lines changed

release-notes/VERSION-2.x

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ Project: jackson-databind
2020
#1870: Remove `final` on inherited methods in `BuilderBasedDeserializer` to allow
2121
overriding by subclasses
2222
(requested by Ville K)
23+
#1878: `@JsonBackReference` property is always ignored when deserializing since 2.9.0
24+
(reported by reda-alaoui@github)
2325

2426
2.9.3 (09-Dec-2017)
2527

src/main/java/com/fasterxml/jackson/databind/deser/BeanDeserializerBuilder.java

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -195,12 +195,15 @@ public void addBackReferenceProperty(String referenceName, SettableBeanProperty
195195
// access set early; unfortunate, but since it works....
196196
prop.fixAccess(_config);
197197
_backRefProperties.put(referenceName, prop);
198-
// also: if we had property with same name, actually remove it
198+
// 16-Jan-2018, tatu: As per [databind#1878] we may want to leave it as is, to allow
199+
// population for cases of "wrong direction", traversing parent first
200+
// If this causes problems should probably instead include in "ignored properties" list
201+
// Alternatively could also extend annotation to allow/disallow explicit value from input
202+
/*
199203
if (_properties != null) {
200-
_properties.remove(referenceName);
204+
_properties.remove(prop.getName());
201205
}
202-
// ??? 23-Jul-2012, tatu: Should it be included in list of all properties?
203-
// For now, won't add, since it is inferred, not explicit...
206+
*/
204207
}
205208

206209
public void addInjectable(PropertyName propName, JavaType propType,
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,16 @@
1-
package com.fasterxml.jackson.failing;
1+
package com.fasterxml.jackson.databind.struct;
22

33
import com.fasterxml.jackson.annotation.JsonBackReference;
44
import com.fasterxml.jackson.annotation.JsonManagedReference;
5+
56
import com.fasterxml.jackson.databind.BaseMapTest;
6-
import com.fasterxml.jackson.databind.DeserializationFeature;
77
import com.fasterxml.jackson.databind.ObjectMapper;
88

99
/**
10-
* Created on 09/01/18.
11-
*
1210
* @author Reda.Housni-Alaoui
1311
*/
14-
public class BackReference1878Test extends BaseMapTest {
15-
12+
public class BackReference1878Test extends BaseMapTest
13+
{
1614
static class Child {
1715
@JsonBackReference
1816
public Parent b;
@@ -26,9 +24,7 @@ static class Parent {
2624
private final ObjectMapper MAPPER = new ObjectMapper();
2725

2826
public void testChildDeserialization() throws Exception {
29-
MAPPER.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
3027
Child child = MAPPER.readValue("{\"b\": {}}", Child.class);
3128
assertNotNull(child.b);
3229
}
33-
3430
}

0 commit comments

Comments
 (0)