C0urante commented on code in PR #13913:
URL: https://github.com/apache/kafka/pull/13913#discussion_r1259876757


##########
connect/mirror/src/main/java/org/apache/kafka/connect/mirror/MirrorSourceConnector.java:
##########
@@ -581,13 +582,26 @@ void incrementalAlterConfigs(Map<String, Config> 
topicConfigs) {
         }));
     }
 
-    private void updateTopicAcls(List<AclBinding> bindings) {
-        log.trace("Syncing {} topic ACL bindings.", bindings.size());
-        targetAdminClient.createAcls(bindings).values().forEach((k, v) -> 
v.whenComplete((x, e) -> {
-            if (e != null) {
-                log.warn("Could not sync ACL of topic {}.", 
k.pattern().name(), e);
-            }
-        }));
+    // Visible for testing
+    int updateTopicAcls(List<AclBinding> bindings) {
+        Set<AclBinding> addBindings = new HashSet<>(bindings);
+        Set<AclBinding> failedBindings = new HashSet<>();
+        addBindings.removeAll(knownTopicAclBindings);
+        int newBindCount = addBindings.size();
+        if (!addBindings.isEmpty()) {
+            log.info("Syncing new found {} topic ACL bindings.", newBindCount);
+            targetAdminClient.createAcls(addBindings).values().forEach((k, v) 
-> v.whenComplete((x, e) -> {
+                if (e != null) {
+                    log.warn("Could not sync ACL of topic {}.", 
k.pattern().name(), e);
+                    failedBindings.add(k);
+                }
+            }));
+            knownTopicAclBindings = new HashSet<>(bindings);
+            knownTopicAclBindings.removeAll(failedBindings);

Review Comment:
   Isn't `failedBindings` likely to be empty at this point unless the admin 
client is able to perform the request to create the ACL bindings exceptionally 
fast (which also happens to be the scenario we're covering in the unit test)?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: jira-unsubscr...@kafka.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to