Skip to content

Commit 366c4ba

Browse files
cushoncopybara-github
authored andcommitted
Disable the GoogleTestSecurityManager by default
and explicitly enable it for tests that rely on it. The SecurityManager is being permanently disabled in JDK 24, see https://openjdk.org/jeps/486 PiperOrigin-RevId: 696974212 Change-Id: I425c0bb66e0c1c057129712e45b60ba481971db8
1 parent 13a1cec commit 366c4ba

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

src/java_tools/junitrunner/java/com/google/testing/junit/runner/junit4/JUnit4Config.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ private static boolean installSecurityManager(Properties systemProperties) {
9090
return false; // Don't install over the specified security manager
9191
}
9292
return Boolean.valueOf(
93-
systemProperties.getProperty(SHOULD_INSTALL_SECURITY_MANAGER_PROPERTY, "true"));
93+
systemProperties.getProperty(SHOULD_INSTALL_SECURITY_MANAGER_PROPERTY, "false"));
9494
}
9595

9696
/**

src/java_tools/junitrunner/javatests/com/google/testing/junit/runner/junit4/JUnit4ConfigTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ public void testShouldInstallSecurityManager_defaultValue() {
8585
GoogleTestSecurityManager.uninstallIfInstalled();
8686

8787
JUnit4Config config = createConfigWithProperties(new Properties());
88-
assertThat(config.shouldInstallSecurityManager()).isTrue();
88+
assertThat(config.shouldInstallSecurityManager()).isFalse();
8989
}
9090

9191
@Test

src/java_tools/junitrunner/javatests/com/google/testing/junit/runner/junit4/JUnit4RunnerTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -444,8 +444,8 @@ private static Properties createProperties(
444444
String apiVersion, boolean shouldInstallSecurityManager) {
445445
Properties properties = new Properties();
446446
properties.setProperty(JUnit4Config.JUNIT_API_VERSION_PROPERTY, apiVersion);
447-
if (!shouldInstallSecurityManager) {
448-
properties.setProperty("java.security.manager", "whatever");
447+
if (shouldInstallSecurityManager) {
448+
properties.setProperty(JUnit4Config.SHOULD_INSTALL_SECURITY_MANAGER_PROPERTY, "true");
449449
}
450450
return properties;
451451
}

0 commit comments

Comments
 (0)