# Motivation: `DefaultByteBufHolder.equals()` considers another object equal if it's an instance of `ByteBufferHolder` and if the contents of two objects are equal. However, the behavior of `equals` method is not a part of the `ByteBufHolder` contract so `DefaultByteBufHolder`'s version may be causing violation of the symmetric property if other classes have different logic. There are already a few classes that are affected by this: `DefaultHttp2GoAwayFrame`, `DefaultHttp2UnknownFrame`, and `SctpMessage` are all overriding `equals` method breaking the symmetric property. Another effect of this behavior is that all instances with empty data are considered equal. That may not be desireable in the situations when instances are created for predefined constants, e.g. `FullBulkStringRedisMessage.NULL_INSTANCE` and `FullBulkStringRedisMessage.EMPTY_INSTANCE` in `codec-redis`. # Modification: Make `DefaultByteBufHolder.equals()` implementation only work for the objects of the same class. # Result: - The symmetric property of the `equals` method is restored for the classes in question. - Instances of different classes are not considered equal even if the content of the data they hold are the same. |
||
---|---|---|
.. | ||
main/java/io/netty/handler/codec/redis | ||
test/java/io/netty/handler/codec/redis |