Skip to content

Commit

Permalink
Merge branch '2.15' into 2.16
Browse files Browse the repository at this point in the history
  • Loading branch information
cowtowncoder committed Feb 13, 2024
2 parents ccabd8e + 901ba02 commit 4fc5def
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 2 deletions.
4 changes: 4 additions & 0 deletions release-notes/VERSION-2.x
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,10 @@ Project: jackson-databind
#4303: `ObjectReader` is not serializable if it's configured for polymorphism
(reported by @asardaes)
(fix contributed by Joo-Hyuk K)
#4378: `TextNode.equals()` throws `NullPointerException` when `TextNode`
constructed with `null`
(reported by @Javed6234)
(fix contributed by @pjfanning)
2.15.3 (12-Oct-2023)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.fasterxml.jackson.databind.node;

import java.io.IOException;
import java.util.Objects;

import com.fasterxml.jackson.core.*;
import com.fasterxml.jackson.core.io.CharTypes;
Expand Down Expand Up @@ -164,13 +165,16 @@ public boolean equals(Object o)
if (o == this) return true;
if (o == null) return false;
if (o instanceof TextNode) {
return ((TextNode) o)._value.equals(_value);
TextNode otherNode = (TextNode) o;
return Objects.equals(otherNode._value, _value);
}
return false;
}

@Override
public int hashCode() { return _value.hashCode(); }
public int hashCode() {
return Objects.hashCode(_value);
}

@Deprecated // since 2.10
protected static void appendQuoted(StringBuilder sb, String content)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.fasterxml.jackson.databind.node;

import static org.junit.Assert.assertNotEquals;

public class TextNodeTest extends NodeTestBase
{
public void testText()
Expand Down Expand Up @@ -36,4 +38,19 @@ public void testText()
assertFalse(TextNode.valueOf("false").asBoolean(true));
assertFalse(TextNode.valueOf("false").asBoolean(false));
}

public void testEquals()
{
assertEquals(new TextNode(null), new TextNode(null));
assertEquals(new TextNode("abc"), new TextNode("abc"));
assertNotEquals(new TextNode(null), new TextNode("def"));
assertNotEquals(new TextNode("abc"), new TextNode("def"));
assertNotEquals(new TextNode("abc"), new TextNode(null));
}

public void testHashCode()
{
assertEquals(0, new TextNode(null).hashCode());
assertEquals("abc".hashCode(), new TextNode("abc").hashCode());
}
}

0 comments on commit 4fc5def

Please sign in to comment.