wolfboys commented on code in PR #3908:
URL: 
https://github.com/apache/incubator-streampark/pull/3908#discussion_r1686391131


##########
streampark-common/src/main/scala/org/apache/streampark/common/conf/SparkVersion.scala:
##########
@@ -36,7 +38,14 @@ class SparkVersion(val sparkHome: String) extends 
Serializable with Logger {
 
   private[this] lazy val SPARK_SCALA_VERSION_PATTERN = 
Pattern.compile("^spark-core_(.*)-[0-9].*.jar$")
 
-  lazy val scalaVersion: String = 
SPARK_SCALA_VERSION_PATTERN.matcher(sparkCoreJar.getName).group(1)
+  lazy val scalaVersion: String = {

Review Comment:
   It would be better to throw an exception if the Scala version cannot be 
extracted.
   ```
     lazy val scalaVersion: String = {
       val matcher = SPARK_SCALA_VERSION_PATTERN.matcher(sparkCoreJar.getName)
       if (matcher.find()) {
         matcher.group(1)
       } else {
         throw new IllegalArgumentException(s"[StreamPark] can not found scala 
version in $sparkCoreJar")
       }
     }
   ```



##########
streampark-common/src/main/scala/org/apache/streampark/common/conf/SparkVersion.scala:
##########
@@ -36,7 +38,14 @@ class SparkVersion(val sparkHome: String) extends 
Serializable with Logger {
 
   private[this] lazy val SPARK_SCALA_VERSION_PATTERN = 
Pattern.compile("^spark-core_(.*)-[0-9].*.jar$")
 
-  lazy val scalaVersion: String = 
SPARK_SCALA_VERSION_PATTERN.matcher(sparkCoreJar.getName).group(1)
+  lazy val scalaVersion: String = {

Review Comment:
   If the Scala version number cannot be obtained, an exception should be 
thrown.
   ```
    lazy val scalaVersion: String = {
       val matcher = SPARK_SCALA_VERSION_PATTERN.matcher(sparkCoreJar.getName)
       if (matcher.find()) {
         matcher.group(1)
       } else {
         throw new IllegalArgumentException(s"[StreamPark] can not found scala 
version in $sparkCoreJar")
       }
     }
   
   ```



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to