undefect. CWE-407 — 92 sites, 42 ecosystems
B&W print-friendly diagrams + tinkerpop-0001 + wave-3 proof sections. Squash of 94 local commits onto remote master.
This commit is contained in:
parent
0a580b313d
commit
db29a08762
1311 changed files with 371202 additions and 1188 deletions
|
|
@ -0,0 +1,36 @@
|
|||
--- a/applications/forwardingrules-manager/src/main/java/org/opendaylight/openflowplugin/applications/frm/impl/DevicesGroupRegistry.java
|
||||
+++ b/applications/forwardingrules-manager/src/main/java/org/opendaylight/openflowplugin/applications/frm/impl/DevicesGroupRegistry.java
|
||||
@@ -9,26 +9,27 @@
|
||||
*/
|
||||
package org.opendaylight.openflowplugin.applications.frm.impl;
|
||||
|
||||
-import java.util.ArrayList;
|
||||
-import java.util.List;
|
||||
+import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
+import java.util.Set;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import org.opendaylight.yangtools.yang.common.Uint32;
|
||||
|
||||
public class DevicesGroupRegistry {
|
||||
- private final Map<String, List<Uint32>> deviceGroupMapping = new ConcurrentHashMap<>();
|
||||
+ // CWE-407 fix: Set<Uint32> gives O(1) contains() vs O(N) for ArrayList
|
||||
+ private final Map<String, Set<Uint32>> deviceGroupMapping = new ConcurrentHashMap<>();
|
||||
|
||||
public boolean isGroupPresent(final String nodeId, final Uint32 groupId) {
|
||||
- final List<Uint32> groups = deviceGroupMapping.get(nodeId);
|
||||
+ final Set<Uint32> groups = deviceGroupMapping.get(nodeId);
|
||||
return groups != null && groups.contains(groupId);
|
||||
}
|
||||
|
||||
public void storeGroup(final String nodeId, final Uint32 groupId) {
|
||||
- deviceGroupMapping.computeIfAbsent(nodeId, groupIdList -> new ArrayList<>()).add(groupId);
|
||||
+ deviceGroupMapping.computeIfAbsent(nodeId, groupIdList -> new HashSet<>()).add(groupId);
|
||||
}
|
||||
|
||||
public void removeGroup(final String nodeId, final Uint32 groupId) {
|
||||
- deviceGroupMapping.computeIfPresent(nodeId, (node, groupIds) -> groupIds).remove(groupId);
|
||||
+ deviceGroupMapping.computeIfPresent(nodeId, (node, groupIds) -> groupIds).remove(groupId); // O(1) with HashSet
|
||||
}
|
||||
|
||||
public void clearNodeGroups(final String nodeId) {
|
||||
Loading…
Add table
Add a link
Reference in a new issue