Skip to content

Commit

Permalink
fix: change == to .equals for Bytes.EMPTY and other non-primitive typ…
Browse files Browse the repository at this point in the history
…es (#17213)

Signed-off-by: Kim Rader <[email protected]>
  • Loading branch information
kimbor authored Jan 6, 2025
1 parent 2de59a2 commit 602f625
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 13 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2022-2024 Hedera Hashgraph, LLC
* Copyright (C) 2022-2025 Hedera Hashgraph, LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -113,7 +113,7 @@ byte[] getBytes() {
@VisibleForTesting
static boolean supports(final ByteString byteString) {
return byteString.size() > UnsafeByteOutput.SIZE
&& byteString.getClass() == UnsafeByteOutput.SUPPORTED_CLASS;
&& UnsafeByteOutput.SUPPORTED_CLASS.equals(byteString.getClass());
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2020-2024 Hedera Hashgraph, LLC
* Copyright (C) 2020-2025 Hedera Hashgraph, LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -213,7 +213,7 @@ public static int getAccountKeyStorageSize(final Key key) {
if (key == null) {
return 0;
}
if (key == Key.getDefaultInstance()) {
if (Key.getDefaultInstance().equals(key)) {
return 0;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2024 Hedera Hashgraph, LLC
* Copyright (C) 2024-2025 Hedera Hashgraph, LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -104,7 +104,7 @@ public AccountID getProxy() {
}

public int[] getFirstUint256Key() {
return firstContractStorageKey == Bytes.EMPTY ? null : toInts(firstContractStorageKey);
return Bytes.EMPTY.equals(firstContractStorageKey) ? null : toInts(firstContractStorageKey);
}

private static int[] toInts(Bytes bytes) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2023-2024 Hedera Hashgraph, LLC
* Copyright (C) 2023-2025 Hedera Hashgraph, LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -513,7 +513,7 @@ public static Function<byte[], String> getMaybeStringifyByteString(@NonNull fina
}

public static boolean getMaybeStringifyByteString(@NonNull final StringBuilder sb, @Nullable final Bytes bytes) {
if (bytes == null || bytes == Bytes.EMPTY) {
if (bytes == null || Bytes.EMPTY.equals(bytes)) {
return false;
}
sb.append(toStringPossibleHumanReadableByteArray(";", bytes.toByteArray()));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2023-2024 Hedera Hashgraph, LLC
* Copyright (C) 2023-2025 Hedera Hashgraph, LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -66,7 +66,7 @@ public void freezeTime(@NonNull final Timestamp freezeTime) {
* Gets the scheduled freeze time. If no freeze has been scheduled, returns null.
*/
public Timestamp freezeTime() {
return freezeTimeState.get() == Timestamp.DEFAULT ? null : freezeTimeState.get();
return Timestamp.DEFAULT.equals(freezeTimeState.get()) ? null : freezeTimeState.get();
}

/**
Expand All @@ -89,6 +89,6 @@ public Bytes updateFileHash() {
if (fileHash == null) {
return null;
}
return fileHash.value() == Bytes.EMPTY ? null : fileHash.value();
return Bytes.EMPTY.equals(fileHash.value()) ? null : fileHash.value();
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2023-2024 Hedera Hashgraph, LLC
* Copyright (C) 2023-2025 Hedera Hashgraph, LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -89,7 +89,7 @@ private static void setTokenKeys(
@NonNull final TokenCreateWrapper tokenCreateWrapper, final Builder txnBodyBuilder) {
tokenCreateWrapper.getTokenKeys().forEach(tokenKeyWrapper -> {
final var key = tokenKeyWrapper.key().asGrpc();
if (key == Key.DEFAULT) {
if (Key.DEFAULT.equals(key)) {
throw new IllegalArgumentException();
}
if (tokenKeyWrapper.isUsedForAdminKey()) {
Expand Down

0 comments on commit 602f625

Please sign in to comment.