Skip to content

Commit 9b97f46

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 d6fb172 commit 9b97f46

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

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

Lines changed: 3 additions & 0 deletions
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,6 +268,8 @@ 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 =
271274
checkTopicsForConfigMismatches(adminClient, topics);
272275
if (!mismatchingConfigs.isEmpty()) {

0 commit comments

Comments
 (0)