Initialize checkStamp in LatencyFaultToleranceImpl.FaultItem#10554
Initialize checkStamp in LatencyFaultToleranceImpl.FaultItem#10554vasiliy-mikhailov wants to merge 1 commit into
Conversation
FaultItem never set checkStamp, so it defaulted to 0 and detectByOneRound treated every fault item as ready to detect on every round, ignoring detectInterval. Initialize checkStamp to now plus detectInterval in the constructor.
RockteMQ-AI
left a comment
There was a problem hiding this comment.
Review by github-manager-bot
Summary
Initializes FaultItem.checkStamp in the constructor to now + detectInterval, preventing a freshly created item from being immediately eligible for detection in detectByOneRound().
Findings
- [Info]
LatencyFaultToleranceImpl.java:205— The fix correctly mirrors the assignment inupdateFaultItem(), ensuring consistent initial state. Good alignment. - [Info]
LatencyFaultToleranceImplTest.java:89-103— Regression test is well-structured: uses Mockito to verifydetect()is never called for a freshly added item within the detect interval.
Verdict
Clean, minimal fix with a solid regression test. LGTM.
Automated review by github-manager-bot
RockteMQ-AI
left a comment
There was a problem hiding this comment.
Review by github-manager-bot
Summary
Initializes FaultItem.checkStamp to now + detectInterval in the constructor, preventing a freshly created item from being immediately eligible for detection in detectByOneRound().
Findings
- [Info]
LatencyFaultToleranceImpl.java:205— The fix correctly mirrors the initialization done inupdateFaultItem(). Clean one-line change. - [Info]
LatencyFaultToleranceImplTest.java:92-103— Good regression test. UsingMockito.never()to verify no detection occurs on a fresh item is the right approach. SettingdetectIntervalto 1 hour makes the test deterministic.
Suggestions
- Consider whether
LatencyFaultToleranceImpl.this.detectIntervalcould be zero at construction time (beforesetDetectIntervalis called). If so, the initialization would still result incheckStamp = now, which is the same as the old behavior. The test sets it explicitly after construction, so this edge case may not be covered.
Verdict
Clean, well-targeted fix with a solid regression test. The concern above is minor and may not apply in practice since detectInterval is typically set before any FaultItem is created.
Automated review by github-manager-bot
FaultItem.checkStampis never initialized, so it defaults to0. A freshlycreated fault item is therefore immediately eligible for detection in
detectByOneRound()instead of waiting onedetectIntervallike every itemthat has gone through
updateFaultItem. This makes the very first detect roundfire a probe against a broker that was only just recorded.
Initialize
checkStamptonow + detectIntervalin the constructor, matchingthe value
updateFaultItemassigns. Added a regression test asserting the firstdetectByOneRound()does not probe a freshly added item.Verifying this change
The added
LatencyFaultToleranceImplTest#testDetectByOneRoundRespectsDetectIntervalfails on the currentdevelopand passes with this change:Before the fix (on
develop):After the fix:
AI assistance disclosure
This contribution was produced with the help of an AI pipeline. The pipeline processed a large amount of source code to surface suspected bugs, reproduced a subset of them with failing unit tests and generated candidate fixes, and prepared pull requests from the ones that held up. Each PR was then reviewed and verified by a human before being opened: the fix and test were checked by hand and the test was confirmed to fail before the change and pass after.