From 22d95950e99b5edb968d406f47c1e3e9b5db9827 Mon Sep 17 00:00:00 2001 From: Tatu Saloranta Date: Sun, 14 Jun 2020 10:25:41 -0700 Subject: [PATCH] Undo unnecessary (and actually inconsistent) change to parser/context argument ordering for helper methods in `StdDeserializer` --- .../deser/std/AtomicBooleanDeserializer.java | 2 +- .../deser/std/NumberDeserializers.java | 8 +++---- .../std/PrimitiveArrayDeserializers.java | 4 ++-- .../databind/deser/std/StdDeserializer.java | 22 +++++++++---------- 4 files changed, 17 insertions(+), 19 deletions(-) diff --git a/src/main/java/com/fasterxml/jackson/databind/deser/std/AtomicBooleanDeserializer.java b/src/main/java/com/fasterxml/jackson/databind/deser/std/AtomicBooleanDeserializer.java index 6f2eeb4cae..8d75c01efc 100644 --- a/src/main/java/com/fasterxml/jackson/databind/deser/std/AtomicBooleanDeserializer.java +++ b/src/main/java/com/fasterxml/jackson/databind/deser/std/AtomicBooleanDeserializer.java @@ -26,7 +26,7 @@ public AtomicBoolean deserialize(JsonParser p, DeserializationContext ctxt) thro } // 12-Jun-2020, tatu: May look convoluted, but need to work correctly with // CoercionConfig - Boolean b = _parseBoolean(ctxt, p, AtomicBoolean.class); + Boolean b = _parseBoolean(p, ctxt, AtomicBoolean.class); return (b == null) ? null : new AtomicBoolean(b.booleanValue()); } diff --git a/src/main/java/com/fasterxml/jackson/databind/deser/std/NumberDeserializers.java b/src/main/java/com/fasterxml/jackson/databind/deser/std/NumberDeserializers.java index cb99a7dbe2..cbb8d9a1eb 100644 --- a/src/main/java/com/fasterxml/jackson/databind/deser/std/NumberDeserializers.java +++ b/src/main/java/com/fasterxml/jackson/databind/deser/std/NumberDeserializers.java @@ -220,9 +220,9 @@ public Boolean deserialize(JsonParser p, DeserializationContext ctxt) throws IOE return Boolean.FALSE; } if (_primitive) { - return _parseBooleanPrimitive(ctxt, p); + return _parseBooleanPrimitive(p, ctxt); } - return _parseBoolean(ctxt, p, _valueClass); + return _parseBoolean(p, ctxt, _valueClass); } // Since we can never have type info ("natural type"; String, Boolean, Integer, Double): @@ -240,9 +240,9 @@ public Boolean deserializeWithType(JsonParser p, DeserializationContext ctxt, return Boolean.FALSE; } if (_primitive) { - return _parseBooleanPrimitive(ctxt, p); + return _parseBooleanPrimitive(p, ctxt); } - return _parseBoolean(ctxt, p, _valueClass); + return _parseBoolean(p, ctxt, _valueClass); } } diff --git a/src/main/java/com/fasterxml/jackson/databind/deser/std/PrimitiveArrayDeserializers.java b/src/main/java/com/fasterxml/jackson/databind/deser/std/PrimitiveArrayDeserializers.java index 1afa46aac4..c4520ab0fc 100644 --- a/src/main/java/com/fasterxml/jackson/databind/deser/std/PrimitiveArrayDeserializers.java +++ b/src/main/java/com/fasterxml/jackson/databind/deser/std/PrimitiveArrayDeserializers.java @@ -392,7 +392,7 @@ public boolean[] deserialize(JsonParser p, DeserializationContext ctxt) _verifyNullForPrimitive(ctxt); value = false; } else { - value = _parseBooleanPrimitive(ctxt, p); + value = _parseBooleanPrimitive(p, ctxt); } if (ix >= chunk.length) { chunk = builder.appendCompletedChunk(chunk, ix); @@ -409,7 +409,7 @@ public boolean[] deserialize(JsonParser p, DeserializationContext ctxt) @Override protected boolean[] handleSingleElementUnwrapped(JsonParser p, DeserializationContext ctxt) throws IOException { - return new boolean[] { _parseBooleanPrimitive(ctxt, p) }; + return new boolean[] { _parseBooleanPrimitive(p, ctxt) }; } @Override diff --git a/src/main/java/com/fasterxml/jackson/databind/deser/std/StdDeserializer.java b/src/main/java/com/fasterxml/jackson/databind/deser/std/StdDeserializer.java index 978d174c80..a976a27f8d 100644 --- a/src/main/java/com/fasterxml/jackson/databind/deser/std/StdDeserializer.java +++ b/src/main/java/com/fasterxml/jackson/databind/deser/std/StdDeserializer.java @@ -353,9 +353,10 @@ protected T _deserializeWrappedValue(JsonParser p, DeserializationContext ctxt) /********************************************************** */ - @Deprecated // since 2.11, use overloaded variant - protected final boolean _parseBooleanPrimitive(JsonParser p, DeserializationContext ctxt) throws IOException { - return _parseBooleanPrimitive(ctxt, p); + @Deprecated // since 2.12, use overloaded variant that does NOT take target type + protected final boolean _parseBooleanPrimitive(DeserializationContext ctxt, + JsonParser p, Class targetType) throws IOException { + return _parseBooleanPrimitive(p, ctxt); } /** @@ -365,12 +366,9 @@ protected final boolean _parseBooleanPrimitive(JsonParser p, DeserializationCont * same as {@link #handledType}, and not necessarily {@code boolean} * (may be {@code boolean[]} or {@code AtomicBoolean} for example); * used for coercion config access - * - * @since 2.12 */ - protected final boolean _parseBooleanPrimitive(DeserializationContext ctxt, - JsonParser p) - throws IOException + protected final boolean _parseBooleanPrimitive(JsonParser p, DeserializationContext ctxt) + throws IOException { final JsonToken t = p.currentToken(); // usually caller should have handled but: @@ -419,7 +417,7 @@ protected final boolean _parseBooleanPrimitive(DeserializationContext ctxt, // 12-Jun-2020, tatu: For some reason calling `_deserializeFromArray()` won't work so: if (t == JsonToken.START_ARRAY && ctxt.isEnabled(DeserializationFeature.UNWRAP_SINGLE_VALUE_ARRAYS)) { p.nextToken(); - final boolean parsed = _parseBooleanPrimitive(ctxt, p); + final boolean parsed = _parseBooleanPrimitive(p, ctxt); _verifyEndArrayForSingle(p, ctxt); return parsed; } @@ -436,16 +434,16 @@ protected final boolean _parseBooleanPrimitive(DeserializationContext ctxt, * Caller may need to translate from 3 possible result types into appropriately * matching output types. * - * @param ctxt Deserialization context for accessing configuration * @param p Underlying parser + * @param ctxt Deserialization context for accessing configuration * @param targetType Actual type that is being deserialized, may be * same as {@link #handledType} but could be {@code AtomicBoolean} for example. * Used for coercion config access. * * @since 2.12 */ - protected final Boolean _parseBoolean(DeserializationContext ctxt, - JsonParser p, Class targetType) + protected final Boolean _parseBoolean(JsonParser p, DeserializationContext ctxt, + Class targetType) throws IOException { switch (p.currentTokenId()) {