From 2b6ef5606bec1a4547c8e850440bf12cc3422e1d Mon Sep 17 00:00:00 2001 From: William Hyun Date: Sat, 19 Dec 2020 14:19:44 -0800 Subject: [PATCH] [SPARK-33854][BUILD] Use ListBuffer instead of Stack in SparkBuild.scala ### What changes were proposed in this pull request? This PR aims to use ListBuffer instead of Stack in SparkBuild.scala to remove deprecation warning. ### Why are the changes needed? Stack is deprecated in Scala 2.12.0. ```scala % build/sbt compile ... [warn] /Users/william/spark/project/SparkBuild.scala:1112:25: class Stack in package mutable is deprecated (since 2.12.0): Stack is an inelegant and potentially poorly-performing wrapper around List. Use a List assigned to a var instead. [warn] val stack = new Stack[File]() ``` ### Does this PR introduce _any_ user-facing change? No. ### How was this patch tested? Manual. Closes #30860 from williamhyun/SPARK-33854. Authored-by: William Hyun Signed-off-by: Dongjoon Hyun --- project/SparkBuild.scala | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/project/SparkBuild.scala b/project/SparkBuild.scala index 3098060478..aa3e2cd65e 100644 --- a/project/SparkBuild.scala +++ b/project/SparkBuild.scala @@ -23,7 +23,7 @@ import java.util.Locale import scala.io.Source import scala.util.Properties import scala.collection.JavaConverters._ -import scala.collection.mutable.Stack +import scala.collection.mutable.ListBuffer import sbt._ import sbt.Classpaths.publishTask @@ -1109,14 +1109,14 @@ object TestSettings { // Because File.mkdirs() can fail if multiple callers are trying to create the same // parent directory, this code tries to create parents one at a time, and avoids // failures when the directories have been created by somebody else. - val stack = new Stack[File]() + val stack = new ListBuffer[File]() while (!dir.isDirectory()) { - stack.push(dir) + stack.prepend(dir) dir = dir.getParentFile() } while (stack.nonEmpty) { - val d = stack.pop() + val d = stack.remove(0) require(d.mkdir() || d.isDirectory(), s"Failed to create directory $d") } }