You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@spark.apache.org by sa...@apache.org on 2020/06/10 07:58:36 UTC

[spark] branch branch-2.4 updated: [SPARK-31941][CORE] Replace SparkException to NoSuchElementException for applicationInfo in AppStatusStore

This is an automated email from the ASF dual-hosted git repository.

sarutak pushed a commit to branch branch-2.4
in repository https://gitbox.apache.org/repos/asf/spark.git


The following commit(s) were added to refs/heads/branch-2.4 by this push:
     new 53f1349  [SPARK-31941][CORE] Replace SparkException to NoSuchElementException for applicationInfo in AppStatusStore
53f1349 is described below

commit 53f1349e768be66a92542c3ebf0493ffb779ed91
Author: SaurabhChawla <sa...@qubole.com>
AuthorDate: Wed Jun 10 16:51:19 2020 +0900

    [SPARK-31941][CORE] Replace SparkException to NoSuchElementException for applicationInfo in AppStatusStore
    
    ### What changes were proposed in this pull request?
    After SPARK-31632 SparkException is thrown from def applicationInfo
    `def applicationInfo(): v1.ApplicationInfo = {
        try {
          // The ApplicationInfo may not be available when Spark is starting up.
          store.view(classOf[ApplicationInfoWrapper]).max(1).iterator().next().info
        } catch {
          case _: NoSuchElementException =>
            throw new SparkException("Failed to get the application information. " +
              "If you are starting up Spark, please wait a while until it's ready.")
        }
      }`
    
    Where as the caller for this method def getSparkUser in Spark UI is not handling SparkException in the catch
    
    `def getSparkUser: String = {
        try {
          Option(store.applicationInfo().attempts.head.sparkUser)
            .orElse(store.environmentInfo().systemProperties.toMap.get("user.name"))
            .getOrElse("<unknown>")
        } catch {
          case _: NoSuchElementException => "<unknown>"
        }
      }`
    
    So On using this method (getSparkUser )we can get the application erred out.
    
    As the part of this PR we will replace SparkException to NoSuchElementException for applicationInfo in AppStatusStore
    
    ### Why are the changes needed?
    On invoking the method getSparkUser, we can get the SparkException on calling store.applicationInfo(). And this is not handled in the catch block and getSparkUser will error out in this scenario
    
    ### Does this PR introduce _any_ user-facing change?
    No
    
    ### How was this patch tested?
    Done the manual testing using the spark-shell and spark-submit
    
    Closes #28768 from SaurabhChawla100/SPARK-31941.
    
    Authored-by: SaurabhChawla <sa...@qubole.com>
    Signed-off-by: Kousuke Saruta <sa...@oss.nttdata.com>
    (cherry picked from commit 82ff29be7afa2ff6350310ab9bdf6b474398fdc1)
    Signed-off-by: Kousuke Saruta <sa...@oss.nttdata.com>
---
 core/src/main/scala/org/apache/spark/status/AppStatusStore.scala | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/core/src/main/scala/org/apache/spark/status/AppStatusStore.scala b/core/src/main/scala/org/apache/spark/status/AppStatusStore.scala
index e2086d6..8919dab 100644
--- a/core/src/main/scala/org/apache/spark/status/AppStatusStore.scala
+++ b/core/src/main/scala/org/apache/spark/status/AppStatusStore.scala
@@ -40,7 +40,7 @@ private[spark] class AppStatusStore(
       store.view(classOf[ApplicationInfoWrapper]).max(1).iterator().next().info
     } catch {
       case _: NoSuchElementException =>
-        throw new SparkException("Failed to get the application information. " +
+        throw new NoSuchElementException("Failed to get the application information. " +
           "If you are starting up Spark, please wait a while until it's ready.")
     }
   }


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