Skip to content

Commit

Permalink
use standardcharset.utf-8 instead of literal (#3285)
Browse files Browse the repository at this point in the history
* use standardcharset.utf-8 instead of literal

* remove unused import
  • Loading branch information
mjaow authored and beiwei30 committed Jan 21, 2019
1 parent bcb6eee commit ca84f6c
Showing 1 changed file with 2 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
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;
import java.util.List;
Expand All @@ -33,7 +33,6 @@

/**
* ConsistentHashLoadBalance
*
*/
public class ConsistentHashLoadBalance extends AbstractLoadBalance {
public static final String NAME = "consistenthash";
Expand Down Expand Up @@ -126,12 +125,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();
}
Expand Down

0 comments on commit ca84f6c

Please sign in to comment.