Skip to content

Commit a4fc0e0

Browse files
committed
Update RDDOperationScope.scala
1 parent 490d5a7 commit a4fc0e0

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

core/src/main/scala/org/apache/spark/rdd/RDDOperationScope.scala

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -95,17 +95,17 @@ private[spark] object RDDOperationScope extends Logging {
9595
private[spark] def withScope[T](
9696
sc: SparkContext,
9797
allowNesting: Boolean = false)(body: => T): T = {
98-
val stackTrace = Thread.currentThread.getStackTrace().tail // ignore "Thread#getStackTrace"
99-
val ourMethodName = stackTrace(1).getMethodName // i.e. withScope
100-
// Climb upwards to find the first method that's called something different
101-
val callerMethodName = stackTrace
102-
.find(_.getMethodName != ourMethodName)
98+
99+
val callerMethodName = Thread.currentThread.getStackTrace()
100+
.dropWhile(! _.getMethodName().equals("withScope"))
101+
.find(_.getMethodName != "withScope")
103102
.map(_.getMethodName)
104103
.getOrElse {
105104
// Log a warning just in case, but this should almost certainly never happen
106105
logWarning("No valid method name for this RDD operation scope!")
107106
"N/A"
108107
}
108+
109109
withScope[T](sc, callerMethodName, allowNesting, ignoreParent = false)(body)
110110
}
111111

0 commit comments

Comments
 (0)