From 5e9e703ceebcd8e114bb9f12dd847beef7dc1869 Mon Sep 17 00:00:00 2001 From: liangbowen Date: Wed, 29 Nov 2023 00:10:58 +0800 Subject: [PATCH] move PATTERN_FOR_KEY_VALUE_ARG from Utils to CommandLineUtils --- kyuubi-common/src/main/scala/org/apache/kyuubi/Utils.scala | 2 -- .../org/apache/kyuubi/util/command/CommandLineUtils.scala | 2 ++ .../org/apache/kyuubi/util/command/CommandUtilsSuite.scala | 7 +++++-- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/kyuubi-common/src/main/scala/org/apache/kyuubi/Utils.scala b/kyuubi-common/src/main/scala/org/apache/kyuubi/Utils.scala index 60f1c3ea52f..df5a8f0bc50 100644 --- a/kyuubi-common/src/main/scala/org/apache/kyuubi/Utils.scala +++ b/kyuubi-common/src/main/scala/org/apache/kyuubi/Utils.scala @@ -339,8 +339,6 @@ object Utils extends Logging { val REDACTION_REPLACEMENT_TEXT = "*********(redacted)" - private val PATTERN_FOR_KEY_VALUE_ARG = "(.+?)=(.+)".r - def redactCommandLineArgs(conf: KyuubiConf, commands: Iterable[String]): Iterable[String] = { val redactionPattern = conf.get(SERVER_SECRET_REDACTION_PATTERN) var nextKV = false diff --git a/kyuubi-util-scala/src/main/scala/org/apache/kyuubi/util/command/CommandLineUtils.scala b/kyuubi-util-scala/src/main/scala/org/apache/kyuubi/util/command/CommandLineUtils.scala index 137c7ec6cb7..c06bd05bf8a 100644 --- a/kyuubi-util-scala/src/main/scala/org/apache/kyuubi/util/command/CommandLineUtils.scala +++ b/kyuubi-util-scala/src/main/scala/org/apache/kyuubi/util/command/CommandLineUtils.scala @@ -22,6 +22,8 @@ import java.io.File object CommandLineUtils { val CONF = "--conf" + val PATTERN_FOR_KEY_VALUE_ARG = "(.+?)=(.+)".r + /** * The Java command's option name for classpath */ diff --git a/kyuubi-util-scala/src/test/scala/org/apache/kyuubi/util/command/CommandUtilsSuite.scala b/kyuubi-util-scala/src/test/scala/org/apache/kyuubi/util/command/CommandUtilsSuite.scala index f961b83bffa..e000e7478b6 100644 --- a/kyuubi-util-scala/src/test/scala/org/apache/kyuubi/util/command/CommandUtilsSuite.scala +++ b/kyuubi-util-scala/src/test/scala/org/apache/kyuubi/util/command/CommandUtilsSuite.scala @@ -15,11 +15,10 @@ * limitations under the License. */ package org.apache.kyuubi.util.command - // scalastyle:off import org.scalatest.funsuite.AnyFunSuite -// scalastyle:on +import org.apache.kyuubi.util.AssertionUtils._ import org.apache.kyuubi.util.command.CommandLineUtils._ // scalastyle:off @@ -30,6 +29,10 @@ class CommandUtilsSuite extends AnyFunSuite { assertResult("abc=123")(genKeyValuePair("abc", "123")) assertResult("abc=123")(genKeyValuePair(" abc", "123 ")) assertResult("abc.def=xyz.123")(genKeyValuePair("abc.def", "xyz.123")) + + assertMatches(genKeyValuePair("abc", "123"), PATTERN_FOR_KEY_VALUE_ARG) + assertMatches(genKeyValuePair(" abc", "123 "), PATTERN_FOR_KEY_VALUE_ARG) + assertMatches(genKeyValuePair("abc.def", "xyz.123"), PATTERN_FOR_KEY_VALUE_ARG) } test("assemble key value pair with config option") {