Skip to content

Commit 06e37f3

Browse files
committed
And some more passing of JsonParser for exceptions
1 parent b8482e6 commit 06e37f3

File tree

4 files changed

+55
-25
lines changed

4 files changed

+55
-25
lines changed

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

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -998,14 +998,12 @@ public Object deserializeWithType(JsonParser p, DeserializationContext ctxt,
998998
*
999999
* @since 2.3
10001000
*/
1001-
protected Object _handleTypedObjectId(JsonParser jp, DeserializationContext ctxt,
1001+
protected Object _handleTypedObjectId(JsonParser p, DeserializationContext ctxt,
10021002
Object pojo, Object rawId)
10031003
throws IOException
10041004
{
1005-
/* 07-Aug-2013, tatu: One more challenge: type of id may not be type
1006-
* of property we are expecting later on; specifically, numeric ids
1007-
* vs Strings.
1008-
*/
1005+
// One more challenge: type of id may not be type of property we are expecting
1006+
// later on; specifically, numeric ids vs Strings.
10091007
JsonDeserializer<Object> idDeser = _objectIdReader.getDeserializer();
10101008
final Object id;
10111009

@@ -1014,7 +1012,7 @@ protected Object _handleTypedObjectId(JsonParser jp, DeserializationContext ctxt
10141012
// nope: already same type
10151013
id = rawId;
10161014
} else {
1017-
id = _convertObjectId(jp, ctxt, rawId, idDeser);
1015+
id = _convertObjectId(p, ctxt, rawId, idDeser);
10181016
}
10191017

10201018
ReadableObjectId roid = ctxt.findObjectId(id, _objectIdReader.generator, _objectIdReader.resolver);

src/main/java/com/fasterxml/jackson/databind/exc/IgnoredPropertyException.java

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,28 @@ public class IgnoredPropertyException
1818
{
1919
private static final long serialVersionUID = 1L;
2020

21+
/**
22+
* @since 2.7
23+
*/
24+
public IgnoredPropertyException(JsonParser p, String msg, JsonLocation loc,
25+
Class<?> referringClass, String propName,
26+
Collection<Object> propertyIds)
27+
{
28+
super(p, msg, loc, referringClass, propName, propertyIds);
29+
}
30+
31+
/**
32+
* @deprecated Since 2.7
33+
*/
34+
@Deprecated
2135
public IgnoredPropertyException(String msg, JsonLocation loc,
2236
Class<?> referringClass, String propName,
2337
Collection<Object> propertyIds)
2438
{
2539
super(msg, loc, referringClass, propName, propertyIds);
2640
}
2741

42+
2843
/**
2944
* Factory method used for constructing instances of this exception type.
3045
*
@@ -35,7 +50,7 @@ public IgnoredPropertyException(String msg, JsonLocation loc,
3550
* @param propertyIds (optional, null if not available) Set of properties that
3651
* type would recognize, if completely known: null if set can not be determined.
3752
*/
38-
public static IgnoredPropertyException from(JsonParser jp,
53+
public static IgnoredPropertyException from(JsonParser p,
3954
Object fromObjectOrClass, String propertyName,
4055
Collection<Object> propertyIds)
4156
{
@@ -50,8 +65,8 @@ public static IgnoredPropertyException from(JsonParser jp,
5065
}
5166
String msg = "Ignored field \""+propertyName+"\" (class "+ref.getName()
5267
+") encountered; mapper configured not to allow this";
53-
IgnoredPropertyException e = new IgnoredPropertyException(msg,
54-
jp.getCurrentLocation(), ref, propertyName, propertyIds);
68+
IgnoredPropertyException e = new IgnoredPropertyException(p, msg,
69+
p.getCurrentLocation(), ref, propertyName, propertyIds);
5570
// but let's also ensure path includes this last (missing) segment
5671
e.prependPath(fromObjectOrClass, propertyName);
5772
return e;

src/main/java/com/fasterxml/jackson/databind/exc/PropertyBindingException.java

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import java.util.Iterator;
66

77
import com.fasterxml.jackson.core.JsonLocation;
8+
import com.fasterxml.jackson.core.JsonParser;
89
import com.fasterxml.jackson.databind.JsonMappingException;
910

1011
/**
@@ -28,7 +29,7 @@ public abstract class PropertyBindingException
2829
* reference path.
2930
*/
3031
protected final String _propertyName;
31-
32+
3233
/**
3334
* Set of ids of properties that are known for the type, if this
3435
* can be statically determined.
@@ -40,18 +41,31 @@ public abstract class PropertyBindingException
4041
* constructing actual message if and as needed.
4142
*/
4243
protected transient String _propertiesAsString;
43-
44-
protected PropertyBindingException(String msg, JsonLocation loc,
44+
45+
/**
46+
* @since 2.7
47+
*/
48+
protected PropertyBindingException(JsonParser p, String msg, JsonLocation loc,
4549
Class<?> referringClass, String propName,
4650
Collection<Object> propertyIds)
4751
{
48-
49-
super(msg, loc);
52+
super(p, msg, loc);
5053
_referringClass = referringClass;
5154
_propertyName = propName;
5255
_propertyIds = propertyIds;
5356
}
5457

58+
/**
59+
* @deprecated Since 2.7
60+
*/
61+
@Deprecated // since 2.7
62+
protected PropertyBindingException(String msg, JsonLocation loc,
63+
Class<?> referringClass, String propName,
64+
Collection<Object> propertyIds)
65+
{
66+
this(null, msg, loc, referringClass, propName, propertyIds);
67+
}
68+
5569
/*
5670
/**********************************************************
5771
/* Overrides

src/main/java/com/fasterxml/jackson/databind/exc/UnrecognizedPropertyException.java

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,17 @@ public class UnrecognizedPropertyException
1717
{
1818
private static final long serialVersionUID = 1L;
1919

20+
public UnrecognizedPropertyException(JsonParser p, String msg, JsonLocation loc,
21+
Class<?> referringClass, String propName,
22+
Collection<Object> propertyIds)
23+
{
24+
super(p, msg, loc, referringClass, propName, propertyIds);
25+
}
26+
27+
/**
28+
* @deprecated Since 2.7
29+
*/
30+
@Deprecated // since 2.7
2031
public UnrecognizedPropertyException(String msg, JsonLocation loc,
2132
Class<?> referringClass, String propName,
2233
Collection<Object> propertyIds)
@@ -34,7 +45,7 @@ public UnrecognizedPropertyException(String msg, JsonLocation loc,
3445
* @param propertyIds (optional, null if not available) Set of properties that
3546
* type would recognize, if completely known: null if set can not be determined.
3647
*/
37-
public static UnrecognizedPropertyException from(JsonParser jp,
48+
public static UnrecognizedPropertyException from(JsonParser p,
3849
Object fromObjectOrClass, String propertyName,
3950
Collection<Object> propertyIds)
4051
{
@@ -48,18 +59,10 @@ public static UnrecognizedPropertyException from(JsonParser jp,
4859
ref = fromObjectOrClass.getClass();
4960
}
5061
String msg = "Unrecognized field \""+propertyName+"\" (class "+ref.getName()+"), not marked as ignorable";
51-
UnrecognizedPropertyException e = new UnrecognizedPropertyException(msg,
52-
jp.getCurrentLocation(), ref, propertyName, propertyIds);
62+
UnrecognizedPropertyException e = new UnrecognizedPropertyException(p, msg,
63+
p.getCurrentLocation(), ref, propertyName, propertyIds);
5364
// but let's also ensure path includes this last (missing) segment
5465
e.prependPath(fromObjectOrClass, propertyName);
5566
return e;
5667
}
57-
58-
/**
59-
* @deprecated Since 2.3, use {@link #getPropertyName} instead.
60-
*/
61-
@Deprecated // since 2.3
62-
public String getUnrecognizedPropertyName() {
63-
return getPropertyName();
64-
}
6568
}

0 commit comments

Comments
 (0)