Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update default Dataflow add-open opts for Java 17+ #5537

Merged
merged 3 commits into from
Dec 20, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This regex would give 1 for java 8 (version is set as 1.8....).
Let's use the same def as for the build

System.getProperty("java.version").stripPrefix("1.").takeWhile(_.isDigit).toInt


sys.props("java.version") match {
case javaVersionRe(version)
if version.toInt >= 17 && dataflowPipelineOpts.getJdkAddOpenModules == null =>
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suppose this is also a bugfix PR for Java 21 users 😬

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
Loading