srowen commented on a change in pull request #23896: [SPARK-26977][CORE] Fix
warn against subclassing scala.App
URL: https://github.com/apache/spark/pull/23896#discussion_r260321328
##########
File path: core/src/main/scala/org/apache/spark/deploy/SparkSubmit.scala
##########
@@ -828,9 +828,12 @@ private[spark] class SparkSubmit extends Logging {
val app: SparkApplication = if
(classOf[SparkApplication].isAssignableFrom(mainClass)) {
mainClass.newInstance().asInstanceOf[SparkApplication]
} else {
- // SPARK-4170
- if (classOf[scala.App].isAssignableFrom(mainClass)) {
- logWarning("Subclasses of scala.App may not work correctly. Use a
main() method instead.")
+ // SPARK-4170, SPARK-26977
+ Try {
+ if
(classOf[scala.App].isAssignableFrom(Utils.classForName(s"$childMainClass$$")))
{
+ logWarning("Subclasses of scala.App may not work correctly. " +
+ "Use a main() method instead.")
+ }
Review comment:
Nit: The indent is wrong here
I think this needs to preserve the original check, and the try-catch should
narrowly catch ClassNotFoundException. This may need to be broken out a little
more.
Needs a few comments too.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]