diff --git a/src/main/java/io/lettuce/core/dynamic/ParameterBinder.java b/src/main/java/io/lettuce/core/dynamic/ParameterBinder.java index d34a3542ca..e3c867155f 100644 --- a/src/main/java/io/lettuce/core/dynamic/ParameterBinder.java +++ b/src/main/java/io/lettuce/core/dynamic/ParameterBinder.java @@ -99,7 +99,11 @@ private void bind(CommandArgs args, RedisCodec codec, Object } if (argument instanceof byte[]) { - args.add((byte[]) argument); + if (index != -1 && accessor.isKey(index)) { + args.addKey((K) argument); + } else { + args.add((byte[]) argument); + } return; } diff --git a/src/test/java/io/lettuce/core/dynamic/RedisCommandsClusterSyncTest.java b/src/test/java/io/lettuce/core/dynamic/RedisCommandsClusterSyncTest.java index 9932dcc8e3..61ed3787e2 100644 --- a/src/test/java/io/lettuce/core/dynamic/RedisCommandsClusterSyncTest.java +++ b/src/test/java/io/lettuce/core/dynamic/RedisCommandsClusterSyncTest.java @@ -84,6 +84,18 @@ public void sync() { assertThat(api.getAsBytes("key")).isEqualTo("value".getBytes()); } + @Test + public void shouldRouteBinaryKey() { + + connection.sync().set(key, value); + + RedisCommandFactory factory = new RedisCommandFactory(connection); + + SynchronousCommands api = factory.getCommands(SynchronousCommands.class); + + assertThat(api.get(key.getBytes())).isEqualTo(value.getBytes()); + } + @Test public void mgetAsValues() { @@ -98,7 +110,9 @@ public void mgetAsValues() { assertThat(values.get(0)).isEqualTo(Value.just(value)); } - static interface SynchronousCommands extends Commands { + interface SynchronousCommands extends Commands { + + byte[] get(byte[] key); String get(String key);