Skip to content

Commit

Permalink
Update default Dataflow add-open opts for Java 17+
Browse files Browse the repository at this point in the history
  • Loading branch information
clairemcginty committed Dec 19, 2024
1 parent 532e915 commit a1fce4a
Showing 1 changed file with 15 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,16 +41,22 @@ case object DataflowContext extends RunnerContext {
.filesToStage(options, classLoader, localArtifacts, artifacts)
.asJavaCollection

// Required for Kryo w/ Java 17
// Required for Kryo w/ Java 17+
lazy val dataflowPipelineOpts = options.as(classOf[DataflowPipelineOptions])
if (
sys
.props("java.version")
.startsWith("17.") && dataflowPipelineOpts.getJdkAddOpenModules == null
) {
dataflowPipelineOpts.setJdkAddOpenModules(
List("java.base/java.util=ALL-UNNAMED", "java.base/java.lang.invoke=ALL-UNNAMED").asJava
)
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+
}

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

0 comments on commit a1fce4a

Please sign in to comment.