Frun1na opened a new pull request, #4647:
URL: https://github.com/apache/rocketmq-dashboard/pull/4647
### Which Issue(s) This PR Fixes
- Fixes #<BACKFILL>
### Brief Description
`CollectorScheduler.cleanUpSnapshots()` (runs hourly via `@Scheduled`) parses
`studio.alerting.snapshot-retention` with an unguarded `Duration.parse`. The
default is the
ISO-8601 string `PT24H`, but a configuration value like `24h` — the natural
spelling, and the
format most other tools accept — throws a `DateTimeParseException` on every
invocation.
Because the method is called by the fixed-delay scheduler, the failure
repeats every hour: the
exception is swallowed by the scheduler, no snapshot is ever deleted, and
the snapshot table
grows without bound until someone notices, fixes the config, and restarts
the process.
The fix catches the parse failure, logs the offending value, and skips the
run. Skipping (rather
than falling back to the default) is deliberate: silently deleting with a
guessed horizon could
destroy snapshots the operator intended to keep.
### How Did You Test This Change?
```
$ cd server && mvn -B -ntp test -Dtest='CollectorSchedulerTest'
[INFO] Tests run: 14, Failures: 0, Errors: 0, Skipped: 0
[INFO] BUILD SUCCESS
```
Two new tests:
- `cleanUpSnapshotsSkipsRunWhenRetentionIsMalformedTest`: with
`snapshot-retention=24h` the call
does not throw and `deleteBefore` is never invoked (fails on the pre-fix
code with
`DateTimeParseException`).
- `cleanUpSnapshotsDeletesBeforeRetentionHorizonTest`: with the valid
`PT24H` the cutoff passed
to `deleteBefore` is now minus the retention (guards the happy path).
- [x] I have added tests for my changes
- [x] I have run the existing tests and they pass
--
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]