Moti Asayag has posted comments on this change. Change subject: core: Use set instead of List to prevent duplicate key violiation ......................................................................
Patch Set 1: (1 comment) https://gerrit.ovirt.org/#/c/40709/1/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/tasks/CommandExecutor.java File backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/tasks/CommandExecutor.java: Line 180: private Collection<CommandAssociatedEntity> buildCommandAssociatedEntities(Guid cmdId, SubjectEntity... subjectEntities) { Line 181: if (subjectEntities.length == 0) { Line 182: return Collections.emptyList(); Line 183: } Line 184: Set<CommandAssociatedEntity> results = new HashSet<>(subjectEntities.length); the only variable of this method args that could lead to non unique result is the subject entities array. I'd suggest instead creating a Set out of it, and iterate over the Set when constructing the results array. The entire approach will be more accurate: * results array size will be precise * no need to instantiate CommandAssociatedEntity for dup entities Line 185: for (SubjectEntity subjectEntity : subjectEntities) { Line 186: results.add(new CommandAssociatedEntity(cmdId, subjectEntity.getEntityType(), subjectEntity.getEntityId())); Line 187: Line 188: } -- To view, visit https://gerrit.ovirt.org/40709 To unsubscribe, visit https://gerrit.ovirt.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I55a2933da86aec6202fd806bf1a5701811ed1207 Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Maor Lipchuk <[email protected]> Gerrit-Reviewer: Daniel Erez <[email protected]> Gerrit-Reviewer: Jenkins CI Gerrit-Reviewer: Moti Asayag <[email protected]> Gerrit-Reviewer: [email protected] Gerrit-HasComments: Yes _______________________________________________ Engine-patches mailing list [email protected] http://lists.ovirt.org/mailman/listinfo/engine-patches
