Problem
TransactionId.compareTo() uses the wrong null flag when comparing validStart.
In sdk/src/main/java/com/hedera/hashgraph/sdk/TransactionId.java:532:
if (thisStartIsNull != otherStartIsNull) {
return thisAccountIdIsNull ? -1 : 1; // ❌ should use thisStartIsNull
}
This can violate the Comparable contract when both accountId values are non-null but only one validStart is null.
Impact
Sorted collections (TreeSet, TreeMap, Collections.sort()) may behave unexpectedly if comparisons are inconsistent.
Suggested Fix
Change line 532 to:
return thisStartIsNull ? -1 : 1;
Reproduction
TransactionId a = new TransactionId(new AccountId(1, 2, 3), Instant.now());
TransactionId b = new TransactionId(new AccountId(1, 2, 3), null);
// Both a.compareTo(b) and b.compareTo(a) may return 1
Problem
TransactionId.compareTo()uses the wrong null flag when comparingvalidStart.In
sdk/src/main/java/com/hedera/hashgraph/sdk/TransactionId.java:532:This can violate the Comparable contract when both accountId values are non-null but only one validStart is null.
Impact
Sorted collections (TreeSet, TreeMap, Collections.sort()) may behave unexpectedly if comparisons are inconsistent.
Suggested Fix
Change line 532 to:
return thisStartIsNull ? -1 : 1;
Reproduction
TransactionId a = new TransactionId(new AccountId(1, 2, 3), Instant.now());
TransactionId b = new TransactionId(new AccountId(1, 2, 3), null);
// Both a.compareTo(b) and b.compareTo(a) may return 1