You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by GitBox <gi...@apache.org> on 2022/04/16 19:01:13 UTC

[GitHub] [spark] srowen commented on a diff in pull request #36222: [SPARK-38922][Core] TaskLocation.apply throw NullPointerException

srowen commented on code in PR #36222:
URL: https://github.com/apache/spark/pull/36222#discussion_r851660751


##########
core/src/main/scala/org/apache/spark/rdd/HadoopRDD.scala:
##########
@@ -457,9 +457,9 @@ private[spark] object HadoopRDD extends Logging {
       if (locationStr != "localhost") {
         if (loc.isInMemory) {
           logDebug(s"Partition $locationStr is cached by Hadoop.")
-          Some(HDFSCacheTaskLocation(locationStr).toString)
+          Option(HDFSCacheTaskLocation(locationStr).toString)

Review Comment:
   I don't see how the result of .toString can be null. Isn't the issue if anything that HDFSCacheTaskLocation.apply returns null?



##########
core/src/main/scala/org/apache/spark/scheduler/DAGScheduler.scala:
##########
@@ -2736,7 +2736,7 @@ private[spark] class DAGScheduler(
     // If the RDD has some placement preferences (as is the case for input RDDs), get those
     val rddPrefs = rdd.preferredLocations(rdd.partitions(partition)).toList
     if (rddPrefs.nonEmpty) {
-      return rddPrefs.map(TaskLocation(_))
+      return rddPrefs.map(TaskLocation(_)).filter(_ != null)

Review Comment:
   If you filter out null first, you don't need to check in the apply() method below



-- 
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: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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