Before Creating the Enhancement Request
Summary
org.apache.rocketmq.srvutil.ShutdownHookThread and ServerUtil are shared utility classes used by RocketMQ entry modules. This change adds focused regression coverage for their observable behavior.
Motivation
These utilities are low-level and easy to regress:
ShutdownHookThread controls shutdown callback execution
ServerUtil builds CLI options and converts CommandLine to Properties
- both are reused by multiple entry points
Without regression tests, small changes here may introduce:
- duplicate shutdown callback execution
- unclear behavior when the callback throws
- incorrect command-line option construction
- incorrect conversion from
CommandLine to Properties
Describe the Solution You'd Like
Add focused unit tests under srvutil/src/test/java/org/apache/rocketmq/srvutil/ to cover:
- repeated
run() invocation semantics in ShutdownHookThread
- callback exception handling in
ShutdownHookThread
ServerUtil.buildCommandlineOptions()
ServerUtil.commandLine2Properties()
The scope should stay limited to observable behavior. No production logic changes are required.
Describe Alternatives You've Considered
- Testing
parseCmdLine() directly
- Rejected because it can terminate the JVM via
System.exit()
- This makes the test setup less stable and harder to reuse
- Expanding the scope to integration-level startup behavior
- Rejected because this is a narrow regression task for utility code
- The lower-cost unit coverage is enough for the intended contribution
Additional Context
Covered behavior:
- repeated
run() invocation on ShutdownHookThread
- exception handling in the shutdown callback
ServerUtil.buildCommandlineOptions()
ServerUtil.commandLine2Properties()
Not covered:
parseCmdLine() exit behavior
- JVM shutdown hook registration
- integration-level startup behavior
Acceptance criteria:
- tests added under
srvutil/src/test/java/org/apache/rocketmq/srvutil/
- tests pass locally
- no production logic change
- no unrelated refactor
Expected outcome:
- stronger regression protection for
srvutil
- safer future changes in shutdown and CLI helper code
- no production behavior change
Before Creating the Enhancement Request
Summary
org.apache.rocketmq.srvutil.ShutdownHookThreadandServerUtilare shared utility classes used by RocketMQ entry modules. This change adds focused regression coverage for their observable behavior.Motivation
These utilities are low-level and easy to regress:
ShutdownHookThreadcontrols shutdown callback executionServerUtilbuilds CLI options and convertsCommandLinetoPropertiesWithout regression tests, small changes here may introduce:
CommandLinetoPropertiesDescribe the Solution You'd Like
Add focused unit tests under
srvutil/src/test/java/org/apache/rocketmq/srvutil/to cover:run()invocation semantics inShutdownHookThreadShutdownHookThreadServerUtil.buildCommandlineOptions()ServerUtil.commandLine2Properties()The scope should stay limited to observable behavior. No production logic changes are required.
Describe Alternatives You've Considered
parseCmdLine()directlySystem.exit()Additional Context
Covered behavior:
run()invocation onShutdownHookThreadServerUtil.buildCommandlineOptions()ServerUtil.commandLine2Properties()Not covered:
parseCmdLine()exit behaviorAcceptance criteria:
srvutil/src/test/java/org/apache/rocketmq/srvutil/Expected outcome:
srvutil