Skip to content

Commit

Permalink
Fix #1878
Browse files Browse the repository at this point in the history
  • Loading branch information
cowtowncoder committed Jan 17, 2018
1 parent 8cfe3ee commit 4e71662
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 12 deletions.
2 changes: 2 additions & 0 deletions release-notes/VERSION-2.x
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ Project: jackson-databind
#1870: Remove `final` on inherited methods in `BuilderBasedDeserializer` to allow
overriding by subclasses
(requested by Ville K)
#1878: `@JsonBackReference` property is always ignored when deserializing since 2.9.0
(reported by reda-alaoui@github)

2.9.3 (09-Dec-2017)

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

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

import com.fasterxml.jackson.annotation.JsonBackReference;
import com.fasterxml.jackson.annotation.JsonManagedReference;

import com.fasterxml.jackson.databind.BaseMapTest;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;

/**
* Created on 09/01/18.
*
* @author Reda.Housni-Alaoui
*/
public class BackReference1878Test extends BaseMapTest {

public class BackReference1878Test extends BaseMapTest
{
static class Child {
@JsonBackReference
public Parent b;
Expand All @@ -26,9 +24,7 @@ static class Parent {
private final ObjectMapper MAPPER = new ObjectMapper();

public void testChildDeserialization() throws Exception {
MAPPER.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
Child child = MAPPER.readValue("{\"b\": {}}", Child.class);
assertNotNull(child.b);
}

}

0 comments on commit 4e71662

Please sign in to comment.