Skip to content

Commit

Permalink
Merge branch '2.17' into 2.18
Browse files Browse the repository at this point in the history
  • Loading branch information
cowtowncoder committed Apr 27, 2024
2 parents fe37f53 + 55b48b6 commit 24f823f
Show file tree
Hide file tree
Showing 10 changed files with 10 additions and 11 deletions.
3 changes: 3 additions & 0 deletions release-notes/VERSION-2.x
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ Project: jackson-databind
(fix by Joo-Hyuk K)
#4450: Empty QName deserialized as `null`
(reported by @winfriedgerlach)
#4471: Reconsider deprecation of `JsonNode.asText(defaultValue)`
(requested by @aerisnju)
(fix by Joo-Hyuk K)
#4481: Unable to override `DeserializationFeature.READ_UNKNOWN_ENUM_VALUES_AS_NULL`
with `JsonFormat.Feature.READ_UNKNOWN_ENUM_VALUES_AS_NULL`
(reported by @luozhenyu)
Expand Down
6 changes: 1 addition & 5 deletions src/main/java/com/fasterxml/jackson/databind/JsonNode.java
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
*<p>
* 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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,6 @@ public String asText() {
}

@Override
@Deprecated // since 2.17
public String asText(String defaultValue) {
return (_value == null) ? defaultValue : _value;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ public void testMissing()
assertTrue(n.isMissingNode());
assertEquals(JsonToken.NOT_AVAILABLE, n.asToken());
assertEquals("", n.asText());
assertEquals("default", n.asText("default"));
assertStandardEquals(n);
// 10-Dec-2018, tatu: With 2.10, should serialize same as via ObjectMapper/ObjectWriter
// 10-Dec-2019, tatu: Surprise! No, this is not how it worked in 2.9, nor does it make
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ public void testBasicsWithNullNode() throws Exception
assertEquals(0L, n.longValue());
assertEquals(BigDecimal.ZERO, n.decimalValue());
assertEquals(BigInteger.ZERO, n.bigIntegerValue());
// may be odd but...
assertEquals("null", n.asText());
assertEquals("fallback", n.asText("fallback"));

assertEquals(0, n.size());
assertTrue(n.isEmpty());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,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);

Expand Down

0 comments on commit 24f823f

Please sign in to comment.