Skip to content

GoogleTestSecurityManager replacement for tests that call System.exit #24354

@cushon

Description

@cushon

Java tests run by Bazel have historically installed the GoogleTestSecurityManager, which prevents the tests from calling System.exit (and Runtime.exit and Runtime.halt). The idea is to prevent a test that calls System.exit(0) from spuriously passing, or failing in a hard-to-debug way if it reports another exit code.

The SecurityManager has been deprecated for several JDK releases, and is being removed in JDK 24: https://openjdk.org/jeps/486

To avoid breaking Java tests running on JDK 24, the GoogleTestSecurityManager is now disabled by default: 366c4ba

This bug tracks providing replacement functionality for tests that call System.exit. There are a number of possibilities:

There's been some internal discussion about this that leaned towards the addShutdownHook approach.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2We'll consider working on this in future. (Assignee optional)team-Rules-JavaIssues for Java rulestype: bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions