Skip to content

Commit

Permalink
Fix aligned TimeValuePair npe (#173)
Browse files Browse the repository at this point in the history
  • Loading branch information
shuwenwei authored Jul 11, 2024
1 parent ab02b83 commit 289cd82
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -691,6 +691,12 @@ public boolean equals(Object anObject) {
return false;
}
for (int i = 0; i < this.values.length; i++) {
if (values[i] == null && anotherTs.values[i] == null) {
continue;
}
if (values[i] == null || anotherTs.values[i] == null) {
return false;
}
if (!values[i].equals(anotherTs.values[i])) {
return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

import org.apache.tsfile.common.conf.TSFileConfig;
import org.apache.tsfile.enums.TSDataType;
import org.apache.tsfile.read.TimeValuePair;
import org.apache.tsfile.utils.TsPrimitiveType.TsBinary;
import org.apache.tsfile.utils.TsPrimitiveType.TsBoolean;
import org.apache.tsfile.utils.TsPrimitiveType.TsDouble;
Expand Down Expand Up @@ -59,4 +60,19 @@ public void testNewAndGet() {
Assert.assertEquals(new TsBoolean(true), booleanValue);
Assert.assertTrue(booleanValue.getBoolean());
}

@Test
public void testCompareWithNullValue() {
TimeValuePair timeValuePair1 =
new TimeValuePair(
1,
new TsPrimitiveType.TsVector(
new TsPrimitiveType[] {new TsBoolean(true), null, null, new TsInt(1)}));
TimeValuePair timeValuePair2 =
new TimeValuePair(
1,
new TsPrimitiveType.TsVector(
new TsPrimitiveType[] {new TsBoolean(true), null, new TsInt(1), null}));
Assert.assertFalse(timeValuePair1.equals(timeValuePair2));
}
}

0 comments on commit 289cd82

Please sign in to comment.