Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/main/java/redis/clients/jedis/Protocol.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package redis.clients.jedis;

import java.io.IOException;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
Expand Down Expand Up @@ -29,7 +31,7 @@ public final class Protocol {
public static final int DEFAULT_TIMEOUT = 2000;
public static final int DEFAULT_DATABASE = 0;

public static final String CHARSET = "UTF-8";
public static final Charset CHARSET = StandardCharsets.UTF_8;

public static final byte DOLLAR_BYTE = '$';
public static final byte ASTERISK_BYTE = '*';
Expand Down
16 changes: 4 additions & 12 deletions src/main/java/redis/clients/jedis/util/SafeEncoder.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,22 +25,14 @@ public static byte[][] encodeMany(final String... strs) {
}

public static byte[] encode(final String str) {
try {
if (str == null) {
throw new IllegalArgumentException("null value cannot be sent to redis");
}
return str.getBytes(Protocol.CHARSET);
} catch (UnsupportedEncodingException e) {
throw new JedisException(e);
if (str == null) {
throw new IllegalArgumentException("null value cannot be sent to redis");
}
return str.getBytes(Protocol.CHARSET);
}

public static String encode(final byte[] data) {
try {
return new String(data, Protocol.CHARSET);
} catch (UnsupportedEncodingException e) {
throw new JedisException(e);
}
return new String(data, Protocol.CHARSET);
}

/**
Expand Down