Skip to content

Commit

Permalink
Fix test requiring a security manager
Browse files Browse the repository at this point in the history
  • Loading branch information
aherbert committed Sep 10, 2024
1 parent fa4ff76 commit a7e16a3
Showing 1 changed file with 15 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,21 @@ void canCreateParentIgnoresNullParent() throws IOException {
@Test
void canCreateParentWrapsSecurityException() throws IOException {
// Check there is no security manager
Assumptions.assumeTrue(System.getSecurityManager() == null, "Require no security manager");
// Note: The SecurityManager is deprecated for removal from JDK 17
String version = System.getProperty("java.specification.version");
// Do not care about low version 1.8. From JDK 9 this should lead with the major version.
int i = version.indexOf('.');
if (i >= 0) {
version = version.substring(0, i);
}
try {
Assumptions.assumeTrue(Integer.parseInt(version) < 17 && System.getSecurityManager() == null,
"Require no security manager and pre-JDK 17");
} catch (NumberFormatException e) {
Logger.getAnonymousLogger()
.warning(() -> "Unknown version: " + System.getProperty("java.specification.version"));
return;
}

Path tmpDir = null;
try {
Expand Down

0 comments on commit a7e16a3

Please sign in to comment.