Tal Nisan has uploaded a new change for review. Change subject: coverity: Fix INVALIDATE_ITERATOR warning in SessionDataContainer ......................................................................
coverity: Fix INVALIDATE_ITERATOR warning in SessionDataContainer Altering a collection while iterating over it with a for loop will most likely cause ConcurrentModificationException, using an iterator instead Change-Id: I223c41e0ad0c091532e598f281f0679306f1164c Signed-off-by: Tal Nisan <[email protected]> --- M backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/session/SessionDataContainer.java 1 file changed, 5 insertions(+), 6 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/75/27275/1 diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/session/SessionDataContainer.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/session/SessionDataContainer.java index 5cbbf2c..51062ec 100644 --- a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/session/SessionDataContainer.java +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/session/SessionDataContainer.java @@ -1,6 +1,7 @@ package org.ovirt.engine.core.bll.session; import java.util.Date; +import java.util.Iterator; import java.util.Map.Entry; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentMap; @@ -144,12 +145,14 @@ @OnTimerMethodAnnotation("cleanExpiredUsersSessions") public final void cleanExpiredUsersSessions() { Date now = new Date(); - for (Entry<String, SessionInfo> entry : sessionInfoMap.entrySet()) { + Iterator<Entry<String, SessionInfo>> iter = sessionInfoMap.entrySet().iterator(); + while (iter.hasNext()) { + Entry<String, SessionInfo> entry = iter.next(); ConcurrentMap<String, Object> sessionMap = entry.getValue().contentOfSession; Date hardLimit = (Date) sessionMap.get(HARD_LIMIT_PARAMETER_NAME); Date softLimit = (Date) sessionMap.get(SOFT_LIMIT_PARAMETER_NAME); if ((hardLimit != null && hardLimit.before(now)) || (softLimit != null && softLimit.before(now))) { - removeSessionImpl(entry.getKey()); + iter.remove(); } } } @@ -268,10 +271,6 @@ sessionInfo.contentOfSession.put(SOFT_LIMIT_PARAMETER_NAME, DateUtils.addMinutes(new Date(), softLimitValue)); } - } - - private void removeSessionImpl(String sessionId) { - sessionInfoMap.remove(sessionId); } } -- To view, visit http://gerrit.ovirt.org/27275 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I223c41e0ad0c091532e598f281f0679306f1164c Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Tal Nisan <[email protected]> _______________________________________________ Engine-patches mailing list [email protected] http://lists.ovirt.org/mailman/listinfo/engine-patches
