Skip to content

Commit

Permalink
Merge pull request redis#1064 from xetorthio/fix_binarycompat
Browse files Browse the repository at this point in the history
Fixes binary compatibility between 2.6.3 and 2.7.x
  • Loading branch information
marcosnils committed Jul 20, 2015
2 parents d4b4aec + 8f725f9 commit 942c4d6
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 21 deletions.
6 changes: 3 additions & 3 deletions src/main/java/redis/clients/jedis/Connection.java
Original file line number Diff line number Diff line change
Expand Up @@ -83,19 +83,19 @@ public void rollbackTimeout() {
}
}

protected Connection sendCommand(final ProtocolCommand cmd, final String... args) {
protected Connection sendCommand(final Command cmd, final String... args) {
final byte[][] bargs = new byte[args.length][];
for (int i = 0; i < args.length; i++) {
bargs[i] = SafeEncoder.encode(args[i]);
}
return sendCommand(cmd, bargs);
}

protected Connection sendCommand(final ProtocolCommand cmd) {
protected Connection sendCommand(final Command cmd) {
return sendCommand(cmd, EMPTY_ARGS);
}

protected Connection sendCommand(final ProtocolCommand cmd, final byte[]... args) {
protected Connection sendCommand(final Command cmd, final byte[]... args) {
try {
connect();
Protocol.sendCommand(outputStream, cmd, args);
Expand Down
12 changes: 4 additions & 8 deletions src/main/java/redis/clients/jedis/Protocol.java
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,9 @@ private Protocol() {
// this prevent the class from instantiation
}

public static void sendCommand(final RedisOutputStream os, final ProtocolCommand command,
public static void sendCommand(final RedisOutputStream os, final Command command,
final byte[]... args) {
sendCommand(os, command.getRaw(), args);
sendCommand(os, command.raw, args);
}

private static void sendCommand(final RedisOutputStream os, final byte[] command,
Expand Down Expand Up @@ -221,19 +221,15 @@ public static final byte[] toByteArray(final double value) {
return SafeEncoder.encode(String.valueOf(value));
}

public static enum Command implements ProtocolCommand {
public static enum Command {
PING, SET, GET, QUIT, EXISTS, DEL, TYPE, FLUSHDB, KEYS, RANDOMKEY, RENAME, RENAMENX, RENAMEX, DBSIZE, EXPIRE, EXPIREAT, TTL, SELECT, MOVE, FLUSHALL, GETSET, MGET, SETNX, SETEX, MSET, MSETNX, DECRBY, DECR, INCRBY, INCR, APPEND, SUBSTR, HSET, HGET, HSETNX, HMSET, HMGET, HINCRBY, HEXISTS, HDEL, HLEN, HKEYS, HVALS, HGETALL, RPUSH, LPUSH, LLEN, LRANGE, LTRIM, LINDEX, LSET, LREM, LPOP, RPOP, RPOPLPUSH, SADD, SMEMBERS, SREM, SPOP, SMOVE, SCARD, SISMEMBER, SINTER, SINTERSTORE, SUNION, SUNIONSTORE, SDIFF, SDIFFSTORE, SRANDMEMBER, ZADD, ZRANGE, ZREM, ZINCRBY, ZRANK, ZREVRANK, ZREVRANGE, ZCARD, ZSCORE, MULTI, DISCARD, EXEC, WATCH, UNWATCH, SORT, BLPOP, BRPOP, AUTH, SUBSCRIBE, PUBLISH, UNSUBSCRIBE, PSUBSCRIBE, PUNSUBSCRIBE, PUBSUB, ZCOUNT, ZRANGEBYSCORE, ZREVRANGEBYSCORE, ZREMRANGEBYRANK, ZREMRANGEBYSCORE, ZUNIONSTORE, ZINTERSTORE, ZLEXCOUNT, ZRANGEBYLEX, ZREVRANGEBYLEX, ZREMRANGEBYLEX, SAVE, BGSAVE, BGREWRITEAOF, LASTSAVE, SHUTDOWN, INFO, MONITOR, SLAVEOF, CONFIG, STRLEN, SYNC, LPUSHX, PERSIST, RPUSHX, ECHO, LINSERT, DEBUG, BRPOPLPUSH, SETBIT, GETBIT, BITPOS, SETRANGE, GETRANGE, EVAL, EVALSHA, SCRIPT, SLOWLOG, OBJECT, BITCOUNT, BITOP, SENTINEL, DUMP, RESTORE, PEXPIRE, PEXPIREAT, PTTL, INCRBYFLOAT, PSETEX, CLIENT, TIME, MIGRATE, HINCRBYFLOAT, SCAN, HSCAN, SSCAN, ZSCAN, WAIT, CLUSTER, ASKING, PFADD, PFCOUNT, PFMERGE;

private final byte[] raw;
public final byte[] raw;

Command() {
raw = SafeEncoder.encode(this.name());
}

@Override
public byte[] getRaw() {
return raw;
}
}

public static enum Keyword {
Expand Down
7 changes: 0 additions & 7 deletions src/main/java/redis/clients/jedis/ProtocolCommand.java

This file was deleted.

4 changes: 1 addition & 3 deletions src/test/java/redis/clients/jedis/tests/ConnectionTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,8 @@
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;

import redis.clients.jedis.Connection;
import redis.clients.jedis.Protocol.Command;
import redis.clients.jedis.ProtocolCommand;
import redis.clients.jedis.exceptions.JedisConnectionException;

public class ConnectionTest extends Assert {
Expand Down Expand Up @@ -59,7 +57,7 @@ public TestConnection() {
}

@Override
protected Connection sendCommand(ProtocolCommand cmd, byte[]... args) {
protected Connection sendCommand(Command cmd, byte[]... args) {
return super.sendCommand(cmd, args);
}
}
Expand Down

0 comments on commit 942c4d6

Please sign in to comment.