protected void scavenge(){
  if (isStopping() || isStopped())   return;
  Thread thread=Thread.currentThread();
  ClassLoader origClassLoader=thread.getContextClassLoader();
  _scavengeCount++;
  try {
    if (_loader != null)     thread.setContextClassLoader(_loader);
    long now=System.currentTimeMillis();
    if (Log.isDebugEnabled())     Log.debug("Scavenging old sessions, expiring before: " + (now));
    Object[] expiredSessions;
    do {
      expiredSessions=findExpiredSessions((now));
      for (int i=0; i < expiredSessions.length; i++) {
        if (Log.isDebugEnabled())         Log.debug("Timing out expired session " + expiredSessions[i]);
        GigaSessionManager.Session expiredSession=new GigaSessionManager.Session(GigaSessionManager.this,(SessionData)expiredSessions[i]);
        expiredSession.timeout();
        if (Log.isDebugEnabled())         Log.debug("Expiring old session " + expiredSession._data);
      }
    }
 while (expiredSessions.length > 0);
    lastSessionCount=-1;
  }
 catch (  Throwable t) {
    if (t instanceof ThreadDeath)     throw ((ThreadDeath)t);
    Log.warn("Problem scavenging sessions",t);
  }
 finally {
    thread.setContextClassLoader(origClassLoader);
  }
}

protected void scavenge ( ) { if ( isStopping ( ) || isStopped ( ) ) return ; Thread thread = Thread . currentThread ( ) ; ClassLoader origClassLoader = thread . getContextClassLoader ( ) ; _scavengeCount ++ ; try { if ( _loader != null ) thread . setContextClassLoader ( _loader ) ; long now = System . currentTimeMillis ( ) ; if ( Log . isDebugEnabled ( ) ) Log . debug ( "Scavenging old sessions, expiring before: " + ( now ) ) ; Object [ ] expiredSessions ; do { expiredSessions = findExpiredSessions ( ( now ) ) ; for ( int i = 0 ; i < expiredSessions . length ; i ++ ) { if ( Log . isDebugEnabled ( ) ) Log . debug ( "Timing out expired session " + expiredSessions [ i ] ) ; GigaSessionManager . Session expiredSession = new GigaSessionManager . Session ( GigaSessionManager . this , ( SessionData ) expiredSessions [ i ] ) ; expiredSession . timeout ( ) ; if ( Log . isDebugEnabled ( ) ) Log . debug ( "Expiring old session " + expiredSession . _data ) ; } } while ( expiredSessions . length > 0 ) ; lastSessionCount = - 1 ; } catch ( Throwable t ) { if ( t instanceof ThreadDeath ) throw ( ( ThreadDeath ) t ) ; Log . warn ( "Problem scavenging sessions" , t ) ; } finally { thread . setContextClassLoader ( origClassLoader ) ; } }
look for expired sessions that we know about in our session map , and double check with the grid that it has really expired , or already been removed .
