He-Pin commented on code in PR #2511:
URL: https://github.com/apache/pekko/pull/2511#discussion_r2534115754


##########
project/OSGi.scala:
##########
@@ -137,10 +137,25 @@ object OSGi {
       "!scala.util.parsing.*",
       scalaImport(scalaVersion))
   def pekkoImport(version: String, packageName: String = "org.apache.pekko.*") 
= {
+    // see https://github.com/apache/pekko/issues/2509 for background
+    // on why the version that is input might not be in the expected format
     val versionComponents = version.split('.')
-    val nextMinorVersion = versionComponents(1).toInt + 1
-    versionedImport(packageName, 
s"${versionComponents.head}.${versionComponents(1)}",
-      s"${versionComponents.head}.$nextMinorVersion")
+    if (versionComponents.length < 2) {
+      useDefaultImportRange(version, packageName)
+    } else {
+      try {
+        val nextMinorVersion = versionComponents(1).toInt + 1
+        versionedImport(packageName, 
s"${versionComponents.head}.${versionComponents(1)}",
+          s"${versionComponents.head}.$nextMinorVersion")
+      } catch {
+        case _: NumberFormatException =>
+          useDefaultImportRange(version, packageName)
+      }
+    }
+  }
+  private def useDefaultImportRange(version: String, packageName: String) = {
+    System.err.println(s"Invalid Pekko version: $version for OSGi import 
package versioning, defaulting to [0.0,10.0)")

Review Comment:
   nice to use `err` here



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


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

Reply via email to