You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hudi.apache.org by xu...@apache.org on 2022/10/31 09:17:49 UTC

[hudi] branch master updated: [HUDI-5096] Upgrade jcommander to 1.78 (#7068)

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

xushiyan pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/hudi.git


The following commit(s) were added to refs/heads/master by this push:
     new 455a3bd615 [HUDI-5096] Upgrade jcommander to 1.78 (#7068)
455a3bd615 is described below

commit 455a3bd615b0401341bed8a1c5030e1310850a5e
Author: Manu <36...@users.noreply.github.com>
AuthorDate: Mon Oct 31 17:17:38 2022 +0800

    [HUDI-5096] Upgrade jcommander to 1.78 (#7068)
    
    - resolves security vulnerability
    - resolves NPE issues with HiveSyncTool args parsing
    
    Co-authored-by: Raymond Xu <27...@users.noreply.github.com>
---
 .../org/apache/hudi/hive/TestHiveSyncToolArgs.java | 54 ++++++++++++++++++++++
 pom.xml                                            |  2 +-
 2 files changed, 55 insertions(+), 1 deletion(-)

diff --git a/hudi-sync/hudi-hive-sync/src/test/java/org/apache/hudi/hive/TestHiveSyncToolArgs.java b/hudi-sync/hudi-hive-sync/src/test/java/org/apache/hudi/hive/TestHiveSyncToolArgs.java
new file mode 100644
index 0000000000..40c69c4717
--- /dev/null
+++ b/hudi-sync/hudi-hive-sync/src/test/java/org/apache/hudi/hive/TestHiveSyncToolArgs.java
@@ -0,0 +1,54 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hudi.hive;
+
+import org.apache.hudi.common.config.TypedProperties;
+
+import com.beust.jcommander.JCommander;
+import org.junit.jupiter.api.Test;
+
+import static org.apache.hudi.hive.HiveSyncConfig.HIVE_SKIP_RO_SUFFIX_FOR_READ_OPTIMIZED_TABLE;
+import static org.apache.hudi.hive.HiveSyncConfig.HIVE_SYNC_AS_DATA_SOURCE_TABLE;
+import static org.apache.hudi.hive.HiveSyncConfig.HIVE_SYNC_MODE;
+import static org.apache.hudi.hive.HiveSyncConfig.HIVE_USE_JDBC;
+import static org.apache.hudi.sync.common.HoodieSyncConfig.META_SYNC_BASE_PATH;
+import static org.apache.hudi.sync.common.HoodieSyncConfig.META_SYNC_TABLE_NAME;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+public class TestHiveSyncToolArgs {
+
+  @Test
+  public void testArgsParse() {
+    HiveSyncConfig.HiveSyncConfigParams params = new HiveSyncConfig.HiveSyncConfigParams();
+    JCommander cmd = JCommander.newBuilder().addObject(params).build();
+    String[] args = {"--sync-mode", "hms", "--base-path", "/table_path", "--table", "table_name",
+        "--spark-datasource"};
+    cmd.parse(args);
+
+    final TypedProperties props = params.toProps();
+    assertEquals("hms", props.getProperty(HIVE_SYNC_MODE.key()));
+    assertEquals("/table_path", props.getProperty(META_SYNC_BASE_PATH.key()));
+    assertEquals("table_name", props.getProperty(META_SYNC_TABLE_NAME.key()));
+    assertTrue(props.getBoolean(HIVE_SYNC_AS_DATA_SOURCE_TABLE.key()), "should be true because present in args");
+    assertFalse(props.contains(HIVE_USE_JDBC.key()), "should be not present due to not in args");
+    assertFalse(props.contains(HIVE_SKIP_RO_SUFFIX_FOR_READ_OPTIMIZED_TABLE.key()), "should be not present due to not in args");
+  }
+}
diff --git a/pom.xml b/pom.xml
index 27bec25b72..e97647b119 100644
--- a/pom.xml
+++ b/pom.xml
@@ -951,7 +951,7 @@
       <dependency>
         <groupId>com.beust</groupId>
         <artifactId>jcommander</artifactId>
-        <version>1.72</version>
+        <version>1.78</version>
       </dependency>
 
       <dependency>