Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
("Allow session timeout configuration")
  • Loading branch information
jfarcand committed Sep 16, 2010
1 parent 81d907c commit cd93085
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
Expand Up @@ -67,6 +67,7 @@ abstract public class AsynchronousProcessor implements CometSupport<AtmosphereRe

protected final static Action timedoutAction = new Action(Action.TYPE.TIMEOUT);
protected final static Action cancelledAction = new Action(Action.TYPE.CANCELLED);
private final static int DEFAULT_SESSION_TIMEOUT = 1800;

protected final Logger logger = LoggerUtils.getLogger();

Expand Down Expand Up @@ -162,7 +163,9 @@ Action action(HttpServletRequest req, HttpServletResponse res)
// operation from disparate requests.
HttpSession session = req.getSession(true);
// Do not allow times out.
session.setMaxInactiveInterval(-1);
if (session.getMaxInactiveInterval() == DEFAULT_SESSION_TIMEOUT) {
session.setMaxInactiveInterval(-1);
}
}

req.setAttribute(AtmosphereServlet.SUPPORT_SESSION, supportSession());
Expand Down
Expand Up @@ -162,6 +162,12 @@ public void suspend(long timeout) {
}

public void suspend(long timeout, boolean flushComment) {

if (req.getSession(false) != null && req.getSession().getMaxInactiveInterval() != -1 && req.getSession().getMaxInactiveInterval() < timeout) {
throw new IllegalStateException("Cannot suspend a " +
"response longer than the session timeout. Increase the value of session-timeout in web.xml");
}

if (!event.isResumedOnTimeout()) {

String upgrade = req.getHeader("Connection");
Expand Down

0 comments on commit cd93085

Please sign in to comment.