-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Closed
Labels
Description
Background
There are several cases where System.exit is directly invoked to terminate the system after encountering specific exceptions. While this approach is straightforward, it can lead to various technical debts:
- Poor maintainability: Scattered
System.exitcalls make it difficult to trace and maintain program workflows. - Testing Environment Impact: Code containing
System.exitis challenging to unit test. Such calls cause Gradle unit tests to terminate unexpectedly, affecting code coverage statistics and reducing the reliability and stability of CI. - Resource Release Risks: System.exit does not trigger the execution of
finallycode blocks, potentially leading to improperly closed resources such as database connections and file handles.
Rationale
Replace direct System.exit calls with specific exceptions, such as TronError, and handle these exceptions at appropriate higher-level calling points using a unified exit logic. This approach preserves the default exit behavior while addressing the issues above to the greatest extent possible.
Sunny6889
Metadata
Metadata
Assignees
Labels
Type
Projects
Status
Done