Juan Hernandez has uploaded a new change for review. Change subject: core: Avoid concurrent modification in DirectorySearcher ......................................................................
core: Avoid concurrent modification in DirectorySearcher When doing LDAP searches we iterate the list of LDAP servers and inside the loop we potentially reorder that list. This can generate concurrent modification exceptions. To prevent that this patch makes a copy of the list and iterates it instead of the original. Change-Id: I1781df6c73178097898233e6a15b36844cb1488e Signed-off-by: Juan Hernandez <juan.hernan...@redhat.com> --- M backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/adbroker/DirectorySearcher.java 1 file changed, 5 insertions(+), 3 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/07/14207/1 diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/adbroker/DirectorySearcher.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/adbroker/DirectorySearcher.java index fd85d66..fdc377a 100644 --- a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/adbroker/DirectorySearcher.java +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/adbroker/DirectorySearcher.java @@ -79,9 +79,11 @@ } List<?> response = null; - for (Iterator<URI> iterator = ldapServerURIs.iterator(); iterator.hasNext();) { - URI ldapURI = iterator.next(); - response = findAndOrderServers(queryData, ldapURI, domainName, resultCount, ldapServerURIs); + // The list of is modified inside the loop so we need to iterate a copy + // to avoid concurrent modification exceptions: + URI[] uris = ldapServerURIs.toArray(new URI[ldapServerURIs.size()]); + for (URI uri : uris) { + response = findAndOrderServers(queryData, uri, domainName, resultCount, ldapServerURIs); if (response != null) { break; } -- To view, visit http://gerrit.ovirt.org/14207 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I1781df6c73178097898233e6a15b36844cb1488e Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Juan Hernandez <juan.hernan...@redhat.com> _______________________________________________ Engine-patches mailing list Engine-patches@ovirt.org http://lists.ovirt.org/mailman/listinfo/engine-patches