diff --git a/rpc-framework-core/src/main/java/github/javaguide/loadbalance/loadbalancer/ConsistentHashLoadBalance.java b/rpc-framework-core/src/main/java/github/javaguide/loadbalance/loadbalancer/ConsistentHashLoadBalance.java index 0d3e6bc..e4def88 100644 --- a/rpc-framework-core/src/main/java/github/javaguide/loadbalance/loadbalancer/ConsistentHashLoadBalance.java +++ b/rpc-framework-core/src/main/java/github/javaguide/loadbalance/loadbalancer/ConsistentHashLoadBalance.java @@ -7,10 +7,7 @@ import java.nio.charset.StandardCharsets; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; -import java.util.Arrays; -import java.util.List; -import java.util.Map; -import java.util.TreeMap; +import java.util.*; import java.util.concurrent.ConcurrentHashMap; /** @@ -34,7 +31,7 @@ protected String doSelect(List<String> serviceAddresses, RpcRequest rpcRequest) selectors.put(rpcServiceName, new ConsistentHashSelector(serviceAddresses, 160, identityHashCode)); selector = selectors.get(rpcServiceName); } - return selector.select(rpcServiceName + Arrays.stream(rpcRequest.getParameters())); + return selector.select(rpcServiceName + Arrays.stream(Optional.ofNullable(rpcRequest.getParameters()).orElseGet(() -> new Object[0]))); } static class ConsistentHashSelector {