From b82665b0cae18122b0094c6d970fce4f34b0a07f Mon Sep 17 00:00:00 2001 From: minjun Date: Mon, 21 Jan 2019 01:23:55 +0800 Subject: [PATCH 1/2] use standardcharset.utf-8 instead of literal --- .../cluster/loadbalance/ConsistentHashLoadBalance.java | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/loadbalance/ConsistentHashLoadBalance.java b/dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/loadbalance/ConsistentHashLoadBalance.java index 8671cdeca82..5f48da5b07b 100644 --- a/dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/loadbalance/ConsistentHashLoadBalance.java +++ b/dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/loadbalance/ConsistentHashLoadBalance.java @@ -23,6 +23,7 @@ import org.apache.dubbo.rpc.support.RpcUtils; import java.io.UnsupportedEncodingException; +import java.nio.charset.StandardCharsets; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; import java.util.List; @@ -33,7 +34,6 @@ /** * ConsistentHashLoadBalance - * */ public class ConsistentHashLoadBalance extends AbstractLoadBalance { public static final String NAME = "consistenthash"; @@ -126,12 +126,7 @@ private byte[] md5(String value) { throw new IllegalStateException(e.getMessage(), e); } md5.reset(); - byte[] bytes; - try { - bytes = value.getBytes("UTF-8"); - } catch (UnsupportedEncodingException e) { - throw new IllegalStateException(e.getMessage(), e); - } + byte[] bytes = value.getBytes(StandardCharsets.UTF_8); md5.update(bytes); return md5.digest(); } From e1486e0d1c5b8b46189be260317a3e07d28fcc15 Mon Sep 17 00:00:00 2001 From: minjun Date: Mon, 21 Jan 2019 13:14:09 +0800 Subject: [PATCH 2/2] remove unused import --- .../dubbo/rpc/cluster/loadbalance/ConsistentHashLoadBalance.java | 1 - 1 file changed, 1 deletion(-) diff --git a/dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/loadbalance/ConsistentHashLoadBalance.java b/dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/loadbalance/ConsistentHashLoadBalance.java index 5f48da5b07b..83d6f8c9112 100644 --- a/dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/loadbalance/ConsistentHashLoadBalance.java +++ b/dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/loadbalance/ConsistentHashLoadBalance.java @@ -22,7 +22,6 @@ import org.apache.dubbo.rpc.Invoker; import org.apache.dubbo.rpc.support.RpcUtils; -import java.io.UnsupportedEncodingException; import java.nio.charset.StandardCharsets; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException;