You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by te...@apache.org on 2024/03/27 08:36:41 UTC

(pulsar) branch master updated: [cleanup][cli] Cleanup jcommander (#22337)

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

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


The following commit(s) were added to refs/heads/master by this push:
     new d23a8f64acb [cleanup][cli] Cleanup jcommander (#22337)
d23a8f64acb is described below

commit d23a8f64acbfb4179b9f2f64e1e9dd0756742a5b
Author: Zixuan Liu <no...@gmail.com>
AuthorDate: Wed Mar 27 16:36:36 2024 +0800

    [cleanup][cli] Cleanup jcommander (#22337)
    
    Signed-off-by: Zixuan Liu <no...@gmail.com>
---
 distribution/shell/src/assemble/LICENSE.bin.txt    |  1 -
 pom.xml                                            |  7 ---
 pulsar-cli-utils/pom.xml                           |  5 --
 .../cli/converters/TimeUnitToSecondsConverter.java | 42 --------------
 .../validators/IntegerMaxValueLongValidator.java   | 30 ----------
 .../cli/validators/MinNegativeOneValidator.java    | 30 ----------
 .../cli/validators/NonNegativeValueValidator.java  | 30 ----------
 .../validators/PositiveIntegerValueValidator.java  | 31 -----------
 .../cli/validators/PositiveLongValueValidator.java | 31 -----------
 .../apache/pulsar/cli/validators/package-info.java | 19 -------
 .../pulsar/cli/converters/TimeConversionTest.java  |  5 +-
 .../cli/validators/CliUtilValidatorsTest.java      | 64 ----------------------
 .../cli/utils/NameValueParameterSplitterTest.java  | 52 ------------------
 .../apache/pulsar/admin/cli/utils/CmdUtils.java    | 11 ++--
 .../cli/utils/NameValueParameterSplitter.java      | 61 ---------------------
 .../org/apache/pulsar/client/cli/CmdProduce.java   |  9 ++-
 .../java/org/apache/pulsar/client/cli/CmdRead.java |  3 +-
 .../apache/pulsar/admin/cli/TestCmdSources.java    |  3 +-
 18 files changed, 14 insertions(+), 420 deletions(-)

diff --git a/distribution/shell/src/assemble/LICENSE.bin.txt b/distribution/shell/src/assemble/LICENSE.bin.txt
index 2b2f1c26be1..e735bd454ee 100644
--- a/distribution/shell/src/assemble/LICENSE.bin.txt
+++ b/distribution/shell/src/assemble/LICENSE.bin.txt
@@ -309,7 +309,6 @@ pulsar-client-cpp/lib/checksum/crc32c_sw.cc
 This projects includes binary packages with the following licenses:
 
 The Apache Software License, Version 2.0
- * JCommander -- jcommander-1.82.jar
  * Picocli
      - picocli-4.7.5.jar
      - picocli-shell-jline3-4.7.5.jar
diff --git a/pom.xml b/pom.xml
index caa2fc49b27..da7f2c76421 100644
--- a/pom.xml
+++ b/pom.xml
@@ -213,7 +213,6 @@ flexible messaging model and an intuitive client API.</description>
     <confluent.version>6.2.8</confluent.version>
     <aircompressor.version>0.20</aircompressor.version>
     <asynchttpclient.version>2.12.1</asynchttpclient.version>
-    <jcommander.version>1.82</jcommander.version>
     <commons-lang3.version>3.11</commons-lang3.version>
     <commons-configuration.version>1.10</commons-configuration.version>
     <commons-io.version>2.8.0</commons-io.version>
@@ -693,12 +692,6 @@ flexible messaging model and an intuitive client API.</description>
         <classifier>linux-aarch_64</classifier>
       </dependency>
 
-      <dependency>
-        <groupId>com.beust</groupId>
-        <artifactId>jcommander</artifactId>
-        <version>${jcommander.version}</version>
-      </dependency>
-
       <dependency>
         <groupId>info.picocli</groupId>
         <artifactId>picocli</artifactId>
diff --git a/pulsar-cli-utils/pom.xml b/pulsar-cli-utils/pom.xml
index ac442b4004e..1638029f4c8 100644
--- a/pulsar-cli-utils/pom.xml
+++ b/pulsar-cli-utils/pom.xml
@@ -35,11 +35,6 @@
   <description>Isolated CLI utility module</description>
 
   <dependencies>
-    <dependency>
-      <groupId>com.beust</groupId>
-      <artifactId>jcommander</artifactId>
-      <scope>compile</scope>
-    </dependency>
     <dependency>
       <groupId>info.picocli</groupId>
       <artifactId>picocli</artifactId>
diff --git a/pulsar-cli-utils/src/main/java/org/apache/pulsar/cli/converters/TimeUnitToSecondsConverter.java b/pulsar-cli-utils/src/main/java/org/apache/pulsar/cli/converters/TimeUnitToSecondsConverter.java
deleted file mode 100644
index 3aca2e95d25..00000000000
--- a/pulsar-cli-utils/src/main/java/org/apache/pulsar/cli/converters/TimeUnitToSecondsConverter.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * 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.pulsar.cli.converters;
-
-import static org.apache.pulsar.cli.ValueValidationUtil.emptyCheck;
-import com.beust.jcommander.ParameterException;
-import com.beust.jcommander.converters.BaseConverter;
-import java.util.concurrent.TimeUnit;
-
-public class TimeUnitToSecondsConverter extends BaseConverter<Long> {
-
-    public TimeUnitToSecondsConverter(String optionName) {
-        super(optionName);
-    }
-
-    @Override
-    public Long convert(String str) {
-        emptyCheck(getOptionName(), str);
-        try {
-            return TimeUnit.SECONDS.toSeconds(
-                    RelativeTimeUtil.parseRelativeTimeInSeconds(str.trim()));
-        } catch (IllegalArgumentException exception) {
-            throw new ParameterException("For input " + getOptionName() + ": " + exception.getMessage());
-        }
-    }
-}
diff --git a/pulsar-cli-utils/src/main/java/org/apache/pulsar/cli/validators/IntegerMaxValueLongValidator.java b/pulsar-cli-utils/src/main/java/org/apache/pulsar/cli/validators/IntegerMaxValueLongValidator.java
deleted file mode 100644
index 63115b14187..00000000000
--- a/pulsar-cli-utils/src/main/java/org/apache/pulsar/cli/validators/IntegerMaxValueLongValidator.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * 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.pulsar.cli.validators;
-
-import com.beust.jcommander.IValueValidator;
-import com.beust.jcommander.ParameterException;
-import org.apache.pulsar.cli.ValueValidationUtil;
-
-public class IntegerMaxValueLongValidator implements IValueValidator<Long> {
-    @Override
-    public void validate(String name, Long value) throws ParameterException {
-        ValueValidationUtil.maxValueCheck(name, value, Integer.MAX_VALUE);
-    }
-}
diff --git a/pulsar-cli-utils/src/main/java/org/apache/pulsar/cli/validators/MinNegativeOneValidator.java b/pulsar-cli-utils/src/main/java/org/apache/pulsar/cli/validators/MinNegativeOneValidator.java
deleted file mode 100644
index 320e36812bf..00000000000
--- a/pulsar-cli-utils/src/main/java/org/apache/pulsar/cli/validators/MinNegativeOneValidator.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * 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.pulsar.cli.validators;
-
-import com.beust.jcommander.IValueValidator;
-import com.beust.jcommander.ParameterException;
-import org.apache.pulsar.cli.ValueValidationUtil;
-
-public class MinNegativeOneValidator implements IValueValidator<Long> {
-    @Override
-    public void validate(String name, Long value) throws ParameterException {
-        ValueValidationUtil.minValueCheck(name, value, -1L);
-    }
-}
diff --git a/pulsar-cli-utils/src/main/java/org/apache/pulsar/cli/validators/NonNegativeValueValidator.java b/pulsar-cli-utils/src/main/java/org/apache/pulsar/cli/validators/NonNegativeValueValidator.java
deleted file mode 100644
index 473961be06d..00000000000
--- a/pulsar-cli-utils/src/main/java/org/apache/pulsar/cli/validators/NonNegativeValueValidator.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * 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.pulsar.cli.validators;
-
-import com.beust.jcommander.IValueValidator;
-import com.beust.jcommander.ParameterException;
-import org.apache.pulsar.cli.ValueValidationUtil;
-
-public class NonNegativeValueValidator implements IValueValidator<Long> {
-    @Override
-    public void validate(String name, Long value) throws ParameterException {
-        ValueValidationUtil.minValueCheck(name, value, 0L);
-    }
-}
diff --git a/pulsar-cli-utils/src/main/java/org/apache/pulsar/cli/validators/PositiveIntegerValueValidator.java b/pulsar-cli-utils/src/main/java/org/apache/pulsar/cli/validators/PositiveIntegerValueValidator.java
deleted file mode 100644
index c6b4cc43d68..00000000000
--- a/pulsar-cli-utils/src/main/java/org/apache/pulsar/cli/validators/PositiveIntegerValueValidator.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * 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.pulsar.cli.validators;
-
-import com.beust.jcommander.IValueValidator;
-import com.beust.jcommander.ParameterException;
-import org.apache.pulsar.cli.ValueValidationUtil;
-
-public class PositiveIntegerValueValidator implements IValueValidator<Integer> {
-
-    @Override
-    public void validate(String name, Integer value) throws ParameterException {
-        ValueValidationUtil.positiveCheck(name, value);
-    }
-}
diff --git a/pulsar-cli-utils/src/main/java/org/apache/pulsar/cli/validators/PositiveLongValueValidator.java b/pulsar-cli-utils/src/main/java/org/apache/pulsar/cli/validators/PositiveLongValueValidator.java
deleted file mode 100644
index 849a55241c6..00000000000
--- a/pulsar-cli-utils/src/main/java/org/apache/pulsar/cli/validators/PositiveLongValueValidator.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * 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.pulsar.cli.validators;
-
-import com.beust.jcommander.IValueValidator;
-import com.beust.jcommander.ParameterException;
-import org.apache.pulsar.cli.ValueValidationUtil;
-
-public class PositiveLongValueValidator implements IValueValidator<Long> {
-
-    @Override
-    public void validate(String name, Long value) throws ParameterException {
-        ValueValidationUtil.positiveCheck(name, value);
-    }
-}
diff --git a/pulsar-cli-utils/src/main/java/org/apache/pulsar/cli/validators/package-info.java b/pulsar-cli-utils/src/main/java/org/apache/pulsar/cli/validators/package-info.java
deleted file mode 100644
index 4d132b984c2..00000000000
--- a/pulsar-cli-utils/src/main/java/org/apache/pulsar/cli/validators/package-info.java
+++ /dev/null
@@ -1,19 +0,0 @@
-/*
- * 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.pulsar.cli.validators;
diff --git a/pulsar-cli-utils/src/test/java/org/apache/pulsar/cli/converters/TimeConversionTest.java b/pulsar-cli-utils/src/test/java/org/apache/pulsar/cli/converters/TimeConversionTest.java
index cc50eed4d03..451a215bce3 100644
--- a/pulsar-cli-utils/src/test/java/org/apache/pulsar/cli/converters/TimeConversionTest.java
+++ b/pulsar-cli-utils/src/test/java/org/apache/pulsar/cli/converters/TimeConversionTest.java
@@ -22,6 +22,7 @@ import static org.testng.Assert.assertEquals;
 import static org.testng.Assert.assertThrows;
 import java.util.concurrent.TimeUnit;
 import org.apache.pulsar.cli.converters.picocli.TimeUnitToMillisConverter;
+import org.apache.pulsar.cli.converters.picocli.TimeUnitToSecondsConverter;
 import org.testng.annotations.DataProvider;
 import org.testng.annotations.Test;
 
@@ -57,8 +58,8 @@ public class TimeConversionTest {
     }
 
     @Test(dataProvider = "successfulRelativeTimeUtilTestCases")
-    public void testSuccessfulTimeUnitToSecondsConverter(String input, long expected) {
-        TimeUnitToSecondsConverter secondsConverter = new TimeUnitToSecondsConverter("optionName");
+    public void testSuccessfulTimeUnitToSecondsConverter(String input, long expected) throws Exception {
+        TimeUnitToSecondsConverter secondsConverter = new TimeUnitToSecondsConverter();
         assertEquals(secondsConverter.convert(input), Long.valueOf(expected));
     }
 
diff --git a/pulsar-cli-utils/src/test/java/org/apache/pulsar/cli/validators/CliUtilValidatorsTest.java b/pulsar-cli-utils/src/test/java/org/apache/pulsar/cli/validators/CliUtilValidatorsTest.java
deleted file mode 100644
index ba7de233738..00000000000
--- a/pulsar-cli-utils/src/test/java/org/apache/pulsar/cli/validators/CliUtilValidatorsTest.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * 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.pulsar.cli.validators;
-
-import static org.testng.Assert.assertThrows;
-import org.testng.annotations.Test;
-
-public class CliUtilValidatorsTest {
-
-    @Test
-    public void testPositiveLongValueValidator() {
-        PositiveLongValueValidator validator = new PositiveLongValueValidator();
-        assertThrows(IllegalArgumentException.class, () -> validator.validate("param", -1L));
-        assertThrows(IllegalArgumentException.class, () -> validator.validate("param", 0L));
-        validator.validate("param", 1L);
-    }
-
-    @Test
-    public void testPositiveIntegerValueValidator() {
-        PositiveIntegerValueValidator validator = new PositiveIntegerValueValidator();
-        assertThrows(IllegalArgumentException.class, () -> validator.validate("param", -1));
-        assertThrows(IllegalArgumentException.class, () -> validator.validate("param", 0));
-        validator.validate("param", 1);
-    }
-
-    @Test
-    public void testNonNegativeValueValidator() {
-        NonNegativeValueValidator validator = new NonNegativeValueValidator();
-        assertThrows(IllegalArgumentException.class, () -> validator.validate("param", -1L));
-        validator.validate("param", 0L);
-        validator.validate("param", 1L);
-    }
-
-    @Test
-    public void testMinNegativeOneValidator() {
-        MinNegativeOneValidator validator = new MinNegativeOneValidator();
-        assertThrows(IllegalArgumentException.class, () -> validator.validate("param", -2L));
-        validator.validate("param", -1L);
-        validator.validate("param", 0L);
-    }
-
-    @Test
-    public void testIntegerMaxValueLongValidator() {
-        IntegerMaxValueLongValidator validator = new IntegerMaxValueLongValidator();
-        assertThrows(IllegalArgumentException.class, () -> validator.validate("param", Integer.MAX_VALUE + 1L));
-        validator.validate("param", (long) Integer.MAX_VALUE);
-    }
-}
diff --git a/pulsar-client-tools-test/src/test/java/org/apache/pulsar/admin/cli/utils/NameValueParameterSplitterTest.java b/pulsar-client-tools-test/src/test/java/org/apache/pulsar/admin/cli/utils/NameValueParameterSplitterTest.java
deleted file mode 100644
index 1bf4f3fedec..00000000000
--- a/pulsar-client-tools-test/src/test/java/org/apache/pulsar/admin/cli/utils/NameValueParameterSplitterTest.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * 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.pulsar.admin.cli.utils;
-
-import java.util.Map;
-
-import org.testng.Assert;
-import org.testng.annotations.Test;
-
-public class NameValueParameterSplitterTest {
-    @Test(description = "Basic Test")
-    public void test1() {
-        NameValueParameterSplitter splitter = new NameValueParameterSplitter();
-        Map<String, String> result = splitter.convert("Name=Sunnyvale");
-        Assert.assertEquals(result.get("Name"), "Sunnyvale");
-    }
-
-    @Test(description = "Check trimming of values")
-    public void test2() {
-        NameValueParameterSplitter splitter = new NameValueParameterSplitter();
-        Map<String, String> result = splitter.convert(" Name = Sunnyvale CA");
-        Assert.assertEquals(result.get("Name"), "Sunnyvale CA");
-    }
-
-    @Test(description = "Check error on invalid input")
-    public void test3() {
-        try {
-            NameValueParameterSplitter splitter = new NameValueParameterSplitter();
-            splitter.convert(" Name  Sunnyvale CA");
-            // Expecting exception
-            Assert.fail("' Name  Sunnyvale CA' is not a valid name value pair");
-        } catch (Exception e) {
-            // TODO: handle exception
-        }
-    }
-}
diff --git a/pulsar-client-tools/src/main/java/org/apache/pulsar/admin/cli/utils/CmdUtils.java b/pulsar-client-tools/src/main/java/org/apache/pulsar/admin/cli/utils/CmdUtils.java
index a4db39f9cc9..bfbd78601c4 100644
--- a/pulsar-client-tools/src/main/java/org/apache/pulsar/admin/cli/utils/CmdUtils.java
+++ b/pulsar-client-tools/src/main/java/org/apache/pulsar/admin/cli/utils/CmdUtils.java
@@ -18,7 +18,6 @@
  */
 package org.apache.pulsar.admin.cli.utils;
 
-import com.beust.jcommander.ParameterException;
 import com.fasterxml.jackson.databind.exc.InvalidFormatException;
 import com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException;
 import java.io.File;
@@ -40,7 +39,7 @@ public class CmdUtils {
                         unrecognizedPropertyException.getLocation().getLineNr(),
                         unrecognizedPropertyException.getLocation().getColumnNr(),
                         unrecognizedPropertyException.getKnownPropertyIds());
-                throw new ParameterException(exceptionMessage);
+                throw new IllegalArgumentException(exceptionMessage);
             } else if (ex instanceof InvalidFormatException) {
 
                 InvalidFormatException invalidFormatException = (InvalidFormatException) ex;
@@ -50,23 +49,23 @@ public class CmdUtils {
                         invalidFormatException.getLocation().getLineNr(),
                         invalidFormatException.getLocation().getColumnNr());
 
-                throw new ParameterException(exceptionMessage);
+                throw new IllegalArgumentException(exceptionMessage);
             } else {
-                throw new ParameterException(ex.getMessage());
+                throw new IllegalArgumentException(ex.getMessage());
             }
         }
     }
 
     public static boolean positiveCheck(String paramName, long value) {
         if (value <= 0) {
-            throw new ParameterException(paramName + " cannot be less than or equal to 0!");
+            throw new IllegalArgumentException(paramName + " cannot be less than or equal to 0!");
         }
         return true;
     }
 
     public static boolean maxValueCheck(String paramName, long value, long maxValue) {
         if (value > maxValue) {
-            throw new ParameterException(paramName + " cannot be greater than " + maxValue + "!");
+            throw new IllegalArgumentException(paramName + " cannot be greater than " + maxValue + "!");
         }
         return true;
     }
diff --git a/pulsar-client-tools/src/main/java/org/apache/pulsar/admin/cli/utils/NameValueParameterSplitter.java b/pulsar-client-tools/src/main/java/org/apache/pulsar/admin/cli/utils/NameValueParameterSplitter.java
deleted file mode 100644
index 011f93e18f1..00000000000
--- a/pulsar-client-tools/src/main/java/org/apache/pulsar/admin/cli/utils/NameValueParameterSplitter.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * 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.pulsar.admin.cli.utils;
-
-import com.beust.jcommander.IStringConverter;
-import com.beust.jcommander.ParameterException;
-import java.util.HashMap;
-import java.util.Map;
-
-public class NameValueParameterSplitter implements IStringConverter<Map<String, String>> {
-
-    @Override
-    public Map<String, String> convert(String value) {
-        boolean error = false;
-        Map<String, String> map = new HashMap<String, String>();
-
-        String[] nvpairs = value.split(",");
-
-        for (String nvpair : nvpairs) {
-            error = true;
-            if (nvpair != null) {
-                String[] nv = nvpair.split("=");
-                if (nv != null && nv.length == 2) {
-                    nv[0] = nv[0].trim();
-                    nv[1] = nv[1].trim();
-                    if (!nv[0].isEmpty() && !nv[1].isEmpty() && nv[0].charAt(0) != '\'') {
-                        map.put(nv[0], nv[1]);
-                        error = false;
-                    }
-                }
-            }
-
-            if (error) {
-                break;
-            }
-        }
-
-        if (error) {
-            throw new ParameterException("unable to parse bad name=value parameter list: " + value);
-        }
-
-        return map;
-    }
-
-}
diff --git a/pulsar-client-tools/src/main/java/org/apache/pulsar/client/cli/CmdProduce.java b/pulsar-client-tools/src/main/java/org/apache/pulsar/client/cli/CmdProduce.java
index b41aea4538c..e5a88366021 100644
--- a/pulsar-client-tools/src/main/java/org/apache/pulsar/client/cli/CmdProduce.java
+++ b/pulsar-client-tools/src/main/java/org/apache/pulsar/client/cli/CmdProduce.java
@@ -19,7 +19,6 @@
 package org.apache.pulsar.client.cli;
 
 import static org.apache.commons.lang3.StringUtils.isNotBlank;
-import com.beust.jcommander.ParameterException;
 import com.fasterxml.jackson.core.JsonProcessingException;
 import com.google.common.annotations.VisibleForTesting;
 import com.google.common.util.concurrent.RateLimiter;
@@ -270,7 +269,7 @@ public class CmdProduce extends AbstractCmd {
                 case KEY_VALUE_ENCODING_TYPE_INLINE:
                     break;
                 default:
-                    throw (new ParameterException("--key-value-encoding-type "
+                    throw (new IllegalArgumentException("--key-value-encoding-type "
                             + keyValueEncodingType + " is not valid, only 'separated' or 'inline'"));
             }
         }
@@ -279,7 +278,7 @@ public class CmdProduce extends AbstractCmd {
         if (totalMessages > MAX_MESSAGES) {
             String msg = "Attempting to send " + totalMessages + " messages. Please do not send more than "
                     + MAX_MESSAGES + " messages";
-            throw new ParameterException(msg);
+            throw new IllegalArgumentException(msg);
         }
 
         if (this.serviceURL.startsWith("ws")) {
@@ -322,13 +321,13 @@ public class CmdProduce extends AbstractCmd {
                 final byte[] keyValueKeyBytes;
                 if (this.keyValueKey != null) {
                     if (keyValueEncodingType == KEY_VALUE_ENCODING_TYPE_NOT_SET) {
-                        throw new ParameterException(
+                        throw new IllegalArgumentException(
                             "Key value encoding type must be set when using --key-value-key");
                     }
                     keyValueKeyBytes = this.keyValueKey.getBytes(StandardCharsets.UTF_8);
                 } else if (this.keyValueKeyFile != null) {
                     if (keyValueEncodingType == KEY_VALUE_ENCODING_TYPE_NOT_SET) {
-                        throw new ParameterException(
+                        throw new IllegalArgumentException(
                             "Key value encoding type must be set when using --key-value-key-file");
                     }
                     keyValueKeyBytes = Files.readAllBytes(Paths.get(this.keyValueKeyFile));
diff --git a/pulsar-client-tools/src/main/java/org/apache/pulsar/client/cli/CmdRead.java b/pulsar-client-tools/src/main/java/org/apache/pulsar/client/cli/CmdRead.java
index 2e0a3e826aa..daab4364992 100644
--- a/pulsar-client-tools/src/main/java/org/apache/pulsar/client/cli/CmdRead.java
+++ b/pulsar-client-tools/src/main/java/org/apache/pulsar/client/cli/CmdRead.java
@@ -19,7 +19,6 @@
 package org.apache.pulsar.client.cli;
 
 import static org.apache.commons.lang3.StringUtils.isNotBlank;
-import com.beust.jcommander.ParameterException;
 import com.google.common.annotations.VisibleForTesting;
 import com.google.common.util.concurrent.RateLimiter;
 import java.io.IOException;
@@ -114,7 +113,7 @@ public class CmdRead extends AbstractCmdConsume {
      */
     public int run() throws PulsarClientException, IOException {
         if (this.numMessagesToRead < 0) {
-            throw (new ParameterException("Number of messages should be zero or positive."));
+            throw (new IllegalArgumentException("Number of messages should be zero or positive."));
         }
 
 
diff --git a/pulsar-client-tools/src/test/java/org/apache/pulsar/admin/cli/TestCmdSources.java b/pulsar-client-tools/src/test/java/org/apache/pulsar/admin/cli/TestCmdSources.java
index 13a632121e0..d96b0933d3f 100644
--- a/pulsar-client-tools/src/test/java/org/apache/pulsar/admin/cli/TestCmdSources.java
+++ b/pulsar-client-tools/src/test/java/org/apache/pulsar/admin/cli/TestCmdSources.java
@@ -27,7 +27,6 @@ import static org.mockito.Mockito.spy;
 import static org.mockito.Mockito.verify;
 import static org.mockito.Mockito.when;
 import static org.testng.Assert.assertTrue;
-import com.beust.jcommander.ParameterException;
 import com.fasterxml.jackson.core.JsonProcessingException;
 import com.fasterxml.jackson.dataformat.yaml.YAMLMapper;
 import java.io.Closeable;
@@ -460,7 +459,7 @@ public class TestCmdSources {
     
     private void verifyNoSuchFileParameterException(org.apache.pulsar.admin.cli.CmdSources.SourceDetailsCommand command) {
         command.sourceConfigFile = UUID.randomUUID().toString();
-        ParameterException e = Assert.expectThrows(ParameterException.class, command::processArguments);
+        IllegalArgumentException e = Assert.expectThrows(IllegalArgumentException.class, command::processArguments);
         assertTrue(e.getMessage().endsWith("(No such file or directory)"));
     }