Skip to content
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

Nice to have: notRetryOn() and retryOn() in RetryTemplateBuilder #254

Closed
hotire opened this issue Jan 13, 2022 · 10 comments · Fixed by #255
Closed

Nice to have: notRetryOn() and retryOn() in RetryTemplateBuilder #254

hotire opened this issue Jan 13, 2022 · 10 comments · Fixed by #255

Comments

@hotire
Copy link
Contributor

hotire commented Jan 13, 2022

Summary

I noted this while using the RetryTemplateBuilder.

https://github.com/spring-projects/spring-retry/blob/main/src/main/java/org/springframework/retry/support/RetryTemplateBuilder.java#L285

It would be nice to support list parameter like RetryTopicConfigurationBuilder in spring-kafka

https://github.com/spring-projects/spring-kafka/blob/main/spring-kafka/src/main/java/org/springframework/kafka/retrytopic/RetryTopicConfigurationBuilder.java#L308

Sample

public RetryTemplateBuilder notRetryOn(List<Class<? extends Throwable>> throwables) {
       for (final Class<? extends Throwable> throwable : throwables) {
		classifierBuilder().notRetryOn(throwable);
	}
	return this;
}
public RetryTemplateBuilder retryOn(List<Class<? extends Throwable>> throwables) {
	for (final Class<? extends Throwable> throwable : throwables) {
		classifierBuilder().retryOn(throwable);
	}
	return this;
}
hotire pushed a commit to hotire/spring-retry-1 that referenced this issue Jan 13, 2022
…tryTemplateBuilder

Fixes spring-projects#254

Add method with list parameter by overloading existed method
@artembilan
Copy link
Member

As @garyrussell has marked this issue , the contribution is welcome!

While looking into this, I wonder why list, why not varargs?
Just classes, so would be much easier to list them over the comma.
I believe user are going to do List.of() for this contract anyway. So, let's make their life easier with varargs!

hotire pushed a commit to hotire/spring-retry-1 that referenced this issue Jan 13, 2022
…() in RetryTemplateBuilder"

This reverts commit b9dffcf.
hotire added a commit to hotire/spring-retry-1 that referenced this issue Jan 13, 2022
…tryTemplateBuilder

Fixes spring-projects#254

Add method with list parameter by overloading existed method
@hotire
Copy link
Contributor Author

hotire commented Jan 13, 2022

Using varargs is much simpler, but with a warning message...

"Unchecked generics array creation for varargs parameter"

@hotire hotire mentioned this issue Jan 13, 2022
@artembilan
Copy link
Member

That's true.
Just add this to those varargs methods:

@SuppressWarnings("varargs")
@SafeVarargs

And the warn is gone.

@hotire
Copy link
Contributor Author

hotire commented Jan 13, 2022

@artembilan

That's a cool idea.!!

Let's change from List to varargs.

@artembilan
Copy link
Member

Although it might be a breaking change for the existing notRetryOn(Class<? extends Throwable> throwable).
It might be OK for those projects which are going to upgrade and compile. But those with just drop-in replacement are going to suffer from non-compatible bytecode...

@hotire
Copy link
Contributor Author

hotire commented Jan 13, 2022

SafeVarargs annotation is API available from 1.7 or later.... 😂

@artembilan
Copy link
Member

Yeah... As long as I remember the @SuppressWarnings("varargs") i enough to suppress it in the build logs.
Plus annotations works the way that they are ignored if they are not present in the classpath.
Anyway: let's stick with a list for now.
Please, bring your PR back and sorry for a false noise from me: we will revise it into varargs when we switch to version 2.0.

Thank you!

@dratler
Copy link

dratler commented Jan 13, 2022

Hi @garyrussell , @artembilan is this open for the greb ?

@hotire
Copy link
Contributor Author

hotire commented Jan 13, 2022

Thanks for the great ideas.!!

@artembilan
Copy link
Member

Hi @dratler !

Thank you for the offer, but looks like @hotire has taken care about this already.
See his PR #255

You can take any other issue in backlog.

@artembilan artembilan added this to the 1.3.2 milestone Jan 13, 2022
hotire added a commit to hotire/spring-retry-1 that referenced this issue Jan 13, 2022
…tryTemplateBuilder

Fixes spring-projects#254

Add method with list parameter by overloading existed method
hotire added a commit to hotire/spring-retry-1 that referenced this issue Jan 13, 2022
…tryTemplateBuilder

Fixes spring-projects#254

Add method with list parameter by overloading existed method
artembilan pushed a commit that referenced this issue Jan 18, 2022
Fixes #254

Add method with list parameter by overloading existed method
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants