Skip to content

Commit 9eb9b36

Browse files
Check if ByteString is empty by using isEmpty() instead of == ByteString.EMPTY
PiperOrigin-RevId: 852852532
1 parent 2ec322e commit 9eb9b36

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

java/core/src/main/java/com/google/protobuf/LazyFieldLite.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -170,10 +170,8 @@ public int hashCode() {
170170
* Determines whether this LazyFieldLite instance represents the default instance of this type.
171171
*/
172172
public boolean containsDefaultInstance() {
173-
// TODO: ByteString can be empty but not the same as ByteString.EMPTY. Use
174-
// `isEmpty()` instead for both `delayedBytes` and `memoizedBytes`.
175-
return memoizedBytes == ByteString.EMPTY
176-
|| (value == null && (delayedBytes == null || delayedBytes == ByteString.EMPTY))
173+
return (memoizedBytes != null && memoizedBytes.isEmpty())
174+
|| (value == null && (delayedBytes == null || delayedBytes.isEmpty()))
177175
|| (defaultInstance != null && value == defaultInstance);
178176
}
179177

0 commit comments

Comments
 (0)