Skip to content

Commit

Permalink
[#681] DestroyOldestAction fix hang on invalid session (#682)
Browse files Browse the repository at this point in the history
  • Loading branch information
vharseko authored Dec 5, 2023
1 parent ce11cde commit 50c44ff
Showing 1 changed file with 9 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
import com.iplanet.dpro.session.SessionID;
import com.iplanet.dpro.session.service.InternalSession;
import com.iplanet.dpro.session.service.QuotaExhaustionActionImpl;

import java.util.HashSet;
import java.util.Map;
import org.apache.commons.lang.StringUtils;

Expand All @@ -42,17 +44,19 @@ public class DestroyOldestAction extends QuotaExhaustionActionImpl {
public boolean action(InternalSession is, Map<String, Long> sessions) {
long smallestExpTime = Long.MAX_VALUE;
String oldestSessionID = null;
for (Map.Entry<String, Long> entry : sessions.entrySet())
if (!StringUtils.equals(is.getSessionID().toString(), entry.getKey())){
for (String sid : new HashSet<String>(sessions.keySet()))
if (!StringUtils.equals(is.getSessionID().toString(), sid)){
try {
Session session = new Session(new SessionID(entry.getKey()));
Session session = new Session(new SessionID(sid));
session.refresh(false);
long expTime = session.getTimeLeft();
if (expTime <= smallestExpTime) {
smallestExpTime = expTime;
oldestSessionID = entry.getKey();
oldestSessionID = sid;
}
} catch (SessionException ssoe) {}
} catch (SessionException ssoe) {
sessions.remove(sid); //session invalid
}
}
if (oldestSessionID != null) {
destroy(oldestSessionID,sessions);
Expand Down

0 comments on commit 50c44ff

Please sign in to comment.