fix: stop StatusUpdateTrigger from overriding user-configured StatusUpdater timeout#5210
Open
herley-shaori wants to merge 1 commit intocodecentric:masterfrom
Open
Conversation
…pdater timeout (codecentric#5147) StatusUpdateTrigger.updateStatus() was calling statusUpdater.timeout(intervalCheck.getInterval()) on every invocation, which unconditionally overwrote the timeout to the status-check interval value (default 10s). This made it impossible for users to configure a custom timeout on StatusUpdater, either via a custom bean definition or through the monitor.default-timeout property — the value was always replaced before updateStatus() was called. Root cause: - StatusUpdater.timeout() is a mutable setter that modifies the instance's internal timeout field and returns `this`. - StatusUpdateTrigger called it on every status check cycle, resetting the timeout to intervalCheck.getInterval() regardless of what was previously configured. Changes: - Remove the timeout() call from StatusUpdateTrigger.updateStatus(), making it consistent with InfoUpdateTrigger which never overrides InfoUpdater's timeout. - Apply monitor.defaultTimeout from AdminServerProperties when constructing the auto-configured StatusUpdater bean, so the property spring.boot.admin.monitor.default-timeout is respected out of the box. - Users who define a custom StatusUpdater bean with a custom timeout will now have that timeout honored, as documented.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #5147
Problem
StatusUpdateTrigger.updateStatus()unconditionally callsstatusUpdater.timeout(intervalCheck.getInterval())on every status check cycle. This overwrites any user-configured timeout onStatusUpdaterwith the status-check interval value (default 10s), making it impossible to customize the timeout — either via a custom bean definition (as documented) or through thespring.boot.admin.monitor.default-timeoutproperty.Evidence from the reporter: Setting a 30s timeout still results in
TimeoutExceptionat9000ms(interval 10s minus the 1s margin applied bygetTimeoutWithMargin()).Root Cause
StatusUpdater.timeout(Duration)is a mutable setter that modifies the instance's internaltimeoutfield and returnsthis.StatusUpdateTriggercalled it before everyupdateStatus()invocation, resetting the timeout tointervalCheck.getInterval()regardless of what was previously configured.InfoUpdateTrigger, which callsinfoUpdater.updateInfo()directly without overriding any timeout.Changes
StatusUpdateTrigger.java— Removed thestatusUpdater.timeout(intervalCheck.getInterval())call. Now callsstatusUpdater.updateStatus()directly, consistent with howInfoUpdateTriggerworks.AdminServerAutoConfiguration.java— Appliedmonitor.defaultTimeoutfromAdminServerPropertieswhen constructing the auto-configuredStatusUpdaterbean, so the propertyspring.boot.admin.monitor.default-timeoutis respected out of the box.StatusUpdateTriggerTest.java— Removed the now-unnecessarytimeout()mock setup.Behavior After Fix
StatusUpdaterusesdefaultTimeoutfrom properties (default 10s) — no change in behavior.StatusUpdaterbean with a custom timeout will have that timeout honored, as documented.spring.boot.admin.monitor.default-timeoutnow correctly applies to status checks for the auto-configured bean.Test Plan
StatusUpdateTriggerTesttests passStatusUpdaterbean that sets timeout to 30s —TimeoutExceptionshould report ~29s, not ~9s