Skip to content

Commit 726b6e0

Browse files
committed
Fixed #844
1 parent 9317e54 commit 726b6e0

File tree

3 files changed

+26
-11
lines changed

3 files changed

+26
-11
lines changed

release-notes/CREDITS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,8 @@ Steve Sanbeg: (sanbeg@github)
149149
Ian Barfield: (tea-dragon@github)
150150
* Reported #580: delegate deserializers choke on a (single) abstract/polymorphic parameter
151151
(2.4.4)
152+
* Reported #844: Using JsonCreator still causes invalid path references in JsonMappingException
153+
(2.5.5)
152154

153155
Eugene Lukash
154156
* Reported #592: Wrong `TokenBuffer` delegate deserialization using `@JsonCreator`

release-notes/VERSION

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ Project: jackson-databind
66

77
2.5.5 (not released)
88

9+
#844: Using JsonCreator still causes invalid path references in JsonMappingException
10+
(reported by Ian B)
911
#852: Accept scientific number notation for quoted numbers too
1012

1113
2.5.4 (09-Jun-2015)

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

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -385,7 +385,7 @@ protected Object _deserializeUsingPropertyBased(final JsonParser p, final Deseri
385385
try {
386386
bean = creator.build(ctxt, buffer);
387387
} catch (Exception e) {
388-
wrapAndThrow(e, _beanType.getRawClass(), propName, ctxt);
388+
wrapInstantiationProblem(e, ctxt);
389389
bean = null; // never gets here
390390
}
391391
if (bean == null) {
@@ -413,7 +413,8 @@ protected Object _deserializeUsingPropertyBased(final JsonParser p, final Deseri
413413
// regular property? needs buffering
414414
SettableBeanProperty prop = _beanProperties.find(propName);
415415
if (prop != null) {
416-
buffer.bufferProperty(prop, prop.deserialize(p, ctxt));
416+
buffer.bufferProperty(prop,
417+
deserializeWithErrorWrapping(prop, p, ctxt, propName));
417418
continue;
418419
}
419420
// As per [JACKSON-313], things marked as ignorable should not be
@@ -424,7 +425,11 @@ protected Object _deserializeUsingPropertyBased(final JsonParser p, final Deseri
424425
}
425426
// "any property"?
426427
if (_anySetter != null) {
427-
buffer.bufferAnyProperty(_anySetter, propName, _anySetter.deserialize(p, ctxt));
428+
try {
429+
buffer.bufferAnyProperty(_anySetter, propName, _anySetter.deserialize(p, ctxt));
430+
} catch (Exception e) {
431+
wrapAndThrow(e, _beanType.getRawClass(), propName, ctxt);
432+
}
428433
continue;
429434
}
430435
// Ok then, let's collect the whole field; name and value
@@ -454,11 +459,11 @@ protected Object _deserializeUsingPropertyBased(final JsonParser p, final Deseri
454459
return bean;
455460
}
456461

457-
protected Object deserializeWithErrorWrapping(SettableBeanProperty creatorProp, JsonParser p, DeserializationContext ctxt,
458-
String propName)
459-
throws IOException {
462+
protected Object deserializeWithErrorWrapping(SettableBeanProperty prop,
463+
JsonParser p, DeserializationContext ctxt, String propName) throws IOException
464+
{
460465
try {
461-
return creatorProp.deserialize(p, ctxt);
466+
return prop.deserialize(p, ctxt);
462467
} catch (IOException e) {
463468
wrapAndThrow(e, _beanType.getRawClass(), propName, ctxt);
464469
// exception below will be throw only if someone overwrite default implementation of wrapAndThrow method
@@ -639,7 +644,7 @@ protected Object deserializeUsingPropertyBasedWithUnwrapped(JsonParser p, Deseri
639644
try {
640645
bean = creator.build(ctxt, buffer);
641646
} catch (Exception e) {
642-
wrapAndThrow(e, _beanType.getRawClass(), propName, ctxt);
647+
wrapInstantiationProblem(e, ctxt);
643648
continue; // never gets here
644649
}
645650
// [databind#631]: Assign current value, to be accessible by custom serializers
@@ -668,9 +673,11 @@ protected Object deserializeUsingPropertyBasedWithUnwrapped(JsonParser p, Deseri
668673
// regular property? needs buffering
669674
SettableBeanProperty prop = _beanProperties.find(propName);
670675
if (prop != null) {
671-
buffer.bufferProperty(prop, prop.deserialize(p, ctxt));
676+
buffer.bufferProperty(prop,
677+
deserializeWithErrorWrapping(prop, p, ctxt, propName));
672678
continue;
673679
}
680+
674681
/* As per [JACKSON-313], things marked as ignorable should not be
675682
* passed to any setter
676683
*/
@@ -682,14 +689,18 @@ protected Object deserializeUsingPropertyBasedWithUnwrapped(JsonParser p, Deseri
682689
tokens.copyCurrentStructure(p);
683690
// "any property"?
684691
if (_anySetter != null) {
685-
buffer.bufferAnyProperty(_anySetter, propName, _anySetter.deserialize(p, ctxt));
692+
try {
693+
buffer.bufferAnyProperty(_anySetter, propName, _anySetter.deserialize(p, ctxt));
694+
} catch (Exception e) {
695+
wrapAndThrow(e, _beanType.getRawClass(), propName, ctxt);
696+
}
686697
}
687698
}
688699

689700
// We hit END_OBJECT, so:
690701
Object bean;
691702
try {
692-
bean = creator.build(ctxt, buffer);
703+
bean = creator.build(ctxt, buffer);
693704
} catch (Exception e) {
694705
wrapInstantiationProblem(e, ctxt);
695706
return null; // never gets here

0 commit comments

Comments
 (0)