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

    https://github.com/apache/spark/pull/2311#discussion_r17251037
  
    --- Diff: 
yarn/common/src/main/scala/org/apache/spark/deploy/yarn/ApplicationMaster.scala 
---
    @@ -355,11 +355,20 @@ private[spark] class ApplicationMaster(args: 
ApplicationMasterArguments,
       private def startUserClass(): Thread = {
         logInfo("Starting the user JAR in a separate Thread")
         System.setProperty("spark.executor.instances", 
args.numExecutors.toString)
    +    var stopped = false
    +    case class NoExitsException(exitCode: Int) extends SecurityException
         val mainMethod = Class.forName(args.userClass, false,
           Thread.currentThread.getContextClassLoader).getMethod("main", 
classOf[Array[String]])
     
         val t = new Thread {
           override def run() {
    +        System.setSecurityManager(new java.lang.SecurityManager() {
    +          override def checkExit(paramInt: Int) {
    +            if (!stopped) {
    +              throw new NoExitsException(paramInt)
    --- End diff --
    
    Instead of throwing the exception, why not just set `exitStatus` directly 
and avoid having a custom exception? You can also use that as a trigger to call 
"finish()" if it hasn't been called yet, with a nice error message about the 
app having called `System.exit`.
    
    That avoids messing with the app's exception handling, since very few 
people realize `System.exit` can throw and thus don't really plan for it.


---
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 [email protected] or file a JIRA ticket
with INFRA.
---

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

Reply via email to