-
Notifications
You must be signed in to change notification settings - Fork 519
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support of Duration in RetryTemplateBuilder #344
Conversation
src/main/java/org/springframework/retry/support/RetryTemplateBuilder.java
Show resolved
Hide resolved
src/main/java/org/springframework/retry/support/RetryTemplateBuilder.java
Show resolved
Hide resolved
I applied the requested changes and deprecated |
@@ -132,6 +136,36 @@ public RetryTemplateBuilder withinMillis(long timeout) { | |||
return this; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And just delegate to a new method from this deprecated one!
Not sure why do we need to keep a duplication of the logic...
*/ | ||
public RetryTemplateBuilder withTimeout(Duration timeout) { | ||
Assert.notNull(timeout, "timeout is null"); | ||
return this.withinMillis(timeout.toMillis()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No this.
on method calls, please.
And why do you call a deprecated method from here then?
@@ -111,12 +114,14 @@ public void testBasicCustomization() { | |||
/* ---------------- Retry policy -------------- */ | |||
|
|||
@Test | |||
@SuppressWarnings("removal") | |||
public void testFailOnRetryPoliciesConflict() { | |||
assertThatIllegalArgumentException() | |||
.isThrownBy(() -> RetryTemplate.builder().maxAttempts(3).withinMillis(1000).build()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So, why cannot we use a new method then instead of a deprecated one?
Since we have it just deprecated we simply claim that we don't support it any more.
If you have introduced tests for new methods, then this old simply can be removed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's an existing test that's testing the deprecated code. That isn't so bad, isn't it? As long as there is a new test for the new code.
The test should be flagged with deprecated probably.
Sorry, my change aversion got out of hand. Problems are hopefully fixed. |
* @since 2.0.2 | ||
*/ | ||
public RetryTemplateBuilder withTimeout(Duration timeout) { | ||
Assert.notNull(timeout, "timeout is null"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure where you took this pattern from, but it would be better to give an instruction in this message.
When exception is thrown from that Assert.notNull
is is already clear that something is wrong: we only just need to say how to fix: "'timeout' must not be null"
.
And fix the rest of similar messages in this class, please.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Better?
Thank you for contribution, @aahlenst ; looking forward for more! |
Introduce java.time.Duration as an alternative to express timeouts and intervals when building RestTemplate.