Skip to content

Commit

Permalink
Check for JDK version while setting java.security.manager option (ope…
Browse files Browse the repository at this point in the history
…nsearch-project#5205)

Signed-off-by: Rabi Panda <[email protected]>
  • Loading branch information
adnapibar authored and reta committed Nov 10, 2023
1 parent 492a17e commit 4a56213
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,9 @@ public void execute(Task t) {
test.jvmArgs("--illegal-access=warn");
}
}
if (test.getJavaVersion().compareTo(JavaVersion.VERSION_17) > 0) {
test.jvmArgs("-Djava.security.manager=allow");
}
}
});
test.getJvmArgumentProviders().add(nonInputProperties);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,21 @@ static List<String> systemJvmOptions() {
// log4j 2
"-Dlog4j.shutdownHookEnabled=false",
"-Dlog4j2.disable.jmx=true",

// security manager
allowSecurityManagerOption(),
javaLocaleProviders()
)
).stream().filter(e -> e.isEmpty() == false).collect(Collectors.toList());
}

private static String allowSecurityManagerOption() {
if (Runtime.version().feature() > 17) {
return "-Djava.security.manager=allow";
} else {
return "";
}
}

private static String maybeShowCodeDetailsInExceptionMessages() {
if (Runtime.version().feature() >= 14) {
return "-XX:+ShowCodeDetailsInExceptionMessages";
Expand Down

0 comments on commit 4a56213

Please sign in to comment.