Skip to content

Commit c717624

Browse files
morvenhuangLuciferYang
authored andcommitted
[SPARK-52800][SQL][K8S] Remove several deprecated commons-lang3 methods
### What changes were proposed in this pull request? This PR removes several deprecated commons-lang3 methods, including: - StringUtils.contains(CharSequence, CharSequence) - StringUtils.endsWith(CharSequence, CharSequence) - StringUtils.equals(CharSequence, CharSequence) - StringUtils.replace(String, String, String) ### Why are the changes needed? To clean up deprecated APIs. ### Does this PR introduce _any_ user-facing change? No. ### How was this patch tested? Pass GA. ### Was this patch authored or co-authored using generative AI tooling? No. Closes #51495 from morvenhuang/SPARK-52800. Authored-by: morvenhuang <[email protected]> Signed-off-by: yangjie01 <[email protected]>
1 parent a0fb5f0 commit c717624

File tree

5 files changed

+10
-9
lines changed

5 files changed

+10
-9
lines changed

resource-managers/kubernetes/integration-tests/src/test/scala/org/apache/spark/deploy/k8s/integrationtest/backend/cloud/KubeConfigBackend.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ package org.apache.spark.deploy.k8s.integrationtest.backend.cloud
1818

1919
import io.fabric8.kubernetes.client.{Config, KubernetesClient, KubernetesClientBuilder}
2020
import io.fabric8.kubernetes.client.utils.Utils
21-
import org.apache.commons.lang3.StringUtils
21+
import org.apache.commons.lang3.{Strings, StringUtils}
2222

2323
import org.apache.spark.deploy.k8s.integrationtest.TestConstants
2424
import org.apache.spark.deploy.k8s.integrationtest.backend.IntegrationTestBackend
@@ -48,7 +48,7 @@ private[spark] class KubeConfigBackend(var context: String)
4848
// Clean up master URL which would have been specified in Spark format into a normal
4949
// K8S master URL
5050
masterUrl = checkAndGetK8sMasterUrl(masterUrl).replaceFirst("k8s://", "")
51-
if (!StringUtils.equals(config.getMasterUrl, masterUrl)) {
51+
if (!Strings.CS.equals(config.getMasterUrl, masterUrl)) {
5252
logInfo(s"Overriding K8S master URL ${config.getMasterUrl} from K8S config file " +
5353
s"with user specified master URL ${masterUrl}")
5454
config.setMasterUrl(masterUrl)

sql/catalyst/src/main/scala/org/apache/spark/sql/connector/expressions/expressions.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
package org.apache.spark.sql.connector.expressions
1919

2020
import org.apache.commons.codec.binary.Hex
21-
import org.apache.commons.lang3.StringUtils
21+
import org.apache.commons.lang3.Strings
2222

2323
import org.apache.spark.SparkException
2424
import org.apache.spark.sql.catalyst
@@ -390,7 +390,7 @@ private[sql] object HoursTransform {
390390

391391
private[sql] final case class LiteralValue[T](value: T, dataType: DataType) extends Literal[T] {
392392
override def toString: String = dataType match {
393-
case StringType => s"'${StringUtils.replace(s"$value", "'", "''")}'"
393+
case StringType => s"'${Strings.CS.replace(s"$value", "'", "''")}'"
394394
case BinaryType =>
395395
assert(value.isInstanceOf[Array[Byte]])
396396
val bytes = value.asInstanceOf[Array[Byte]]

sql/core/src/main/scala/org/apache/spark/sql/jdbc/JdbcDialects.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import java.util.concurrent.TimeUnit
2626
import scala.collection.mutable.ArrayBuilder
2727
import scala.util.control.NonFatal
2828

29-
import org.apache.commons.lang3.StringUtils
29+
import org.apache.commons.lang3.Strings
3030

3131
import org.apache.spark.{SparkRuntimeException, SparkThrowable, SparkUnsupportedOperationException}
3232
import org.apache.spark.annotation.{DeveloperApi, Since}
@@ -354,7 +354,7 @@ abstract class JdbcDialect extends Serializable with Logging {
354354
*/
355355
@Since("2.3.0")
356356
protected[jdbc] def escapeSql(value: String): String =
357-
if (value == null) null else StringUtils.replace(value, "'", "''")
357+
if (value == null) null else Strings.CS.replace(value, "'", "''")
358358

359359
/**
360360
* Converts value to SQL expression.

sql/hive-thriftserver/src/main/java/org/apache/hive/service/auth/LdapAuthenticationProviderImpl.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
import javax.security.sasl.AuthenticationException;
2828

2929
import org.apache.commons.lang3.StringUtils;
30+
import org.apache.commons.lang3.Strings;
3031
import org.apache.hadoop.hive.conf.HiveConf;
3132
import org.apache.hive.service.ServiceUtils;
3233

@@ -70,7 +71,7 @@ public void Authenticate(String user, String password) throws AuthenticationExce
7071
} else {
7172
String[] patterns = userDNPattern.split(":");
7273
for (String pattern : patterns) {
73-
if (StringUtils.contains(pattern, ",") && StringUtils.contains(pattern, "=")) {
74+
if (Strings.CS.contains(pattern, ",") && Strings.CS.contains(pattern, "=")) {
7475
candidatePrincipals.add(pattern.replaceAll("%s", user));
7576
}
7677
}

sql/hive-thriftserver/src/main/scala/org/apache/spark/sql/hive/thriftserver/SparkSQLCLIDriver.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ import scala.jdk.CollectionConverters._
2727
import jline.console.ConsoleReader
2828
import jline.console.completer.{ArgumentCompleter, Completer, StringsCompleter}
2929
import jline.console.history.FileHistory
30-
import org.apache.commons.lang3.StringUtils
30+
import org.apache.commons.lang3.{Strings, StringUtils}
3131
import org.apache.hadoop.conf.Configuration
3232
import org.apache.hadoop.hive.cli.{CliDriver, CliSessionState, OptionsProcessor}
3333
import org.apache.hadoop.hive.common.HiveInterruptUtils
@@ -573,7 +573,7 @@ private[hive] class SparkSQLCLIDriver extends CliDriver with Logging {
573573
val commands = splitSemiColon(line).asScala
574574
var command: String = ""
575575
for (oneCmd <- commands) {
576-
if (StringUtils.endsWith(oneCmd, "\\")) {
576+
if (Strings.CS.endsWith(oneCmd, "\\")) {
577577
command += StringUtils.chop(oneCmd) + ";"
578578
} else {
579579
command += oneCmd

0 commit comments

Comments
 (0)