-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Fix Issues in DefaultKafkaProducerFactory#updateConfigs() #2897
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
Fix Issues in DefaultKafkaProducerFactory#updateConfigs() #2897
Conversation
1cb2497
to
8da52f5
Compare
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.
Thanks; but it is not clear why you found it necessary for all those format changes.
spring-kafka/src/main/java/org/springframework/kafka/core/DefaultKafkaProducerFactory.java
Outdated
Show resolved
Hide resolved
Without those format changes, the gradle checkstyleMain task would fail. A
surprise to me for I hated the manual labour, naturally. Any way to bypass
it?
…On Wed, Nov 15, 2023, 10:45 a.m. Gary Russell ***@***.***> wrote:
***@***.**** requested changes on this pull request.
Thanks; but it is not clear why you found it necessary for all those
format changes.
------------------------------
In
spring-kafka/src/main/java/org/springframework/kafka/core/DefaultKafkaProducerFactory.java
<#2897 (comment)>
:
> @@ -165,6 +165,7 @@ public class DefaultKafkaProducerFactory<K, V> extends KafkaResourceFactory
/**
* Construct a factory with the provided configuration.
+ *
We never have blank lines in method javadocs; they are allowed in class
java docs.
—
Reply to this email directly, view it on GitHub
<#2897 (review)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AB6UYATSQLCEV7LZCXV3DDDYETPTBAVCNFSM6AAAAAA7LYR4IGVHI2DSMVQWIX3LMV43YUDVNRWFEZLROVSXG5CSMV3GSZLXHMYTOMZSGMZTIMZXGA>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
How about this |
c4bf9df
to
03e8d20
Compare
thanks. It works. Lesson learned. |
03e8d20
to
1afa161
Compare
this.transactionIdPrefix = (String) entry.getValue(); | ||
updates.forEach((key, value) -> { | ||
if (key == null) { | ||
return; |
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.
Doesn't this mean that we are going to exit from a loop on a first key as null?
Therefore we just don't examine all the entries in the map.
No, it simply finishes the BiCinsumer's processing. Also, our unit testing
case protects us.
…On Thu, Nov 16, 2023, 9:41 a.m. Artem Bilan ***@***.***> wrote:
***@***.**** requested changes on this pull request.
------------------------------
In
spring-kafka/src/main/java/org/springframework/kafka/core/DefaultKafkaProducerFactory.java
<#2897 (comment)>
:
> @@ -626,23 +626,31 @@ public boolean removePostProcessor(ProducerPostProcessor<K, V> postProcessor) {
@OverRide
public void updateConfigs(Map<String, Object> updates) {
- updates.entrySet().forEach(entry -> {
- if (entry.getKey().equals(ProducerConfig.TRANSACTIONAL_ID_CONFIG)) {
- Assert.isTrue(entry.getValue() instanceof String, () -> "'" + ProducerConfig.TRANSACTIONAL_ID_CONFIG
- + "' must be a String, not a " + entry.getClass().getName());
- Assert.isTrue(this.transactionIdPrefix != null
- ? entry.getValue() != null
- : entry.getValue() == null,
- "Cannot change transactional capability");
- this.transactionIdPrefix = (String) entry.getValue();
+ updates.forEach((key, value) -> {
+ if (key == null) {
+ return;
Doesn't this mean that we are going to exit from a loop on a first key as
null?
Therefore we just don't examine all the entries in the map.
—
Reply to this email directly, view it on GitHub
<#2897 (review)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AB6UYAUY2TN5UI3X3AFYYJLYEYQZ3AVCNFSM6AAAAAA7LYR4IGVHI2DSMVQWIX3LMV43YUDVNRWFEZLROVSXG5CSMV3GSZLXHMYTOMZUGU3TIOJSHA>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
There are many defects in the original DefaultKafkaProducerFactory#updateConfigs() as below:
It has following defects:
ProducerConfig.TRANSACTIONAL_ID_CONFIG
is allowed; but when entry.getValue() returns null, theentry.getValue() instanceof String
in Line # 4 should have return false without reaching later statements (e.g. Line # 6);"' must be a String, not a " + entry.getValue().getClass().getName())
;entry.getClass()
would always returnMap.Entry
.