Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
@@ -1,5 +1,5 @@
{
"comment": "Modify this file in a trivial way to cause this test suite to run",
"modification": 1,
"modification": 2,
"https://github.com/apache/beam/pull/32440": "test new datastream runner for batch"
}
25 changes: 24 additions & 1 deletion runners/flink/job-server/flink_job_server.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,27 @@ tasks.register("validatesPortableRunner") {
dependsOn validatesPortableRunnerStreamingCheckpoint
}

def flinkJobServerJvmArgs() {
def testJavaVer = project.findProperty('testJavaVersion') ? (project.property('testJavaVersion') as int) : JavaVersion.current().majorVersion.toInteger()
if (testJavaVer >= 17) {
Comment on lines +243 to +244

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

Instead of manually parsing the Java version string to an integer (which can be fragile depending on the format of testJavaVersion), you can use Gradle's built-in JavaVersion.toVersion() helper. This is much more robust and idiomatic.

  def javaVersion = JavaVersion.toVersion(project.findProperty('testJavaVersion') ?: JavaVersion.current())
  if (javaVersion.isJava17Compatible()) {

return [
"--add-opens=java.base/sun.nio.ch=ALL-UNNAMED",
"--add-opens=java.base/java.nio=ALL-UNNAMED",
"--add-opens=java.base/java.util=ALL-UNNAMED",
"--add-opens=java.base/java.lang.invoke=ALL-UNNAMED",
"--add-opens=java.base/java.lang=ALL-UNNAMED",
"-Djava.security.manager=allow",
]
}
return []
}

[validatesPortableRunnerDocker, validatesPortableRunnerBatchDataSet, validatesPortableRunnerBatch, validatesPortableRunnerStreaming, validatesPortableRunnerStreamingCheckpoint].each { task ->
task.configure {
jvmArgs += flinkJobServerJvmArgs()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

Using jvmArgs(...) is the standard and safer Gradle DSL method to append JVM arguments to a task, rather than using the += operator which can fail if jvmArgs is not pre-initialized.

    jvmArgs(flinkJobServerJvmArgs())

}
}

def jobPort = BeamModulePlugin.getRandomPort()
def artifactPort = BeamModulePlugin.getRandomPort()

Expand Down Expand Up @@ -270,7 +291,9 @@ def setupTask = project.tasks.register("flinkJobServerSetup", Exec) {
}

executable 'sh'
args '-c', "$pythonDir/scripts/run_job_server.sh stop --group_id ${project.name} && $pythonDir/scripts/run_job_server.sh start --group_id ${project.name} --job_port ${jobPort} --artifact_port ${artifactPort} --job_server_jar ${flinkJobServerJar} --additional_args \"${additionalArgs}\""
def jvmArgs = flinkJobServerJvmArgs().join(' ')
def jvmArgsOpt = jvmArgs ? "--jvm_args \"${jvmArgs}\"" : ""
args '-c', "$pythonDir/scripts/run_job_server.sh stop --group_id ${project.name} && $pythonDir/scripts/run_job_server.sh start --group_id ${project.name} --job_port ${jobPort} --artifact_port ${artifactPort} --job_server_jar ${flinkJobServerJar} --additional_args \"${additionalArgs}\" ${jvmArgsOpt}"
}

def cleanupTask = project.tasks.register("flinkJobServerCleanup", Exec) {
Expand Down
Loading