diff --git a/src/main/java/com/lambdaworks/redis/RedisAsyncConnectionImpl.java b/src/main/java/com/lambdaworks/redis/RedisAsyncConnectionImpl.java index aea383d5f3..3ec15ecde8 100644 --- a/src/main/java/com/lambdaworks/redis/RedisAsyncConnectionImpl.java +++ b/src/main/java/com/lambdaworks/redis/RedisAsyncConnectionImpl.java @@ -798,7 +798,7 @@ public RedisFuture set(K key, V value) { } @Override - public RedisFuture set(K key, V value, SetArgs setArgs) { + public RedisFuture set(K key, V value, SetArgs setArgs) { return dispatch(commandBuilder.set(key, value, setArgs)); } diff --git a/src/main/java/com/lambdaworks/redis/RedisCommandBuilder.java b/src/main/java/com/lambdaworks/redis/RedisCommandBuilder.java index 7fa885d63d..76005025ea 100644 --- a/src/main/java/com/lambdaworks/redis/RedisCommandBuilder.java +++ b/src/main/java/com/lambdaworks/redis/RedisCommandBuilder.java @@ -779,10 +779,10 @@ public Command set(K key, V value) { return createCommand(SET, new StatusOutput(codec), key, value); } - public Command set(K key, V value, SetArgs setArgs) { + public Command set(K key, V value, SetArgs setArgs) { CommandArgs args = new CommandArgs(codec).addKey(key).addValue(value); setArgs.build(args); - return createCommand(SET, new ValueOutput(codec), args); + return createCommand(SET, new StatusOutput(codec), args); } public Command setbit(K key, long offset, int value) { diff --git a/src/main/java/com/lambdaworks/redis/RedisStringsAsyncConnection.java b/src/main/java/com/lambdaworks/redis/RedisStringsAsyncConnection.java index 181b22ffc7..d1fe1f1c68 100644 --- a/src/main/java/com/lambdaworks/redis/RedisStringsAsyncConnection.java +++ b/src/main/java/com/lambdaworks/redis/RedisStringsAsyncConnection.java @@ -271,7 +271,7 @@ public interface RedisStringsAsyncConnection { * * @return RedisFuture<V> simple-string-reply {@code OK} if {@code SET} was executed correctly. */ - RedisFuture set(K key, V value, SetArgs setArgs); + RedisFuture set(K key, V value, SetArgs setArgs); /** * Sets or clears the bit at offset in the string value stored at key. diff --git a/src/main/java/com/lambdaworks/redis/RedisStringsConnection.java b/src/main/java/com/lambdaworks/redis/RedisStringsConnection.java index 06eccc7984..ce79a1df3f 100644 --- a/src/main/java/com/lambdaworks/redis/RedisStringsConnection.java +++ b/src/main/java/com/lambdaworks/redis/RedisStringsConnection.java @@ -265,9 +265,9 @@ public interface RedisStringsConnection { * @param value the value * @param setArgs the setArgs * - * @return V simple-string-reply {@code OK} if {@code SET} was executed correctly. + * @return String simple-string-reply {@code OK} if {@code SET} was executed correctly. */ - V set(K key, V value, SetArgs setArgs); + String set(K key, V value, SetArgs setArgs); /** * Sets or clears the bit at offset in the string value stored at key. diff --git a/src/main/java/com/lambdaworks/redis/protocol/CommandOutput.java b/src/main/java/com/lambdaworks/redis/protocol/CommandOutput.java index 7f7bc8cc39..58125eb54e 100644 --- a/src/main/java/com/lambdaworks/redis/protocol/CommandOutput.java +++ b/src/main/java/com/lambdaworks/redis/protocol/CommandOutput.java @@ -107,6 +107,10 @@ public void complete(int depth) { } protected String decodeAscii(ByteBuffer bytes) { + if(bytes == null) { + return null; + } + char[] chars = new char[bytes.remaining()]; for (int i = 0; i < chars.length; i++) { chars[i] = (char) bytes.get(); diff --git a/src/test/java/com/lambdaworks/redis/CustomCodecTest.java b/src/test/java/com/lambdaworks/redis/CustomCodecTest.java index 12544454f4..df5a4f6e7b 100644 --- a/src/test/java/com/lambdaworks/redis/CustomCodecTest.java +++ b/src/test/java/com/lambdaworks/redis/CustomCodecTest.java @@ -14,17 +14,24 @@ import java.util.List; import com.lambdaworks.redis.codec.ByteArrayCodec; +import com.lambdaworks.redis.protocol.SetArgs; import org.junit.Test; import com.lambdaworks.redis.codec.RedisCodec; public class CustomCodecTest extends AbstractCommandTest { @Test - public void test() throws Exception { + public void testJavaSerializer() throws Exception { RedisConnection connection = client.connect(new SerializedObjectCodec()); + List list = list("one", "two"); connection.set(key, list); + assertThat(connection.get(key)).isEqualTo(list); + assertThat(connection.set(key, list)).isEqualTo("OK"); + assertThat(connection.set(key, list, SetArgs.Builder.ex(1))).isEqualTo("OK"); + + connection.close(); } @Test