hddong commented on a change in pull request #25389: [SPARK-28657][CORE] Fix currentContext Instance failed sometimes URL: https://github.com/apache/spark/pull/25389#discussion_r320541496
########## File path: core/src/test/scala/org/apache/spark/util/UtilsSuite.scala ########## @@ -924,6 +926,24 @@ class UtilsSuite extends SparkFunSuite with ResetSystemProperties with Logging { } } + test("test class ClassCastException") { + // CallerContext added after hadoop-2.8.0 for HDFS-9184 + if (VersionInfo.getVersion >= "2.8") { + try { + val callerContext = Utils.classForName("org.apache.hadoop.ipc.CallerContext") + val builder = Utils.classForName("org.apache.hadoop.ipc.CallerContext$Builder") + val builderInst = builder.getConstructor(classOf[String]).newInstance("test") + val hdfsContext = builder.getMethod("build").invoke(builderInst) + callerContext.getMethod("setCurrent", callerContext).invoke(null, hdfsContext) + assert(false) + } catch { + case NonFatal(e) => + assert(e.toString == "java.lang.ClassCastException: " + + "org.apache.hadoop.ipc.CallerContext$Builder cannot be cast to scala.runtime.Nothing$") + } + } Review comment: @AngersZhuuuu @dongjoon-hyun ---------------------------------------------------------------- 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. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services --------------------------------------------------------------------- To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org