spring-projects / spring-kafka

Provides Familiar Spring Abstractions for Apache Kafka
https://projects.spring.io/spring-kafka
Apache License 2.0
2.19k stars 1.56k forks source link

Code refactoring #3476

Closed LokeshAlamuri closed 2 months ago

LokeshAlamuri commented 2 months ago

Following code could be considered to refactor.

1) generateFromSleepingBackOffPolicy method in org.springframework.kafka.retrytopic.BackOffValuesGenerator

I have removed the code to set the `maxBackOffPeriod`, if the BackOffPolicy is `UniformRandomBackOffPolicy`. This is not required since, when sleeper is added to the `UniformRandomBackOffPolicy` `maxBackOffPeriod` is not modified. This could be an issue with the earlier versions of spring-retry. But, latest version of spring-kafka 3.3 and spring-retry 2.0.8, this is not an issue.

2) Modify addIfAbsent in org.springframework.kafka.retrytopic.ListenerContainerFactoryResolver.Cache to use putIfAbsent, rather than explictly checking for the key, if it is not there than adding it to the HashMap.

Please give your comments.

LokeshAlamuri commented 2 months ago

Please review the following PR and give your comments.

https://github.com/spring-projects/spring-kafka/pull/3477/files