Skip to content

Commit

Permalink
use same java major extract fn as in build
Browse files Browse the repository at this point in the history
  • Loading branch information
RustedBones committed Dec 20, 2024
1 parent ae38256 commit 87fd804
Showing 1 changed file with 13 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ import scala.jdk.CollectionConverters._
/** Dataflow runner specific context. */
case object DataflowContext extends RunnerContext {

private lazy val JavaMajorVersion: Int =
System.getProperty("java.version").stripPrefix("1.").takeWhile(_.isDigit).toInt

override def prepareOptions(options: PipelineOptions, artifacts: List[String]): Unit = {
val classLoader = classOf[DataflowRunner].getClassLoader
val dataflowOptions = options.as(classOf[DataflowPipelineWorkerPoolOptions])
Expand All @@ -43,20 +46,17 @@ case object DataflowContext extends RunnerContext {

// Required for Kryo w/ Java 17+
lazy val dataflowPipelineOpts = options.as(classOf[DataflowPipelineOptions])
val javaVersionRe = "^(\\d+)\\..*".r

sys.props("java.version") match {
case javaVersionRe(version)
if version.toInt >= 17 && dataflowPipelineOpts.getJdkAddOpenModules == null =>
dataflowPipelineOpts.setJdkAddOpenModules(
List(
"java.base/java.util=ALL-UNNAMED",
"java.base/java.lang.invoke=ALL-UNNAMED",
"java.base/java.lang=ALL-UNNAMED",
"java.base/java.nio=ALL-UNNAMED"
).asJava
)
case _ => // Only add opts for Java 17+
if (JavaMajorVersion >= 17 && dataflowPipelineOpts.getJdkAddOpenModules == null) {
// Only add opts for Java 17+
dataflowPipelineOpts.setJdkAddOpenModules(
List(
"java.base/java.util=ALL-UNNAMED",
"java.base/java.lang.invoke=ALL-UNNAMED",
"java.base/java.lang=ALL-UNNAMED",
"java.base/java.nio=ALL-UNNAMED"
).asJava
)
}

dataflowOptions.setFilesToStage(new java.util.ArrayList(filesToStage))
Expand Down

0 comments on commit 87fd804

Please sign in to comment.