Skip to content

Commit ca84f6c

Browse files
mjaowbeiwei30
authored andcommitted
use standardcharset.utf-8 instead of literal (#3285)
* use standardcharset.utf-8 instead of literal * remove unused import
1 parent bcb6eee commit ca84f6c

File tree

1 file changed

+2
-8
lines changed

1 file changed

+2
-8
lines changed

dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/loadbalance/ConsistentHashLoadBalance.java

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
import org.apache.dubbo.rpc.Invoker;
2323
import org.apache.dubbo.rpc.support.RpcUtils;
2424

25-
import java.io.UnsupportedEncodingException;
25+
import java.nio.charset.StandardCharsets;
2626
import java.security.MessageDigest;
2727
import java.security.NoSuchAlgorithmException;
2828
import java.util.List;
@@ -33,7 +33,6 @@
3333

3434
/**
3535
* ConsistentHashLoadBalance
36-
*
3736
*/
3837
public class ConsistentHashLoadBalance extends AbstractLoadBalance {
3938
public static final String NAME = "consistenthash";
@@ -126,12 +125,7 @@ private byte[] md5(String value) {
126125
throw new IllegalStateException(e.getMessage(), e);
127126
}
128127
md5.reset();
129-
byte[] bytes;
130-
try {
131-
bytes = value.getBytes("UTF-8");
132-
} catch (UnsupportedEncodingException e) {
133-
throw new IllegalStateException(e.getMessage(), e);
134-
}
128+
byte[] bytes = value.getBytes(StandardCharsets.UTF_8);
135129
md5.update(bytes);
136130
return md5.digest();
137131
}

0 commit comments

Comments
 (0)