From 2217293f84ff0f0d9b01e04244d1108440c35f35 Mon Sep 17 00:00:00 2001 From: Alexis Souquiere Date: Thu, 13 Jul 2023 16:40:09 +0200 Subject: [PATCH 1/2] Fixing sonar issues --- .../AkhqClaimProviderController.java | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/main/java/com/michelin/ns4kafka/controllers/AkhqClaimProviderController.java b/src/main/java/com/michelin/ns4kafka/controllers/AkhqClaimProviderController.java index c8ce42e5..7da329b3 100644 --- a/src/main/java/com/michelin/ns4kafka/controllers/AkhqClaimProviderController.java +++ b/src/main/java/com/michelin/ns4kafka/controllers/AkhqClaimProviderController.java @@ -154,15 +154,16 @@ public AKHQClaimResponseV3 generateClaimV3(@Valid @Body AKHQClaimRequest request if (bindings.containsKey(key)) { bindings.get(key).getClusters().add(patternCluster); } else { + List regexes = new ArrayList<>(); + regexes.add(patternRegex); + List clusters = new ArrayList<>(); + clusters.add(patternCluster); + // Otherwise we add a new one bindings.put(key, AKHQClaimResponseV3.Group.builder() .role(role) - .patterns(new ArrayList<>() {{ - add(patternRegex); - }}) - .clusters(new ArrayList<>() {{ - add(patternCluster); - }}) + .patterns(regexes) + .clusters(clusters) .build()); } }); @@ -209,7 +210,7 @@ private List optimizeV3Claim(Map c = new ArrayList<>(r.clusters); c.removeAll(value.clusters); // Same role and same clusters filtering - return r.role.equals(value.role) && c.size() == 0; + return r.role.equals(value.role) && c.isEmpty(); }) .findFirst() .ifPresentOrElse( @@ -237,7 +238,7 @@ private List getAllAclForGroups(List groups) { .getOrDefault(config.getGroupLabel(), "_") .split(",")))) .flatMap(namespace -> accessControlEntryService.findAllGrantedToNamespace(namespace).stream()) - .collect(Collectors.toList()); + .toList(); } /** From fab649ee8b23d58304a290d564dd53991d60bb8c Mon Sep 17 00:00:00 2001 From: Alexis Souquiere Date: Thu, 13 Jul 2023 16:50:40 +0200 Subject: [PATCH 2/2] Fixing sonar issues --- .../ns4kafka/controllers/AkhqClaimProviderController.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/michelin/ns4kafka/controllers/AkhqClaimProviderController.java b/src/main/java/com/michelin/ns4kafka/controllers/AkhqClaimProviderController.java index 7da329b3..a5bcd13d 100644 --- a/src/main/java/com/michelin/ns4kafka/controllers/AkhqClaimProviderController.java +++ b/src/main/java/com/michelin/ns4kafka/controllers/AkhqClaimProviderController.java @@ -238,7 +238,7 @@ private List getAllAclForGroups(List groups) { .getOrDefault(config.getGroupLabel(), "_") .split(",")))) .flatMap(namespace -> accessControlEntryService.findAllGrantedToNamespace(namespace).stream()) - .toList(); + .collect(Collectors.toList()); } /**