diff --git a/common/utils/src/main/scala/org/apache/spark/util/MavenUtils.scala b/common/utils/src/main/scala/org/apache/spark/util/MavenUtils.scala index 42a1d1612aee..d54a2f2ed9ce 100644 --- a/common/utils/src/main/scala/org/apache/spark/util/MavenUtils.scala +++ b/common/utils/src/main/scala/org/apache/spark/util/MavenUtils.scala @@ -342,7 +342,7 @@ private[spark] object MavenUtils extends Logging { } /* Set ivy settings for location of cache, if option is supplied */ - private def processIvyPathArg(ivySettings: IvySettings, ivyPath: Option[String]): Unit = { + private[util] def processIvyPathArg(ivySettings: IvySettings, ivyPath: Option[String]): Unit = { val alternateIvyDir = ivyPath.filterNot(_.trim.isEmpty).getOrElse { // To protect old Ivy-based systems like old Spark from Apache Ivy 2.5.2's incompatibility. System.getProperty("ivy.home", diff --git a/common/utils/src/test/scala/org/apache/spark/util/IvyTestUtils.scala b/common/utils/src/test/scala/org/apache/spark/util/IvyTestUtils.scala index 76062074edca..140de836622f 100644 --- a/common/utils/src/test/scala/org/apache/spark/util/IvyTestUtils.scala +++ b/common/utils/src/test/scala/org/apache/spark/util/IvyTestUtils.scala @@ -365,7 +365,7 @@ private[spark] object IvyTestUtils { useIvyLayout: Boolean = false, withPython: Boolean = false, withR: Boolean = false, - ivySettings: IvySettings = new IvySettings)(f: String => Unit): Unit = { + ivySettings: IvySettings = defaultIvySettings())(f: String => Unit): Unit = { val deps = dependencies.map(MavenUtils.extractMavenCoordinates) purgeLocalIvyCache(artifact, deps, ivySettings) val repo = createLocalRepositoryForTests(artifact, dependencies, rootDir, useIvyLayout, @@ -401,4 +401,16 @@ private[spark] object IvyTestUtils { } } } + + /** + * Creates and initializes a new instance of IvySettings with default configurations. + * The method processes the Ivy path argument using MavenUtils to ensure proper setup. + * + * @return A newly created and configured instance of IvySettings. + */ + private def defaultIvySettings(): IvySettings = { + val settings = new IvySettings + MavenUtils.processIvyPathArg(ivySettings = settings, ivyPath = None) + settings + } }