Github user andrewor14 commented on the pull request:

    https://github.com/apache/spark/pull/3841#issuecomment-69240435
  
    @WangTaoTheTonic I don't understand why `def` is not sufficient. If I 
understand correctly SPARK-5006 is caused by the race condition where `val 
portMaxRetries` is defined before the `SparkEnv.get` is set. Making this a 
`lazy val` will solve this in most cases, but only because this is currently 
only used in `Utils.startServiceOnPort`, which is currently called only after 
the `SparkEnv` is set. However, `lazy val` is not safe because 
`startServiceOnPort` can be called from anywhere even before setting the 
`SparkEnv`, so it's safest to make this a `def`, in which case every call to 
`startServiceOnPort` will check if the `SparkEnv` is set. Does that make sense? 
Please let me know if I'm missing something.


---
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