Skip to content
Merged
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
14 changes: 14 additions & 0 deletions sdks/java/testing/load-tests/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,19 @@ if (isSparkRunner) {
}
}

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

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/integer, you can use Gradle's built-in JavaVersion.toVersion() helper. This is more robust and handles various Java version formats (e.g., "17", "1.8", etc.) gracefully.

  def testJavaVer = JavaVersion.toVersion(project.findProperty('testJavaVersion') ?: JavaVersion.current())
  if (testJavaVer >= JavaVersion.VERSION_17) {

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"
]
}
return []
}

def getLoadTestArgs = {
def loadTestArgs = project.findProperty(loadTestArgsProperty) ?: ""
def loadTestArgsList = new ArrayList<String>()
Expand Down Expand Up @@ -133,6 +146,7 @@ task run(type: JavaExec) {
// Disable UI
systemProperty "spark.ui.enabled", "false"
systemProperty "spark.ui.showConsoleProgress", "false"
jvmArgs += sparkJvmArgs()
}

mainClass = project.findProperty(mainClassProperty)
Expand Down
Loading