Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 324601

Summary: HttpSession.setMaxInactiveInterval needs really good accuracy
Product: [RT] Jetty Reporter: David Jencks <david.a.jencks>
Component: serverAssignee: Greg Wilkins <gregw>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: jetty-inbox
Version: 8.0.0   
Target Milestone: 7.1.x   
Hardware: PC   
OS: Mac OS X - Carbon (unsup.)   
Whiteboard:

Description David Jencks CLA 2010-09-06 17:48:22 EDT
Some people seem to want setMaxInactiveInterval to have results within about 10ms of what is set.  One way to do this is to change AbstractSessionManager.Session.isValid() like this:

        protected boolean isValid()
        {
            if (!_invalid && !_newSession) {
                if (_lastAccessed + _maxIdleMs < System.currentTimeMillis()) {
                    invalidate();
                }
            }
            return !_invalid;
        }


However this adds another access of System.currentTimeMillis.  I suspect that the same kind of logic could be in the call chain of SessionHandler.doScope where it calls 

                        HttpCookie cookie = _sessionManager.access(session,request.isSecure());

(line 167 in jetty-8) as that also accesses the current time.
Comment 1 Greg Wilkins CLA 2010-09-06 20:59:43 EDT
Really??? How stupid!

If a request is 10ms late (easy with normal network jitter), then the session is invalid????   You get GC's longer than 10ms! Sounds like some silly test harness rather than any actual need.

Does this also mean that we should be scavenging at this accuracy?  or just on incoming requests?
Comment 2 Greg Wilkins CLA 2010-09-06 21:25:05 EDT
r2252

I put the fix in the access method, as the current time is passed in (avoiding another currentTimeMillis lookup) and the session is already locked.