Github user srowen commented on a diff in the pull request:

    https://github.com/apache/spark/pull/15377#discussion_r82141925
  
    --- Diff: core/src/main/scala/org/apache/spark/util/Utils.scala ---
    @@ -2474,25 +2474,35 @@ private[spark] class CallerContext(
        val context = "SPARK_" + from + appIdStr + appAttemptIdStr +
          jobIdStr + stageIdStr + stageAttemptIdStr + taskIdStr + 
taskAttemptNumberStr
     
    +   var callerContextSupported : Boolean = true
    +
       /**
        * Set up the caller context [[context]] by invoking Hadoop 
CallerContext API of
        * [[org.apache.hadoop.ipc.CallerContext]], which was added in hadoop 
2.8.
        */
       def setCurrentContext(): Boolean = {
    -    var succeed = false
    -    try {
    -      // scalastyle:off classforname
    -      val callerContext = 
Class.forName("org.apache.hadoop.ipc.CallerContext")
    -      val Builder = 
Class.forName("org.apache.hadoop.ipc.CallerContext$Builder")
    -      // scalastyle:on classforname
    -      val builderInst = 
Builder.getConstructor(classOf[String]).newInstance(context)
    -      val hdfsContext = Builder.getMethod("build").invoke(builderInst)
    -      callerContext.getMethod("setCurrent", callerContext).invoke(null, 
hdfsContext)
    -      succeed = true
    -    } catch {
    -      case NonFatal(e) => logInfo("Fail to set Spark caller context", e)
    +    if (!callerContextSupported) {
    +      false
    +    } else {
    +      try {
    +        // scalastyle:off classforname
    +        val callerContext = 
Class.forName("org.apache.hadoop.ipc.CallerContext")
    +        val Builder = 
Class.forName("org.apache.hadoop.ipc.CallerContext$Builder")
    +        // scalastyle:on classforname
    +        val builderInst = 
Builder.getConstructor(classOf[String]).newInstance(context)
    +        val hdfsContext = Builder.getMethod("build").invoke(builderInst)
    +        callerContext.getMethod("setCurrent", callerContext).invoke(null, 
hdfsContext)
    +        true
    +      } catch {
    +        case e : ClassNotFoundException =>
    +          logInfo("Fail to set Spark caller context: requires hadoop 2.8 
or later.", e)
    +          callerContextSupported = false
    +          false
    --- End diff --
    
    Just put `false` at the end of the method like before. Do you really want 
to log the exception at info level? it looks like a problem when it's not. 
Nits: Builder -> builder, hadoop -> Hadoop. Don't put a space before the 
colons, and the new callerContextSupported flag should be private.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to