dongjoon-hyun commented on code in PR #49858:
URL: https://github.com/apache/spark/pull/49858#discussion_r1949800667


##########
core/src/main/scala/org/apache/spark/util/Utils.scala:
##########
@@ -3151,9 +3152,31 @@ private[spark] object Utils
   }
 }
 
-private[util] object CallerContext extends Logging {
-  val callerContextEnabled: Boolean =
-    SparkHadoopUtil.get.conf.getBoolean("hadoop.caller.context.enabled", false)
+private[spark] object CallerContext extends Logging {
+  var callerContextEnabled: Boolean = SparkHadoopUtil.get.conf.getBoolean(
+    HADOOP_CALLER_CONTEXT_ENABLED_KEY, HADOOP_CALLER_CONTEXT_ENABLED_DEFAULT)
+
+  /**
+   * Run a function with the caller context enabled flag overridden to the 
given value. Normally,
+   * the flag is initialized from Hadoop configuration once per JVM process 
and never changed. This
+   * function is intended only for use by tests that specifically need to 
control whether the caller
+   * context is enabled. The configured value will be restored after execution 
of the function.
+   *
+   * @param enabled override value for the caller context enabled flag
+   * @param func function to run
+   *
+   * VisibleForTesting
+   */
+  def withCallerContextEnabled[T](enabled: Boolean)(func: => T): T = {

Review Comment:
   This looks like a pure test-helper utility instead of `VisibleForTesting`. 
Do we have any benefit in `main` code?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to