Skip to content

Commit

Permalink
Update RDDOperationScope.scala
Browse files Browse the repository at this point in the history
  • Loading branch information
a-roberts committed Jun 9, 2015
1 parent 490d5a7 commit a4fc0e0
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions core/src/main/scala/org/apache/spark/rdd/RDDOperationScope.scala
Original file line number Diff line number Diff line change
Expand Up @@ -95,17 +95,17 @@ private[spark] object RDDOperationScope extends Logging {
private[spark] def withScope[T](
sc: SparkContext,
allowNesting: Boolean = false)(body: => T): T = {
val stackTrace = Thread.currentThread.getStackTrace().tail // ignore "Thread#getStackTrace"
val ourMethodName = stackTrace(1).getMethodName // i.e. withScope
// Climb upwards to find the first method that's called something different
val callerMethodName = stackTrace
.find(_.getMethodName != ourMethodName)

val callerMethodName = Thread.currentThread.getStackTrace()
.dropWhile(! _.getMethodName().equals("withScope"))
.find(_.getMethodName != "withScope")
.map(_.getMethodName)
.getOrElse {
// Log a warning just in case, but this should almost certainly never happen
logWarning("No valid method name for this RDD operation scope!")
"N/A"
}

withScope[T](sc, callerMethodName, allowNesting, ignoreParent = false)(body)
}

Expand Down

0 comments on commit a4fc0e0

Please sign in to comment.