lsq3497 opened a new issue, #10430:
URL: https://github.com/apache/rocketmq/issues/10430
### Before Creating the Enhancement Request
- [x] I have confirmed that this should be classified as an enhancement
rather than a bug/feature.
### 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
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]