You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@geode.apache.org by mk...@apache.org on 2021/04/28 06:18:25 UTC

[geode] branch develop updated: GEODE-9174: fix displaying the result of a gfsh query containing a UUID (#6365)

This is an automated email from the ASF dual-hosted git repository.

mkevo pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/geode.git


The following commit(s) were added to refs/heads/develop by this push:
     new 465173c  GEODE-9174: fix displaying the result of a gfsh query containing a UUID (#6365)
465173c is described below

commit 465173cf7de037239f08b27921066fd84e8cc1f9
Author: Mario Kevo <48...@users.noreply.github.com>
AuthorDate: Wed Apr 28 08:17:02 2021 +0200

    GEODE-9174: fix displaying the result of a gfsh query containing a UUID (#6365)
---
 .../cli/commands/QueryCommandDUnitTestBase.java    | 23 ++++++++++++++++++++++
 .../internal/cli/domain/DataCommandResult.java     |  3 +++
 2 files changed, 26 insertions(+)

diff --git a/geode-dunit/src/main/java/org/apache/geode/management/internal/cli/commands/QueryCommandDUnitTestBase.java b/geode-dunit/src/main/java/org/apache/geode/management/internal/cli/commands/QueryCommandDUnitTestBase.java
index 4ece413..52f27f2 100644
--- a/geode-dunit/src/main/java/org/apache/geode/management/internal/cli/commands/QueryCommandDUnitTestBase.java
+++ b/geode-dunit/src/main/java/org/apache/geode/management/internal/cli/commands/QueryCommandDUnitTestBase.java
@@ -28,6 +28,7 @@ import java.util.List;
 import java.util.Map;
 import java.util.Properties;
 import java.util.Random;
+import java.util.UUID;
 
 import org.junit.Before;
 import org.junit.Rule;
@@ -176,6 +177,21 @@ public class QueryCommandDUnitTestBase {
   }
 
   @Test
+  public void testSimpleQueryWithUUID() {
+    server1.invoke(() -> prepareDataForRegionWithUUID(DATA_PAR_REGION_NAME_PATH));
+    String uuidKey = String.valueOf(new UUID(1, 1));
+    String query = "query --query=\"select key from " + DATA_PAR_REGION_NAME_PATH
+        + ".entries\"";
+    String query1 = "query --query=\"select key,value from " + DATA_PAR_REGION_NAME_PATH
+        + ".entries\"";
+
+    gfsh.executeAndAssertThat(query).statusIsSuccess()
+        .containsOutput(uuidKey);
+    gfsh.executeAndAssertThat(query1).statusIsSuccess()
+        .containsOutput(uuidKey, "value");
+  }
+
+  @Test
   public void testQueryEvictedDataDeserializable() {
     server1.invoke(() -> setupReplicatedRegionWithEviction(DATA_REGION_WITH_EVICTION_NAME));
     locator.waitUntilRegionIsReadyOnExactlyThisManyServers(DATA_REGION_WITH_EVICTION_NAME_PATH, 1);
@@ -220,6 +236,13 @@ public class QueryCommandDUnitTestBase {
     dataRegion.put(2, "value%");
   }
 
+  private static void prepareDataForRegionWithUUID(String regionPath) {
+    InternalCache cache = ClusterStartupRule.getCache();
+    Region<UUID, String> dataRegion = cache.getRegion(regionPath);
+
+    dataRegion.put(new UUID(1, 1), "value");
+  }
+
   private static void prepareNotDeserializableDataForRegion(String regionPath) {
     InternalCache cache = ClusterStartupRule.getCache();
     Region dataRegion = cache.getRegion(regionPath);
diff --git a/geode-gfsh/src/main/java/org/apache/geode/management/internal/cli/domain/DataCommandResult.java b/geode-gfsh/src/main/java/org/apache/geode/management/internal/cli/domain/DataCommandResult.java
index 3f00a95..6bd5fcd 100644
--- a/geode-gfsh/src/main/java/org/apache/geode/management/internal/cli/domain/DataCommandResult.java
+++ b/geode-gfsh/src/main/java/org/apache/geode/management/internal/cli/domain/DataCommandResult.java
@@ -19,6 +19,7 @@ import java.util.ArrayList;
 import java.util.LinkedHashMap;
 import java.util.List;
 import java.util.Map;
+import java.util.UUID;
 
 import com.fasterxml.jackson.core.JsonProcessingException;
 import com.fasterxml.jackson.databind.JsonNode;
@@ -687,6 +688,8 @@ public class DataCommandResult implements Serializable {
         resolvePdxToColumns(columnData, (PdxInstance) value);
       } else if (value instanceof Struct) {
         resolveStructToColumns(columnData, (StructImpl) value);
+      } else if (value instanceof UUID) {
+        columnData.put("Result", valueToJson(value));
       } else {
         ObjectMapper mapper = new ObjectMapper();
         JsonNode node = mapper.valueToTree(value);