From dcecb4dcb0864fb1fe0fb19a701bd960ccbe7678 Mon Sep 17 00:00:00 2001 From: Andrew Carbonetto Date: Wed, 26 Jun 2024 16:58:45 -0700 Subject: [PATCH] Doc updates for review comments Signed-off-by: Andrew Carbonetto --- .../java/glide/api/commands/StreamBaseCommands.java | 6 +++--- .../main/java/glide/api/models/BaseTransaction.java | 6 +++--- .../src/test/java/glide/SharedCommandTests.java | 13 +++++++++++++ 3 files changed, 19 insertions(+), 6 deletions(-) diff --git a/java/client/src/main/java/glide/api/commands/StreamBaseCommands.java b/java/client/src/main/java/glide/api/commands/StreamBaseCommands.java index ba46ace865..b784807587 100644 --- a/java/client/src/main/java/glide/api/commands/StreamBaseCommands.java +++ b/java/client/src/main/java/glide/api/commands/StreamBaseCommands.java @@ -455,7 +455,7 @@ CompletableFuture xgroupCreate( * @param consumer The consumer name. * @return A {@literal Map>} with stream * keys, to Map of stream-ids, to an array of pairings with format [[field, entry], [field, entry], ...]. - * Returns null if the consumer group does not exist. + * Returns null if there is no stream that can be served. * @example *
{@code
      * // create a new stream at "mystream", with stream id "1-0"
@@ -486,11 +486,11 @@ CompletableFuture>> xreadgroup(
      *     Map is composed of a stream's key and the id of the entry after which the stream
      *     will be read. Use the special id of {@literal ">"} to receive only new messages.
      * @param group The consumer group name.
-     * @param consumer The newly created consumer.
+     * @param consumer The consumer name.
      * @param options Options detailing how to read the stream {@link StreamReadGroupOptions}.
      * @return A {@literal Map>} with stream
      *      keys, to Map of stream-ids, to an array of pairings with format [[field, entry], [field, entry], ...].
-     *      Returns null if the consumer group does not exist.
+     *      Returns null if the {@link StreamReadGroupOptions#block} option is given and a timeout occurs, or if there is no stream that can be served.
      * @example
      *     
{@code
      * // create a new stream at "mystream", with stream id "1-0"
diff --git a/java/client/src/main/java/glide/api/models/BaseTransaction.java b/java/client/src/main/java/glide/api/models/BaseTransaction.java
index ee18dbddee..cf92505875 100644
--- a/java/client/src/main/java/glide/api/models/BaseTransaction.java
+++ b/java/client/src/main/java/glide/api/models/BaseTransaction.java
@@ -3105,7 +3105,7 @@ public T xgroupDelConsumer(@NonNull String key, @NonNull String group, @NonNull
      * @return Command Response - A {@literal Map>} with
      *     stream keys, to Map of stream-ids, to an array of pairings with format 
      *     [[field, entry], [field, entry], ...].
-     *     Returns null if the consumer group does not exist.
+     *     Returns null if there is no stream that can be served.
      */
     public T xreadgroup(
             @NonNull Map keysAndIds, @NonNull String group, @NonNull String consumer) {
@@ -3123,12 +3123,12 @@ public T xreadgroup(
      *     will be read. Use the special id of {@literal Map>}
      *      to receive only new messages.
      * @param group The consumer group name.
-     * @param consumer The newly created consumer.
+     * @param consumer The consumer name.
      * @param options Options detailing how to read the stream {@link StreamReadGroupOptions}.
      * @return Command Response - A {@literal Map>} with
      *     stream keys, to Map of stream-ids, to an array of pairings with format 
      *     [[field, entry], [field, entry], ...].
-     *     Returns null if the consumer group does not exist.
+     *     Returns null if the {@link StreamReadGroupOptions#block} option is given and a timeout occurs, or if there is no stream that can be served.
      */
     public T xreadgroup(
             @NonNull Map keysAndIds,
diff --git a/java/integTest/src/test/java/glide/SharedCommandTests.java b/java/integTest/src/test/java/glide/SharedCommandTests.java
index 58517ce08b..15a87d7e7b 100644
--- a/java/integTest/src/test/java/glide/SharedCommandTests.java
+++ b/java/integTest/src/test/java/glide/SharedCommandTests.java
@@ -4039,6 +4039,19 @@ public void xreadgroup_return_failures(BaseClient client) {
                                         .get());
         assertInstanceOf(RequestException.class, executionException.getCause());
 
+        // group doesn't exists, throws a request error with "NOGROUP"
+        executionException =
+                assertThrows(
+                        ExecutionException.class,
+                        () -> client.xreadgroup(Map.of(key, timestamp_1_1), "not_a_group", consumerName).get());
+        assertInstanceOf(RequestException.class, executionException.getCause());
+        assertTrue(executionException.getMessage().contains("NOGROUP"));
+
+        // consumer doesn't exists, returns an empty response
+        var emptyResult =
+                client.xreadgroup(Map.of(key, timestamp_1_1), groupName, "not_a_consumer").get();
+        assertEquals(0, emptyResult.get(key).size());
+
         try (var testClient =
                 client instanceof RedisClient
                         ? RedisClient.CreateClient(commonClientConfig().build()).get()