diff --git a/src/main/java/com/fasterxml/jackson/databind/JsonNode.java b/src/main/java/com/fasterxml/jackson/databind/JsonNode.java index e2f813bcd9..67e42ca149 100644 --- a/src/main/java/com/fasterxml/jackson/databind/JsonNode.java +++ b/src/main/java/com/fasterxml/jackson/databind/JsonNode.java @@ -636,16 +636,12 @@ public byte[] binaryValue() throws IOException { * {@link com.fasterxml.jackson.databind.node.NullNode}, ensuring a default value is returned instead of null or missing indicators. * *

- * NOTE: deprecated since 2.17 because {@link #asText()} very rarely returns - * {@code null} for any node types -- in fact, neither {@link MissingNode} - * nor {@code NullNode} return {@code null} from {@link #asText()}. + * NOTE: This was deprecated in 2.17.0, but as discussed through [databind#4471], was un-deprecated in 2.17.1. * * @param defaultValue The default value to return if this node's text value is absent. * @return The text value of this node, or defaultValue if the text value is absent. * @since 2.4 - * @deprecated Since 2.17, to be removed from 3.0 */ - @Deprecated // @since 2.17 public String asText(String defaultValue) { String str = asText(); return (str == null) ? defaultValue : str; diff --git a/src/main/java/com/fasterxml/jackson/databind/node/MissingNode.java b/src/main/java/com/fasterxml/jackson/databind/node/MissingNode.java index 87843c274b..fcaf5823dd 100644 --- a/src/main/java/com/fasterxml/jackson/databind/node/MissingNode.java +++ b/src/main/java/com/fasterxml/jackson/databind/node/MissingNode.java @@ -60,7 +60,6 @@ public JsonNodeType getNodeType() @Override public String asText() { return ""; } - @Deprecated // since 2.17 @Override public String asText(String defaultValue) { return defaultValue; } // // Note: not a numeric node, hence default 'asXxx()' are fine: diff --git a/src/main/java/com/fasterxml/jackson/databind/node/NullNode.java b/src/main/java/com/fasterxml/jackson/databind/node/NullNode.java index 822cbb2040..be67b7e6f6 100644 --- a/src/main/java/com/fasterxml/jackson/databind/node/NullNode.java +++ b/src/main/java/com/fasterxml/jackson/databind/node/NullNode.java @@ -41,7 +41,6 @@ public JsonNodeType getNodeType() { @Override public JsonToken asToken() { return JsonToken.VALUE_NULL; } @Override - @Deprecated public String asText(String defaultValue) { return defaultValue; } @Override public String asText() { return "null"; } diff --git a/src/main/java/com/fasterxml/jackson/databind/node/POJONode.java b/src/main/java/com/fasterxml/jackson/databind/node/POJONode.java index b24511bb5e..ad411edc08 100644 --- a/src/main/java/com/fasterxml/jackson/databind/node/POJONode.java +++ b/src/main/java/com/fasterxml/jackson/databind/node/POJONode.java @@ -58,7 +58,6 @@ public byte[] binaryValue() throws IOException public String asText() { return (_value == null) ? "null" : _value.toString(); } @Override - @Deprecated public String asText(String defaultValue) { return (_value == null) ? defaultValue : _value.toString(); } diff --git a/src/main/java/com/fasterxml/jackson/databind/node/TextNode.java b/src/main/java/com/fasterxml/jackson/databind/node/TextNode.java index d22ba33541..83d256fe70 100644 --- a/src/main/java/com/fasterxml/jackson/databind/node/TextNode.java +++ b/src/main/java/com/fasterxml/jackson/databind/node/TextNode.java @@ -102,7 +102,6 @@ public String asText() { } @Override - @Deprecated // since 2.17 public String asText(String defaultValue) { return (_value == null) ? defaultValue : _value; } diff --git a/src/test/java/com/fasterxml/jackson/databind/deser/CustomDeserializersTest.java b/src/test/java/com/fasterxml/jackson/databind/deser/CustomDeserializersTest.java index c2bfe713ea..1f2982a8a6 100644 --- a/src/test/java/com/fasterxml/jackson/databind/deser/CustomDeserializersTest.java +++ b/src/test/java/com/fasterxml/jackson/databind/deser/CustomDeserializersTest.java @@ -355,7 +355,7 @@ public NamedPoint deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { JsonNode tree = ctxt.readTree(p); - String name = tree.path("name").asText(); + String name = tree.path("name").asText(null); Point point = ctxt.readTreeAsValue(tree.get("point"), Point.class); return new NamedPoint(name, point); } diff --git a/src/test/java/com/fasterxml/jackson/databind/node/NumberNodesTest.java b/src/test/java/com/fasterxml/jackson/databind/node/NumberNodesTest.java index 1f143f1deb..a6ad436211 100644 --- a/src/test/java/com/fasterxml/jackson/databind/node/NumberNodesTest.java +++ b/src/test/java/com/fasterxml/jackson/databind/node/NumberNodesTest.java @@ -82,7 +82,7 @@ public void testInt() assertEquals(BigInteger.ONE, n.bigIntegerValue()); assertEquals("1", n.asText()); // 2.4 - assertEquals("1", n.asText()); + assertEquals("1", n.asText("foo")); assertNodeNumbers(n, 1, 1.0);