From a4fc0e025d41d197c55ce43bca14ef669aa9bc68 Mon Sep 17 00:00:00 2001 From: a-roberts Date: Tue, 9 Jun 2015 19:01:43 +0100 Subject: [PATCH 1/2] Update RDDOperationScope.scala --- .../scala/org/apache/spark/rdd/RDDOperationScope.scala | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/core/src/main/scala/org/apache/spark/rdd/RDDOperationScope.scala b/core/src/main/scala/org/apache/spark/rdd/RDDOperationScope.scala index 6b09dfafc889c..0bbca1e719869 100644 --- a/core/src/main/scala/org/apache/spark/rdd/RDDOperationScope.scala +++ b/core/src/main/scala/org/apache/spark/rdd/RDDOperationScope.scala @@ -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) } From 13ce390e79cc67e9719ef2779134629367a34bda Mon Sep 17 00:00:00 2001 From: Adam Roberts Date: Wed, 10 Jun 2015 11:27:18 +0100 Subject: [PATCH 2/2] Ensure consistency with String equality checking --- .../src/main/scala/org/apache/spark/rdd/RDDOperationScope.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/src/main/scala/org/apache/spark/rdd/RDDOperationScope.scala b/core/src/main/scala/org/apache/spark/rdd/RDDOperationScope.scala index 0bbca1e719869..a0dc55db27682 100644 --- a/core/src/main/scala/org/apache/spark/rdd/RDDOperationScope.scala +++ b/core/src/main/scala/org/apache/spark/rdd/RDDOperationScope.scala @@ -97,7 +97,7 @@ private[spark] object RDDOperationScope extends Logging { allowNesting: Boolean = false)(body: => T): T = { val callerMethodName = Thread.currentThread.getStackTrace() - .dropWhile(! _.getMethodName().equals("withScope")) + .dropWhile(_.getMethodName != "withScope") .find(_.getMethodName != "withScope") .map(_.getMethodName) .getOrElse {