Skip to content

Commit 9482906

Browse files
committed
[SPARK-41385][K8S] Replace deprecated .newInstance() in K8s module
### What changes were proposed in this pull request? This PR aims to replace the deprecated `Class.newInstance` with `Class.getConstructor.newInstance`. ### Why are the changes needed? SPARK-25984 removed these instances at Spark 3.0.0. SPARK-37145 introduced newly two instances at Spark 3.3.0. ``` $ git grep classForName | grep newInstance | grep -v getConstructor resource-managers/kubernetes/core/src/main/scala/org/apache/spark/deploy/k8s/submit/KubernetesDriverBuilder.scala: val feature = Utils.classForName[Any](className).newInstance() resource-managers/kubernetes/core/src/main/scala/org/apache/spark/scheduler/cluster/k8s/KubernetesExecutorBuilder.scala: val feature = Utils.classForName[Any](className).newInstance() ``` ### Does this PR introduce _any_ user-facing change? No. ### How was this patch tested? Pass the CIs. Closes #38909 from dongjoon-hyun/SPARK-41385. Authored-by: Dongjoon Hyun <dhyun@apple.com> Signed-off-by: Dongjoon Hyun <dongjoon@apache.org>
1 parent a383dde commit 9482906

2 files changed

Lines changed: 2 additions & 2 deletions

File tree

resource-managers/kubernetes/core/src/main/scala/org/apache/spark/deploy/k8s/submit/KubernetesDriverBuilder.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ private[spark] class KubernetesDriverBuilder {
4040

4141
val userFeatures = conf.get(Config.KUBERNETES_DRIVER_POD_FEATURE_STEPS)
4242
.map { className =>
43-
val feature = Utils.classForName[Any](className).newInstance()
43+
val feature = Utils.classForName[Any](className).getConstructor().newInstance()
4444
val initializedFeature = feature match {
4545
// Since 3.3, allow user to implement feature with KubernetesDriverConf
4646
case d: KubernetesDriverCustomFeatureConfigStep =>

resource-managers/kubernetes/core/src/main/scala/org/apache/spark/scheduler/cluster/k8s/KubernetesExecutorBuilder.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ private[spark] class KubernetesExecutorBuilder {
4343

4444
val userFeatures = conf.get(Config.KUBERNETES_EXECUTOR_POD_FEATURE_STEPS)
4545
.map { className =>
46-
val feature = Utils.classForName[Any](className).newInstance()
46+
val feature = Utils.classForName[Any](className).getConstructor().newInstance()
4747
val initializedFeature = feature match {
4848
// Since 3.3, allow user to implement feature with KubernetesExecutorConf
4949
case e: KubernetesExecutorCustomFeatureConfigStep =>

0 commit comments

Comments
 (0)