diff --git a/redisson/src/main/java/org/redisson/client/handler/PubSubKey.java b/redisson/src/main/java/org/redisson/client/handler/PubSubKey.java index 306416565..9c8b461fe 100644 --- a/redisson/src/main/java/org/redisson/client/handler/PubSubKey.java +++ b/redisson/src/main/java/org/redisson/client/handler/PubSubKey.java @@ -17,6 +17,8 @@ package org.redisson.client.handler; import org.redisson.client.ChannelName; +import java.util.Objects; + /** * * @author Nikita Koksharov @@ -42,35 +44,15 @@ public class PubSubKey { } @Override - @SuppressWarnings("AvoidInlineConditionals") - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((channel == null) ? 0 : channel.hashCode()); - result = prime * result + ((operation == null) ? 0 : operation.hashCode()); - return result; + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + PubSubKey pubSubKey = (PubSubKey) o; + return Objects.equals(channel, pubSubKey.channel) && Objects.equals(operation, pubSubKey.operation); } @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - PubSubKey other = (PubSubKey) obj; - if (channel == null) { - if (other.channel != null) - return false; - } else if (!channel.equals(other.channel)) - return false; - if (operation == null) { - if (other.operation != null) - return false; - } else if (!operation.equals(other.operation)) - return false; - return true; + public int hashCode() { + return Objects.hash(channel, operation); } - } diff --git a/redisson/src/main/java/org/redisson/client/protocol/RedisCommands.java b/redisson/src/main/java/org/redisson/client/protocol/RedisCommands.java index fb80df8e4..338bf16fc 100644 --- a/redisson/src/main/java/org/redisson/client/protocol/RedisCommands.java +++ b/redisson/src/main/java/org/redisson/client/protocol/RedisCommands.java @@ -649,9 +649,9 @@ public interface RedisCommands { RedisCommand PSUBSCRIBE = new RedisCommand("PSUBSCRIBE", new PubSubStatusDecoder()); RedisCommand PUNSUBSCRIBE = new RedisCommand("PUNSUBSCRIBE", new PubSubStatusDecoder()); - Set PUBSUB_COMMANDS = new HashSet( + Set PUBSUB_COMMANDS = Collections.unmodifiableSet(new HashSet<>( Arrays.asList(PSUBSCRIBE.getName(), SUBSCRIBE.getName(), PUNSUBSCRIBE.getName(), - UNSUBSCRIBE.getName(), SSUBSCRIBE.getName(), SUNSUBSCRIBE.getName())); + UNSUBSCRIBE.getName(), SSUBSCRIBE.getName(), SUNSUBSCRIBE.getName()))); Set SCAN_COMMANDS = new HashSet( Arrays.asList(HSCAN.getName(), SCAN.getName(), ZSCAN.getName(), SSCAN.getName()));