summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorValerij Fredriksen <freva@users.noreply.github.com>2023-06-12 17:14:39 +0200
committerGitHub <noreply@github.com>2023-06-12 17:14:39 +0200
commit0647b650c3334ff86d50431e78549e25dc46caf9 (patch)
treeb54fee390c17cb5242c33666dd161ced0fc9eb9a
parentfbc1d03e255878b20a5c7e36e355ecd635f3a930 (diff)
parentc597d198dd15ba1147d2b78941ed16b45a776ee7 (diff)
Merge pull request #27385 from vespa-engine/jonmv/avoid-npe-when-no-targets-in
When all targets are inactive, there is not iterator.next later
-rw-r--r--controller-server/src/main/java/com/yahoo/vespa/hosted/controller/routing/RoutingPolicies.java13
1 files changed, 3 insertions, 10 deletions
diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/routing/RoutingPolicies.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/routing/RoutingPolicies.java
index 2726c778218..770957b19d2 100644
--- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/routing/RoutingPolicies.java
+++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/routing/RoutingPolicies.java
@@ -292,16 +292,9 @@ public class RoutingPolicies {
// If all targets are configured OUT, all targets are kept IN. We do this because otherwise removing 100% of
// the ALIAS records would cause the application endpoint to stop resolving entirely (NXDOMAIN).
- for (var kv : targetsByEndpoint.entrySet()) {
- Endpoint endpoint = kv.getKey();
- Set<Target> activeTargets = kv.getValue();
- if (!activeTargets.isEmpty()) {
- continue;
- }
- Set<Target> inactiveTargets = inactiveTargetsByEndpoint.get(endpoint);
- activeTargets.addAll(inactiveTargets);
- inactiveTargets.clear();
- }
+ targetsByEndpoint.forEach((endpoint, targets) -> {
+ if (targets.isEmpty()) targets.addAll(inactiveTargetsByEndpoint.remove(endpoint));
+ });
targetsByEndpoint.forEach((applicationEndpoint, targets) -> {
// Where multiple zones are permitted, they all have the same routing policy, and nameServiceForwarder (below).