diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/session/Session.java b/jetty-server/src/main/java/org/eclipse/jetty/server/session/Session.java index 959a39ba931..e885c7bdada 100644 --- a/jetty-server/src/main/java/org/eclipse/jetty/server/session/Session.java +++ b/jetty-server/src/main/java/org/eclipse/jetty/server/session/Session.java @@ -232,8 +232,7 @@ public class Session implements SessionHandler.SessionIf long lastAccessed = _sessionData.getAccessed(); _sessionData.setAccessed(time); _sessionData.setLastAccessed(lastAccessed); - int maxInterval=getMaxInactiveInterval(); - _sessionData.setExpiry(maxInterval <= 0 ? 0 : (time + maxInterval*1000L)); + _sessionData.calcAndSetExpiry(time); if (isExpiredAt(time)) { invalidate(); diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/session/SessionData.java b/jetty-server/src/main/java/org/eclipse/jetty/server/session/SessionData.java index 6ee6e96e42f..ef385042af5 100644 --- a/jetty-server/src/main/java/org/eclipse/jetty/server/session/SessionData.java +++ b/jetty-server/src/main/java/org/eclipse/jetty/server/session/SessionData.java @@ -251,6 +251,16 @@ public class SessionData implements Serializable return (getMaxInactiveMs() <= 0 ? 0 : (System.currentTimeMillis() + getMaxInactiveMs())); } + public long calcExpiry (long time) + { + return (getMaxInactiveMs() <= 0 ? 0 : (time + getMaxInactiveMs())); + } + + public void calcAndSetExpiry (long time) + { + setExpiry(calcExpiry(time)); + } + public void calcAndSetExpiry () { setExpiry(calcExpiry()); @@ -351,8 +361,8 @@ public class SessionData implements Serializable public boolean isExpiredAt (long time) { if (LOG.isDebugEnabled()) - LOG.debug("Testing expiry on session {}: expires at {} now {}", _id, getExpiry(), time); - if (getExpiry() <= 0) + LOG.debug("Testing expiry on session {}: expires at {} now {} maxIdle {}", _id, getExpiry(), time, getMaxInactiveMs()); + if (getMaxInactiveMs() <= 0) return false; //never expires return (getExpiry() <= time); }