diff --git a/tools/src/main/java/org/apache/kafka/tools/ConnectPluginPath.java b/tools/src/main/java/org/apache/kafka/tools/ConnectPluginPath.java index db352e7e4c2..73987b6746c 100644 --- a/tools/src/main/java/org/apache/kafka/tools/ConnectPluginPath.java +++ b/tools/src/main/java/org/apache/kafka/tools/ConnectPluginPath.java @@ -16,6 +16,7 @@ */ package org.apache.kafka.tools; +import org.apache.kafka.common.config.ConfigException; import org.apache.kafka.common.utils.Exit; import org.apache.kafka.common.utils.Utils; import org.apache.kafka.connect.runtime.WorkerConfig; @@ -85,7 +86,7 @@ public class ConnectPluginPath { } catch (ArgumentParserException e) { parser.handleError(e); return 1; - } catch (TerseException e) { + } catch (TerseException | ConfigException e) { err.println(e.getMessage()); return 2; } catch (Throwable e) { @@ -199,17 +200,17 @@ public class ConnectPluginPath { return pluginLocations; } - private static void validatePluginPath(String pluginPath, String configName) throws TerseException { + private static void validatePluginPath(String pluginPath, String configName) throws ConfigException { String trimmed = pluginPath.trim(); if (trimmed.isEmpty()) { - throw new TerseException("'" + configName + "' must not be empty."); + throw new ConfigException("'" + configName + "' must not be empty."); } String[] pluginPathElements = COMMA_WITH_WHITESPACE.split(trimmed, -1); for (String path : pluginPathElements) { if (path.isEmpty()) { - throw new TerseException("'" + configName + "' values must not be empty."); + throw new ConfigException("'" + configName + "' values must not be empty."); } } } diff --git a/tools/src/test/java/org/apache/kafka/tools/ConnectPluginPathTest.java b/tools/src/test/java/org/apache/kafka/tools/ConnectPluginPathTest.java index 192161cc903..aff3f734ba7 100644 --- a/tools/src/test/java/org/apache/kafka/tools/ConnectPluginPathTest.java +++ b/tools/src/test/java/org/apache/kafka/tools/ConnectPluginPathTest.java @@ -341,7 +341,7 @@ public class ConnectPluginPathTest { "" ); assertNotEquals(0, res.returnCode); - assertTrue("'--plugin-path' must not be empty.\n".equals(res.err)); + assertEquals("'--plugin-path' must not be empty.\n", res.err); } @Test @@ -352,7 +352,7 @@ public class ConnectPluginPathTest { "location-a,,location-b" ); assertNotEquals(0, res.returnCode); - assertTrue("'--plugin-path' values must not be empty.\n".equals(res.err)); + assertEquals("'--plugin-path' values must not be empty.\n", res.err); } @Test @@ -370,7 +370,7 @@ public class ConnectPluginPathTest { configPath.toString() ); assertNotEquals(0, res.returnCode); - assertTrue("'plugin.path' must not be empty.\n".equals(res.err)); + assertEquals("'plugin.path' must not be empty.\n", res.err); } @Test @@ -388,7 +388,7 @@ public class ConnectPluginPathTest { configPath.toString() ); assertNotEquals(0, res.returnCode); - assertTrue("'plugin.path' values must not be empty.\n".equals(res.err)); + assertEquals("'plugin.path' values must not be empty.\n", res.err); } private static Map> assertListSuccess(CommandResult result) {