From fe70d44ba8cc3670c8b34658f70ecc9fec9d5345 Mon Sep 17 00:00:00 2001 From: Julien Ruaux Date: Wed, 4 Nov 2020 15:23:25 -0800 Subject: [PATCH] Implement set(double) in NestedMultiOutput #1486 NestedMultiOutput does not implement CommandOutput.set(double number) which causes problem with RediSearch FT.INFO command --- .../io/lettuce/core/output/NestedMultiOutput.java | 11 +++++++++++ .../core/output/NestedMultiOutputUnitTests.java | 11 +++++++++++ 2 files changed, 22 insertions(+) diff --git a/src/main/java/io/lettuce/core/output/NestedMultiOutput.java b/src/main/java/io/lettuce/core/output/NestedMultiOutput.java index 51949e4587..b137f92eff 100644 --- a/src/main/java/io/lettuce/core/output/NestedMultiOutput.java +++ b/src/main/java/io/lettuce/core/output/NestedMultiOutput.java @@ -32,6 +32,7 @@ * @param Value type. * @author Will Glozer * @author Mark Paluch + * @author Julien Ruaux */ public class NestedMultiOutput extends CommandOutput> { @@ -57,6 +58,16 @@ public void set(long integer) { output.add(integer); } + @Override + public void set(double number) { + + if (!initialized) { + output = new ArrayList<>(); + } + + output.add(number); + } + @Override public void set(ByteBuffer bytes) { diff --git a/src/test/java/io/lettuce/core/output/NestedMultiOutputUnitTests.java b/src/test/java/io/lettuce/core/output/NestedMultiOutputUnitTests.java index 18fdc5eed9..20cb887257 100644 --- a/src/test/java/io/lettuce/core/output/NestedMultiOutputUnitTests.java +++ b/src/test/java/io/lettuce/core/output/NestedMultiOutputUnitTests.java @@ -35,4 +35,15 @@ void nestedMultiError() { output.setError(StandardCharsets.US_ASCII.encode("Oops!")); assertThat(output.getError()).isNotNull(); } + + @Test + void nestedMultiDouble() { + NestedMultiOutput output = new NestedMultiOutput<>(StringCodec.UTF8); + double value = 123.456; + output.set(value); + assertThat(output.get()).isNotNull(); + assertThat(output.get()).size().isEqualTo(1); + assertThat(output.get().get(0)).isEqualTo(value); + } + }