Skip to content

Commit 80ceca8

Browse files
committed
Fix Possible Race in KafkaAdmin
Tests for modifying topic properties sometimes fail with topic not found. Remove newly added topics from the topics to consider for modification.
1 parent 6fad998 commit 80ceca8

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

spring-kafka/src/main/java/org/springframework/kafka/core/KafkaAdmin.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import java.util.Collection;
2323
import java.util.Collections;
2424
import java.util.HashMap;
25+
import java.util.LinkedList;
2526
import java.util.List;
2627
import java.util.Map;
2728
import java.util.Optional;
@@ -267,8 +268,10 @@ private void addOrModifyTopicsIfNeeded(AdminClient adminClient, Collection<NewTo
267268
createMissingPartitions(adminClient, topicsWithPartitionMismatches);
268269
}
269270
if (this.modifyTopicConfigs) {
271+
List<NewTopic> toCheck = new LinkedList<>(topics);
272+
toCheck.removeAll(topicsToAdd);
270273
Map<ConfigResource, List<ConfigEntry>> mismatchingConfigs =
271-
checkTopicsForConfigMismatches(adminClient, topics);
274+
checkTopicsForConfigMismatches(adminClient, toCheck);
272275
if (!mismatchingConfigs.isEmpty()) {
273276
adjustConfigMismatches(adminClient, topics, mismatchingConfigs);
274277
}

0 commit comments

Comments
 (0)