Skip to content

Omit zero timeout in DefaultRetryPolicy.toString() - #37437

Merged
sbrannen merged 1 commit into
spring-projects:mainfrom
guanchengang:improve/default-retry-policy-tostring-timeout
Oct 10, 2026
Merged

sbrannen merged 1 commit into
spring-projects:mainfrom
guanchengang:improve/default-retry-policy-tostring-timeout

Conversation

@guanchengang

@guanchengang guanchengang commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

Include the timeout in DefaultRetryPolicy.toString(), but omit it when it is zero.

A zero timeout is the default and signals that timeout checking is disabled, so omitting it is consistent with how includes, excludes, and predicate are omitted when not configured, and it avoids the misleading PT0S output.

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label Oct 10, 2026
@guanchengang
guanchengang marked this pull request as draft October 10, 2026 07:24
@guanchengang
guanchengang force-pushed the improve/default-retry-policy-tostring-timeout branch from e68ac09 to 4147654 Compare October 10, 2026 07:55
@guanchengang
guanchengang marked this pull request as ready for review October 10, 2026 08:12
@sbrannen sbrannen added the in: core Issues in core modules (aop, beans, core, context, expression) label Oct 10, 2026
@sbrannen sbrannen self-assigned this Oct 10, 2026
@sbrannen sbrannen changed the title Include timeout in DefaultRetryPolicy.toString() Omit zero timeout in DefaultRetryPolicy.toString() Oct 10, 2026

@sbrannen sbrannen left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When the timeout is zero or negative,

It shouldn't be possible for it to be negative. See RetryPolicy.Builder.timeout(Duration).

display it as "none" to indicate that timeout checking is disabled. This avoids the misleading PT0S output.

Instead of displaying none, let's just omit the timeout altogether if it's zero. I've updated the PR's title to reflect that.

@sbrannen sbrannen added status: waiting-for-feedback We need additional information before we can continue type: enhancement A general enhancement and removed status: waiting-for-triage An issue we've not yet triaged or decided on labels Oct 10, 2026
@sbrannen sbrannen added this to the 7.1.0-RC1 milestone Oct 10, 2026
Only include the timeout field when it is non-zero.

Closes spring-projectsgh-37437

Signed-off-by: Chengang Guan <guanchengang@qq.com>
@guanchengang
guanchengang force-pushed the improve/default-retry-policy-tostring-timeout branch from 4147654 to 3bfe2b2 Compare October 10, 2026 12:45
@guanchengang

Copy link
Copy Markdown
Contributor Author

It shouldn't be possible for it to be negative. See RetryPolicy.Builder.timeout(Duration).

You're right, and sorry for the confusion, the mention of negative timeouts was a slip on my part. I never actually handled negatives in the code. I've updated the code, tests, and commit message as you suggested.

@guanchengang
guanchengang requested a review from sbrannen October 10, 2026 13:03
@spring-projects-issues spring-projects-issues added status: feedback-provided Feedback has been provided and removed status: waiting-for-feedback We need additional information before we can continue labels Oct 10, 2026
@sbrannen sbrannen removed the status: feedback-provided Feedback has been provided label Oct 10, 2026
@sbrannen
sbrannen merged commit b7edfc5 into spring-projects:main Oct 10, 2026
3 checks passed
sbrannen added a commit that referenced this pull request Oct 10, 2026
@sbrannen

Copy link
Copy Markdown
Member

Thanks for making the requested changes.

This has been merged into main in b7edfc5 and slightly revised in b5b961d.

@guanchengang
guanchengang deleted the improve/default-retry-policy-tostring-timeout branch October 12, 2026 00:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

in: core Issues in core modules (aop, beans, core, context, expression) type: enhancement A general enhancement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants