vertx: 1 CWE-407 defect — HAManager nodeLeft List.contains O(N×M) in cluster failover loop

This commit is contained in:
russell@unturf.com 2026-03-30 08:54:06 -04:00
parent 4483a2ee12
commit 555896829a
3 changed files with 249 additions and 0 deletions

View file

@ -0,0 +1,24 @@
# UNDF: UNDF-2026-000000570
--- a/vertx-core/src/main/java/io/vertx/core/impl/HAManager.java
+++ b/vertx-core/src/main/java/io/vertx/core/impl/HAManager.java
@@ -304,15 +304,15 @@ public class HAManager {
// We also check for and potentially resume any previous failovers that might have failed
// We can determine this if there any ids in the cluster map which aren't in the node list
- List<String> nodes = clusterManager.getNodes();
+ Set<String> nodes = new HashSet<>(clusterManager.getNodes());
for (Map.Entry<String, String> entry: clusterMap.entrySet()) {
if (!leftNodeID.equals(entry.getKey()) && !nodes.contains(entry.getKey())) {
JsonObject haInfo = new JsonObject(entry.getValue());
checkFailover(entry.getKey(), haInfo);
}
}
}
}
private void addHaInfoIfLost() {
- if (clusterManager.getNodes().contains(nodeID) && !clusterMap.containsKey(nodeID)) {
+ if (new HashSet<>(clusterManager.getNodes()).contains(nodeID) && !clusterMap.containsKey(nodeID)) {
synchronized (haInfo) {
clusterMap.put(nodeID, haInfo.encode());
}