Skip to content

Commit 2684f15

Browse files
committed
Merge branch '2.8'
2 parents dee8ba9 + 8b4a4cd commit 2684f15

File tree

7 files changed

+50
-38
lines changed

7 files changed

+50
-38
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -515,7 +515,7 @@ public void resolve(DeserializationContext ctxt)
515515
// Need to link managed references with matching back references
516516
prop = _resolveManagedReferenceProperty(ctxt, prop);
517517

518-
// [databind#351[: need to wrap properties that require object id resolution.
518+
// [databind#351]: need to wrap properties that require object id resolution.
519519
if (!(prop instanceof ManagedReferenceProperty)) {
520520
prop = _resolvedObjectIdProperty(ctxt, prop);
521521
}

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

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,10 @@ public void addBackReferenceProperty(String referenceName, SettableBeanProperty
183183
if (_backRefProperties == null) {
184184
_backRefProperties = new HashMap<String, SettableBeanProperty>(4);
185185
}
186+
// 15-Sep-2016, tatu: For some reason fixing access at point of `build()` does
187+
// NOT work (2 failing unit tests). Not 100% clear why, but for now force
188+
// access set early; unfortunate, but since it works....
189+
prop.fixAccess(_config);
186190
_backRefProperties.put(referenceName, prop);
187191
// also: if we had property with same name, actually remove it
188192
if (_properties != null) {
@@ -207,7 +211,7 @@ public void addInjectable(PropertyName propName, JavaType propType,
207211
_injectables.add(new ValueInjector(propName, propType,
208212
contextAnnotations, member, valueId));
209213
}
210-
214+
211215
/**
212216
* Method that will add property name as one of properties that can
213217
* be ignored if not recognized.
@@ -462,11 +466,15 @@ private void _fixAccess(Collection<SettableBeanProperty> mainProps)
462466
*/
463467
prop.fixAccess(_config);
464468
}
469+
// 15-Sep-2016, tatu: Access via back-ref properties has been done earlier
470+
// as it has to, for some reason, so not repeated here.
471+
/*
465472
if (_backRefProperties != null) {
466473
for (SettableBeanProperty prop : _backRefProperties.values()) {
467474
prop.fixAccess(_config);
468475
}
469476
}
477+
*/
470478
if (_anySetter != null) {
471479
_anySetter.fixAccess(_config);
472480
}

src/main/java/com/fasterxml/jackson/databind/deser/impl/FieldProperty.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ public final void set(Object instance, Object value) throws IOException
132132
try {
133133
_field.set(instance, value);
134134
} catch (Exception e) {
135-
// 15-Sep-2015, tatu: How coud we get a ref to JsonParser?
135+
// 15-Sep-2015, tatu: How could we get a ref to JsonParser?
136136
_throwAsIOE(e, value);
137137
}
138138
}
@@ -143,7 +143,7 @@ public Object setAndReturn(Object instance, Object value) throws IOException
143143
try {
144144
_field.set(instance, value);
145145
} catch (Exception e) {
146-
// 15-Sep-2015, tatu: How coud we get a ref to JsonParser?
146+
// 15-Sep-2015, tatu: How could we get a ref to JsonParser?
147147
_throwAsIOE(e, value);
148148
}
149149
return instance;

src/main/java/com/fasterxml/jackson/databind/deser/impl/ManagedReferenceProperty.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,17 +22,17 @@ public final class ManagedReferenceProperty
2222
private static final long serialVersionUID = 1L;
2323

2424
protected final String _referenceName;
25-
25+
2626
/**
2727
* Flag that indicates whether property to handle is a container type
2828
* (array, Collection, Map) or not.
2929
*/
3030
protected final boolean _isContainer;
31-
31+
3232
protected final SettableBeanProperty _managedProperty;
3333

3434
protected final SettableBeanProperty _backProperty;
35-
35+
3636
public ManagedReferenceProperty(SettableBeanProperty forward, String refName,
3737
SettableBeanProperty backward, Annotations contextAnnotations, boolean isContainer)
3838
{
@@ -66,7 +66,7 @@ protected ManagedReferenceProperty(ManagedReferenceProperty src, PropertyName ne
6666
public ManagedReferenceProperty withName(PropertyName newName) {
6767
return new ManagedReferenceProperty(this, newName);
6868
}
69-
69+
7070
@Override
7171
public ManagedReferenceProperty withValueDeserializer(JsonDeserializer<?> deser) {
7272
return new ManagedReferenceProperty(this, deser);
@@ -83,7 +83,7 @@ public void fixAccess(DeserializationConfig config) {
8383
/* BeanProperty impl
8484
/**********************************************************
8585
*/
86-
86+
8787
@Override
8888
public <A extends Annotation> A getAnnotation(Class<A> acls) {
8989
return _managedProperty.getAnnotation(acls);

src/main/java/com/fasterxml/jackson/databind/deser/impl/MethodProperty.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ public Object deserializeSetAndReturn(JsonParser p,
119119
return null;
120120
}
121121
}
122-
122+
123123
@Override
124124
public final void set(Object instance, Object value) throws IOException
125125
{

src/main/java/com/fasterxml/jackson/databind/util/ClassUtil.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -979,7 +979,6 @@ public static Ctor[] getConstructors(Class<?> cls) {
979979
* @since 2.7
980980
*/
981981
public static Class<?> getDeclaringClass(Class<?> cls) {
982-
// Caching does not seem worthwhile, as per profiling
983982
return isObjectOrPrimitive(cls) ? null : cls.getDeclaringClass();
984983
}
985984

src/test/java/com/fasterxml/jackson/databind/struct/TestBackRefsWithPolymorphic.java

Lines changed: 32 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -12,33 +12,6 @@
1212
// Unit test for [JACKSON-890]
1313
public class TestBackRefsWithPolymorphic extends BaseMapTest
1414
{
15-
private final String CLASS_NAME = getClass().getName();
16-
17-
// NOTE: order is arbitrary, test is fragile... has to work for now
18-
private final String JSON =
19-
"{\"@class\":\""+CLASS_NAME+"$PropertySheetImpl\",\"id\":0,\"properties\":{\"p1name\":{\"@class\":"
20-
+"\"" +CLASS_NAME+ "$StringPropertyImpl\",\"id\":0,\"name\":\"p1name\",\"value\":\"p1value\"},"
21-
+"\"p2name\":{\"@class\":\""+CLASS_NAME+"$StringPropertyImpl\",\"id\":0,"
22-
+"\"name\":\"p2name\",\"value\":\"p2value\"}}}";
23-
24-
private final ObjectMapper MAPPER = new ObjectMapper();
25-
26-
public void testDeserialize() throws IOException
27-
{
28-
PropertySheet input = MAPPER.readValue(JSON, PropertySheet.class);
29-
assertEquals(JSON, MAPPER.writeValueAsString(input));
30-
}
31-
32-
public void testSerialize() throws IOException
33-
{
34-
PropertySheet sheet = new PropertySheetImpl();
35-
36-
sheet.addProperty(new StringPropertyImpl("p1name", "p1value"));
37-
sheet.addProperty(new StringPropertyImpl("p2name", "p2value"));
38-
String actual = MAPPER.writeValueAsString(sheet);
39-
assertEquals(JSON, actual);
40-
}
41-
4215
@JsonPropertyOrder(alphabetic=true)
4316
interface Entity
4417
{
@@ -217,4 +190,36 @@ public StringPropertyImpl(String name, String value) {
217190
}
218191

219192
static class YetAnotherClass extends StringPropertyImpl { }
193+
194+
/*
195+
/**********************************************************
196+
/* Test methods
197+
/**********************************************************
198+
*/
199+
200+
private final String CLASS_NAME = getClass().getName();
201+
// NOTE: order is arbitrary, test is fragile... has to work for now
202+
private final String JSON =
203+
"{\"@class\":\""+CLASS_NAME+"$PropertySheetImpl\",\"id\":0,\"properties\":{\"p1name\":{\"@class\":"
204+
+"\"" +CLASS_NAME+ "$StringPropertyImpl\",\"id\":0,\"name\":\"p1name\",\"value\":\"p1value\"},"
205+
+"\"p2name\":{\"@class\":\""+CLASS_NAME+"$StringPropertyImpl\",\"id\":0,"
206+
+"\"name\":\"p2name\",\"value\":\"p2value\"}}}";
207+
208+
private final ObjectMapper MAPPER = new ObjectMapper();
209+
210+
public void testDeserialize() throws IOException
211+
{
212+
PropertySheet input = MAPPER.readValue(JSON, PropertySheet.class);
213+
assertEquals(JSON, MAPPER.writeValueAsString(input));
214+
}
215+
216+
public void testSerialize() throws IOException
217+
{
218+
PropertySheet sheet = new PropertySheetImpl();
219+
220+
sheet.addProperty(new StringPropertyImpl("p1name", "p1value"));
221+
sheet.addProperty(new StringPropertyImpl("p2name", "p2value"));
222+
String actual = MAPPER.writeValueAsString(sheet);
223+
assertEquals(JSON, actual);
224+
}
220225
}

0 commit comments

Comments
 (0)