Skip to content

Commit f829910

Browse files
committed
fixed NilValue.equals
1 parent 108fb1d commit f829910

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

src/main/java/org/msgpack/type/NilValue.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,13 @@ public void writeTo(Packer pk) throws IOException {
5454
}
5555

5656
public boolean equals(Object o) {
57-
return o == this;
57+
if(o == this) {
58+
return true;
59+
}
60+
if(!(o instanceof Value)) {
61+
return false;
62+
}
63+
return ((Value) o).isNil();
5864
}
5965

6066
public int hashCode() {

src/test/java/org/msgpack/type/TestEquals.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,12 @@ public void testBigInteger(BigInteger v) throws Exception {
190190
}
191191
}
192192

193+
@Test
194+
public void testNull() {
195+
Value v1 = ValueFactory.nilValue();
196+
Value v2 = ValueFactory.nilValue();
197+
testEquals(v1, v2);
198+
}
193199

194200
private boolean compatibleWithByte(long v) {
195201
return (long)Byte.MIN_VALUE <= v && v <= (long)Byte.MAX_VALUE;

0 commit comments

Comments
 (0)