World's most powerful open data catalog for building a high-performance, geo-distributed and federated metadata lake.
Java ai-catalogdata-catalogdatalakefederated-querylakehousemetadatametalakemodel-catalogopendatacatalogskycomputingstratosphere
[#3165] fix(client-java): Fix the http client `toJson` encode without UTF-8 (#3179)
xloyad6fe135ec464
diff --git a/catalogs/catalog-hadoop/src/test/java/com/datastrato/gravitino/catalog/hadoop/integration/test/HadoopCatalogIT.java b/catalogs/catalog-hadoop/src/test/java/com/datastrato/gravitino/catalog/hadoop/integration/test/HadoopCatalogIT.javaindex 916f7c6183..6668d7fb69 100644--- a/catalogs/catalog-hadoop/src/test/java/com/datastrato/gravitino/catalog/hadoop/integration/test/HadoopCatalogIT.java+++ b/catalogs/catalog-hadoop/src/test/java/com/datastrato/gravitino/catalog/hadoop/integration/test/HadoopCatalogIT.java@@ -197,6 +197,33 @@ public class HadoopCatalogIT extends AbstractIT {Fileset.Type.MANAGED, fileset3.type(), "fileset type should be MANAGED by default");}+ @Test+ public void testCreateFilesetWithChinese() throws IOException {+ // create fileset+ String filesetName = "test_create_fileset_with_chinese";+ String storageLocation = storageLocation(filesetName) + "/中文目录test";+ Assertions.assertFalse(+ hdfs.exists(new Path(storageLocation)), "storage location should not exists");+ Fileset fileset =+ createFileset(+ filesetName,+ "这是中文comment",+ Fileset.Type.MANAGED,+ storageLocation,+ ImmutableMap.of("k1", "v1", "test", "中文测试test", "中文key", "test1"));++ // verify fileset is created+ assertFilesetExists(filesetName);+ Assertions.assertNotNull(fileset, "fileset should be created");+ Assertions.assertEquals("这是中文comment", fileset.comment());+ Assertions.assertEquals(Fileset.Type.MANAGED, fileset.type());+ Assertions.assertEquals(storageLocation, fileset.storageLocation());+ Assertions.assertEquals(3, fileset.properties().size());+ Assertions.assertEquals("v1", fileset.properties().get("k1"));+ Assertions.assertEquals("中文测试test", fileset.properties().get("test"));+ Assertions.assertEquals("test1", fileset.properties().get("中文key"));+ }+@Testpublic void testExternalFileset() throws IOException {// create filesetdiff --git a/clients/client-java/src/main/java/com/datastrato/gravitino/client/HTTPClient.java b/clients/client-java/src/main/java/com/datastrato/gravitino/client/HTTPClient.javaindex 71d10f4aea..74ed72cafe 100644--- a/clients/client-java/src/main/java/com/datastrato/gravitino/client/HTTPClient.java+++ b/clients/client-java/src/main/java/com/datastrato/gravitino/client/HTTPClient.java@@ -785,7 +785,7 @@ public class HTTPClient implements RESTClient {private StringEntity toJson(Object requestBody) {try {- return new StringEntity(mapper.writeValueAsString(requestBody));+ return new StringEntity(mapper.writeValueAsString(requestBody), StandardCharsets.UTF_8);} catch (JsonProcessingException e) {throw new RESTException(e, "Failed to write request body: %s", requestBody);}diff --git a/integration-test/src/test/java/com/datastrato/gravitino/integration/test/client/CatalogIT.java b/integration-test/src/test/java/com/datastrato/gravitino/integration/test/client/CatalogIT.javaindex bc86ef25a9..451986eeea 100644--- a/integration-test/src/test/java/com/datastrato/gravitino/integration/test/client/CatalogIT.java+++ b/integration-test/src/test/java/com/datastrato/gravitino/integration/test/client/CatalogIT.java@@ -112,6 +112,27 @@ public class CatalogIT extends AbstractIT {metalake.dropCatalog(catalogIdent);}+ @Test+ public void testCreateCatalogWithChinese() {+ String catalogName = GravitinoITUtils.genRandomName("catalogz");+ NameIdentifier catalogIdent = NameIdentifier.of(metalakeName, catalogName);+ Assertions.assertFalse(metalake.catalogExists(catalogIdent));++ Map<String, String> properties = Maps.newHashMap();+ properties.put("metastore.uris", hmsUri);+ metalake.createCatalog(+ catalogIdent, Catalog.Type.RELATIONAL, "hive", "这是中文comment", properties);+ Assertions.assertTrue(metalake.catalogExists(catalogIdent));+ Catalog catalog = metalake.loadCatalog(catalogIdent);+ Assertions.assertEquals(catalogName, catalog.name());+ Assertions.assertEquals(Catalog.Type.RELATIONAL, catalog.type());+ Assertions.assertEquals("hive", catalog.provider());+ Assertions.assertEquals("这是中文comment", catalog.comment());+ Assertions.assertTrue(catalog.properties().containsKey("metastore.uris"));++ metalake.dropCatalog(catalogIdent);+ }+@Testpublic void testListCatalogsInfo() {String relCatalogName = GravitinoITUtils.genRandomName("rel_catalog_");diff --git a/integration-test/src/test/java/com/datastrato/gravitino/integration/test/client/MetalakeIT.java b/integration-test/src/test/java/com/datastrato/gravitino/integration/test/client/MetalakeIT.javaindex 11abdd53f3..d51f53029b 100644--- a/integration-test/src/test/java/com/datastrato/gravitino/integration/test/client/MetalakeIT.java+++ b/integration-test/src/test/java/com/datastrato/gravitino/integration/test/client/MetalakeIT.java@@ -157,6 +157,25 @@ public class MetalakeIT extends AbstractIT {});}+ @Test+ public void testCreateMetalakeWithChinese() {+ client.createMetalake(+ NameIdentifier.parse(metalakeNameA), "这是中文comment", Collections.emptyMap());+ GravitinoMetalake metalake = client.loadMetalake(NameIdentifier.of(metalakeNameA));+ assertEquals(metalakeNameA, metalake.name());+ assertEquals("这是中文comment", metalake.comment());+ assertEquals(AuthConstants.ANONYMOUS_USER, metalake.auditInfo().creator());++ // Test metalake name already exists+ Map<String, String> emptyMap = Collections.emptyMap();+ NameIdentifier exists = NameIdentifier.parse(metalakeNameA);+ assertThrows(+ MetalakeAlreadyExistsException.class,+ () -> {+ client.createMetalake(exists, "metalake A comment", emptyMap);+ });+ }+@Testpublic void testDropMetalakes() {GravitinoMetalake metalakeA =