Skip to content

Commit 388b7dc

Browse files
committed
More warnings removal (3.0-proofing)
1 parent bd7dae5 commit 388b7dc

14 files changed

+50
-31
lines changed

release-notes/VERSION-2.x

+2
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ Project: jackson-databind
66

77
2.17.0 (not yet released)
88

9+
#4160: Deprecate `DefaultTyping.EVERYTHING` in `2.x` and remove in `3.0`
10+
(contributed by Joo-Hyuk K)
911
#4194: Add `JsonNodeFeature.FAIL_ON_NAN_TO_BIG_DECIMAL_COERCION` option to
1012
fail on attempting to coerce `NaN` into `BigDecimal`
1113
(contributed by Joo-Hyuk K)

src/main/java/com/fasterxml/jackson/databind/JsonMappingException.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ public JsonMappingException(Closeable processor, String msg) {
236236
// 17-Aug-2015, tatu: Use of token location makes some sense from databinding,
237237
// since actual parsing (current) location is typically only needed for low-level
238238
// parsing exceptions.
239-
_location = ((JsonParser) processor).getTokenLocation();
239+
_location = ((JsonParser) processor).currentTokenLocation();
240240
}
241241
}
242242

@@ -250,7 +250,7 @@ public JsonMappingException(Closeable processor, String msg, Throwable problem)
250250
if (problem instanceof JacksonException) {
251251
_location = ((JacksonException) problem).getLocation();
252252
} else if (processor instanceof JsonParser) {
253-
_location = ((JsonParser) processor).getTokenLocation();
253+
_location = ((JsonParser) processor).currentTokenLocation();
254254
}
255255
}
256256

src/main/java/com/fasterxml/jackson/databind/MappingIterator.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,7 @@ public FormatSchema getParserSchema() {
376376
* @since 2.2.1
377377
*/
378378
public JsonLocation getCurrentLocation() {
379-
return _parser.getCurrentLocation();
379+
return _parser.currentLocation();
380380
}
381381

382382
/*

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,7 @@ protected Object _deserializeFromObjectId(JsonParser p, DeserializationContext c
331331
Object pojo = roid.resolve();
332332
if (pojo == null) { // not yet; should wait...
333333
throw new UnresolvedForwardReference(p,
334-
"Could not resolve Object Id ["+id+"] -- unresolved forward-reference?", p.getCurrentLocation(), roid);
334+
"Could not resolve Object Id ["+id+"] -- unresolved forward-reference?", p.currentLocation(), roid);
335335
}
336336
return pojo;
337337
}

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

+6-6
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ protected final Object _deserializeOther(JsonParser p, DeserializationContext ct
233233
public Object deserialize(JsonParser p, DeserializationContext ctxt, Object bean) throws IOException
234234
{
235235
// [databind#631]: Assign current value, to be accessible by custom serializers
236-
p.setCurrentValue(bean);
236+
p.assignCurrentValue(bean);
237237
if (_injectables != null) {
238238
injectValues(ctxt, bean);
239239
}
@@ -299,7 +299,7 @@ private final Object vanillaDeserialize(JsonParser p,
299299
if (p.hasTokenId(JsonTokenId.ID_FIELD_NAME)) {
300300
// [databind#631]: Assign current value, to be accessible by custom serializers
301301
// [databind#4184]: but only if we have at least one property
302-
p.setCurrentValue(bean);
302+
p.assignCurrentValue(bean);
303303
String propName = p.currentName();
304304
do {
305305
p.nextToken();
@@ -362,7 +362,7 @@ public Object deserializeFromObject(JsonParser p, DeserializationContext ctxt) t
362362
}
363363
final Object bean = _valueInstantiator.createUsingDefault(ctxt);
364364
// [databind#631]: Assign current value, to be accessible by custom deserializers
365-
p.setCurrentValue(bean);
365+
p.assignCurrentValue(bean);
366366
if (p.canReadObjectId()) {
367367
Object id = p.getObjectId();
368368
if (id != null) {
@@ -451,7 +451,7 @@ protected Object _deserializeUsingPropertyBased(final JsonParser p, final Deseri
451451
_creatorReturnedNullException());
452452
}
453453
// [databind#631]: Assign current value, to be accessible by custom serializers
454-
p.setCurrentValue(bean);
454+
p.assignCurrentValue(bean);
455455

456456
// polymorphic?
457457
if (bean.getClass() != _beanType.getRawClass()) {
@@ -713,7 +713,7 @@ protected Object deserializeWithUnwrapped(JsonParser p, DeserializationContext c
713713
final Object bean = _valueInstantiator.createUsingDefault(ctxt);
714714

715715
// [databind#631]: Assign current value, to be accessible by custom serializers
716-
p.setCurrentValue(bean);
716+
p.assignCurrentValue(bean);
717717

718718
if (_injectables != null) {
719719
injectValues(ctxt, bean);
@@ -860,7 +860,7 @@ protected Object deserializeUsingPropertyBasedWithUnwrapped(JsonParser p, Deseri
860860
bean = wrapInstantiationProblem(e, ctxt);
861861
}
862862
// [databind#631]: Assign current value, to be accessible by custom serializers
863-
p.setCurrentValue(bean);
863+
p.assignCurrentValue(bean);
864864
// if so, need to copy all remaining tokens into buffer
865865
while (t == JsonToken.FIELD_NAME) {
866866
// NOTE: do NOT skip name as it needs to be copied; `copyCurrentStructure` does that

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -1472,7 +1472,7 @@ protected Object deserializeFromObjectId(JsonParser p, DeserializationContext ct
14721472
if (pojo == null) { // not yet; should wait...
14731473
throw new UnresolvedForwardReference(p,
14741474
"Could not resolve Object Id ["+id+"] (for "+_beanType+").",
1475-
p.getCurrentLocation(), roid);
1475+
p.currentLocation(), roid);
14761476
}
14771477
return pojo;
14781478
}

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

+4-4
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ public Object deserialize(JsonParser p, DeserializationContext ctxt)
109109
}
110110
final Object bean = _valueInstantiator.createUsingDefault(ctxt);
111111
// [databind#631]: Assign current value, to be accessible by custom serializers
112-
p.setCurrentValue(bean);
112+
p.assignCurrentValue(bean);
113113

114114
final SettableBeanProperty[] props = _orderedProperties;
115115
int i = 0;
@@ -152,7 +152,7 @@ public Object deserialize(JsonParser p, DeserializationContext ctxt, Object bean
152152
throws IOException
153153
{
154154
// [databind#631]: Assign current value, to be accessible by custom serializers
155-
p.setCurrentValue(bean);
155+
p.assignCurrentValue(bean);
156156

157157
if (!p.isExpectedStartArrayToken()) {
158158
return _deserializeFromNonArray(p, ctxt);
@@ -227,7 +227,7 @@ protected Object _deserializeNonVanilla(JsonParser p, DeserializationContext ctx
227227
}
228228
final Object bean = _valueInstantiator.createUsingDefault(ctxt);
229229
// [databind#631]: Assign current value, to be accessible by custom serializers
230-
p.setCurrentValue(bean);
230+
p.assignCurrentValue(bean);
231231
if (_injectables != null) {
232232
injectValues(ctxt, bean);
233233
}
@@ -330,7 +330,7 @@ protected final Object _deserializeUsingPropertyBased(final JsonParser p, final
330330
continue; // never gets here
331331
}
332332
// [databind#631]: Assign current value, to be accessible by custom serializers
333-
p.setCurrentValue(bean);
333+
p.assignCurrentValue(bean);
334334

335335
// polymorphic?
336336
if (bean.getClass() != _beanType.getRawClass()) {

src/main/java/com/fasterxml/jackson/databind/deser/std/CollectionDeserializer.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,7 @@ protected Collection<Object> _deserializeFromArray(JsonParser p, Deserialization
338338
throws IOException
339339
{
340340
// [databind#631]: Assign current value, to be accessible by custom serializers
341-
p.setCurrentValue(result);
341+
p.assignCurrentValue(result);
342342

343343
JsonDeserializer<Object> valueDes = _valueDeserializer;
344344
// Let's offline handling of values with Object Ids (simplifies code here)
@@ -433,7 +433,7 @@ protected Collection<Object> _deserializeWithObjectId(JsonParser p, Deserializat
433433
return handleNonArray(p, ctxt, result);
434434
}
435435
// [databind#631]: Assign current value, to be accessible by custom serializers
436-
p.setCurrentValue(result);
436+
p.assignCurrentValue(result);
437437

438438
final JsonDeserializer<Object> valueDes = _valueDeserializer;
439439
final TypeDeserializer typeDeser = _valueTypeDeserializer;

src/main/java/com/fasterxml/jackson/databind/deser/std/EnumMapDeserializer.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ public EnumMap<?,?> deserialize(JsonParser p, DeserializationContext ctxt,
267267
throws IOException
268268
{
269269
// [databind#631]: Assign current value, to be accessible by custom deserializers
270-
p.setCurrentValue(result);
270+
p.assignCurrentValue(result);
271271

272272
final JsonDeserializer<Object> valueDes = _valueDeserializer;
273273
final TypeDeserializer typeDeser = _valueTypeDeserializer;

src/main/java/com/fasterxml/jackson/databind/deser/std/MapDeserializer.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -467,7 +467,7 @@ public Map<Object,Object> deserialize(JsonParser p, DeserializationContext ctxt,
467467
throws IOException
468468
{
469469
// [databind#631]: Assign current value, to be accessible by custom deserializers
470-
p.setCurrentValue(result);
470+
p.assignCurrentValue(result);
471471

472472
// Ok: must point to START_OBJECT or FIELD_NAME
473473
JsonToken t = p.currentToken();

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ public static IgnoredPropertyException from(JsonParser p,
6262
String msg = String.format("Ignored field \"%s\" (class %s) encountered; mapper configured not to allow this",
6363
propertyName, ref.getName());
6464
IgnoredPropertyException e = new IgnoredPropertyException(p, msg,
65-
p.getCurrentLocation(), ref, propertyName, propertyIds);
65+
p.currentLocation(), ref, propertyName, propertyIds);
6666
// but let's also ensure path includes this last (missing) segment
6767
e.prependPath(fromObjectOrClass, propertyName);
6868
return e;

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public static UnrecognizedPropertyException from(JsonParser p,
5858
String msg = String.format("Unrecognized field \"%s\" (class %s), not marked as ignorable",
5959
propertyName, ref.getName());
6060
UnrecognizedPropertyException e = new UnrecognizedPropertyException(p, msg,
61-
p.getCurrentLocation(), ref, propertyName, propertyIds);
61+
p.currentLocation(), ref, propertyName, propertyIds);
6262
// but let's also ensure path includes this last (missing) segment
6363
e.prependPath(fromObjectOrClass, propertyName);
6464
return e;

src/main/java/com/fasterxml/jackson/databind/node/TreeTraversingParser.java

+10-2
Original file line numberDiff line numberDiff line change
@@ -176,15 +176,23 @@ public JsonStreamContext getParsingContext() {
176176
}
177177

178178
@Override
179-
public JsonLocation getTokenLocation() {
179+
public JsonLocation currentLocation() {
180180
return JsonLocation.NA;
181181
}
182182

183183
@Override
184-
public JsonLocation getCurrentLocation() {
184+
public JsonLocation currentTokenLocation() {
185185
return JsonLocation.NA;
186186
}
187187

188+
@Deprecated // since 2.17
189+
@Override
190+
public JsonLocation getTokenLocation() { return currentTokenLocation(); }
191+
192+
@Deprecated // since 2.17
193+
@Override
194+
public JsonLocation getCurrentLocation() { return currentLocation(); }
195+
188196
/*
189197
/**********************************************************
190198
/* Public API, access to textual content

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

+17-8
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@ public JsonParser asParser(JsonParser src)
299299
{
300300
Parser p = new Parser(_first, src.getCodec(), _hasNativeTypeIds, _hasNativeObjectIds,
301301
_parentContext, src.streamReadConstraints());
302-
p.setLocation(src.getTokenLocation());
302+
p.setLocation(src.currentTokenLocation());
303303
return p;
304304
}
305305

@@ -1692,13 +1692,21 @@ public String nextFieldName() throws IOException
16921692
public JsonStreamContext getParsingContext() { return _parsingContext; }
16931693

16941694
@Override
1695-
public JsonLocation getTokenLocation() { return getCurrentLocation(); }
1696-
1697-
@Override
1698-
public JsonLocation getCurrentLocation() {
1695+
public JsonLocation currentLocation() {
16991696
return (_location == null) ? JsonLocation.NA : _location;
17001697
}
17011698

1699+
@Override
1700+
public JsonLocation currentTokenLocation() { return currentLocation(); }
1701+
1702+
@Deprecated // since 2.17
1703+
@Override
1704+
public JsonLocation getTokenLocation() { return currentTokenLocation(); }
1705+
1706+
@Deprecated // since 2.17
1707+
@Override
1708+
public JsonLocation getCurrentLocation() { return currentLocation(); }
1709+
17021710
@Override
17031711
public String currentName() {
17041712
// 25-Jun-2015, tatu: as per [databind#838], needs to be same as ParserBase
@@ -1709,9 +1717,6 @@ public String currentName() {
17091717
return _parsingContext.getCurrentName();
17101718
}
17111719

1712-
@Override // since 2.12 delegate to the new method
1713-
public String getCurrentName() { return currentName(); }
1714-
17151720
@Override
17161721
public void overrideCurrentName(String name)
17171722
{
@@ -1729,6 +1734,10 @@ public void overrideCurrentName(String name)
17291734
}
17301735
}
17311736

1737+
@Deprecated // since 2.17
1738+
@Override
1739+
public String getCurrentName() { return currentName(); }
1740+
17321741
/*
17331742
/**********************************************************
17341743
/* Public API, access to token information, text

0 commit comments

Comments
 (0)