Skip to content

Commit 26187bf

Browse files
committed
use Objects.hash instead of concat hashcode
1 parent 4f78568 commit 26187bf

File tree

4 files changed

+16
-6
lines changed

4 files changed

+16
-6
lines changed

chainbase/src/main/java/org/tron/core/db2/core/SnapshotManager.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -423,6 +423,7 @@ public List<String> getCheckpointList() {
423423

424424
private void deleteCheckpoint() {
425425
if(checkTmpStore == null) {
426+
//only occurs in mock test. TODO fix test
426427
return;
427428
}
428429
try {

framework/src/main/java/org/tron/common/logsfilter/EventPluginLoader.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -546,6 +546,7 @@ public boolean isBusy() {
546546
}
547547
int queueSize = 0;
548548
if (eventListeners == null || eventListeners.isEmpty()) {
549+
//only occurs in mock test. TODO fix test
549550
return false;
550551
}
551552
for (IPluginEventListener listener : eventListeners) {

framework/src/main/java/org/tron/core/services/jsonrpc/TronJsonRpc.java

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
import org.tron.core.exception.jsonrpc.JsonRpcInvalidRequestException;
2525
import org.tron.core.exception.jsonrpc.JsonRpcMethodNotFoundException;
2626
import org.tron.core.exception.jsonrpc.JsonRpcTooManyResultException;
27-
import org.tron.core.net.peer.Item;
2827
import org.tron.core.services.jsonrpc.types.BlockResult;
2928
import org.tron.core.services.jsonrpc.types.BuildArguments;
3029
import org.tron.core.services.jsonrpc.types.CallArguments;
@@ -501,11 +500,7 @@ public boolean equals(Object o) {
501500

502501
@Override
503502
public int hashCode() {
504-
int result = blockHash != null ? blockHash.hashCode() : 0;
505-
result = 31 * result + (transactionHash != null ? transactionHash.hashCode() : 0);
506-
result = 31 * result + (transactionIndex != null ? transactionIndex.hashCode() : 0);
507-
result = 31 * result + (logIndex != null ? logIndex.hashCode() : 0);
508-
return result + (removed ? 1 : 0);
503+
return Objects.hash(blockHash, transactionHash, transactionIndex, logIndex, removed);
509504
}
510505

511506
}

framework/src/test/java/org/tron/core/jsonrpc/LogMatchExactlyTest.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
import java.util.ArrayList;
66
import java.util.List;
7+
import java.util.Objects;
78
import org.junit.Assert;
89
import org.junit.Test;
910
import org.tron.common.runtime.vm.DataWord;
@@ -220,6 +221,18 @@ public void testMatchBlock() {
220221
List<LogFilterElement> elementList =
221222
matchBlock(logFilter, 100, null, transactionInfoList, false);
222223
Assert.assertEquals(1, elementList.size());
224+
225+
//test LogFilterElement
226+
List<LogFilterElement> elementList2 =
227+
matchBlock(logFilter, 100, null, transactionInfoList, false);
228+
Assert.assertEquals(1, elementList2.size());
229+
230+
LogFilterElement logFilterElement1 = elementList.get(0);
231+
LogFilterElement logFilterElement2 = elementList2.get(0);
232+
233+
Assert.assertEquals(logFilterElement1.hashCode(), logFilterElement2.hashCode());
234+
Assert.assertEquals(logFilterElement1, logFilterElement2);
235+
223236
} catch (JsonRpcInvalidParamsException e) {
224237
Assert.fail();
225238
}

0 commit comments

Comments
 (0)