368191: fixed numerical overflow converting seconds to ms
This commit is contained in:
parent
d0b81a185c
commit
2d24eb8240
|
@ -79,7 +79,7 @@ public class NoSqlSession extends AbstractSession
|
|||
__log.debug("NoSqlSession:access:active "+_active);
|
||||
if (_active.incrementAndGet()==1)
|
||||
{
|
||||
int period=_manager.getStalePeriod()*1000;
|
||||
long period=_manager.getStalePeriod()*1000L;
|
||||
if (period==0)
|
||||
refresh();
|
||||
else if (period>0)
|
||||
|
|
|
@ -50,7 +50,7 @@ public class DefaultHandler extends AbstractHandler
|
|||
{
|
||||
private static final Logger LOG = Log.getLogger(DefaultHandler.class);
|
||||
|
||||
final long _faviconModified=(System.currentTimeMillis()/1000)*1000;
|
||||
final long _faviconModified=(System.currentTimeMillis()/1000)*1000L;
|
||||
byte[] _favicon;
|
||||
boolean _serveIcon=true;
|
||||
boolean _showContexts=true;
|
||||
|
|
|
@ -62,7 +62,7 @@ public abstract class AbstractSession implements AbstractSessionManager.SessionI
|
|||
_accessed=_created;
|
||||
_lastAccessed=_created;
|
||||
_requests=1;
|
||||
_maxIdleMs=_manager._dftMaxIdleSecs>0?_manager._dftMaxIdleSecs*1000:-1;
|
||||
_maxIdleMs=_manager._dftMaxIdleSecs>0?_manager._dftMaxIdleSecs*1000L:-1;
|
||||
if (LOG.isDebugEnabled())
|
||||
LOG.debug("new session & id "+_nodeId+" "+_clusterId);
|
||||
}
|
||||
|
@ -430,7 +430,7 @@ public abstract class AbstractSession implements AbstractSessionManager.SessionI
|
|||
/* ------------------------------------------------------------- */
|
||||
public void setMaxInactiveInterval(int secs)
|
||||
{
|
||||
_maxIdleMs=(long)secs*1000;
|
||||
_maxIdleMs=(long)secs*1000L;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------- */
|
||||
|
|
|
@ -53,9 +53,9 @@ public class HashSessionManager extends AbstractSessionManager
|
|||
private Timer _timer;
|
||||
private boolean _timerStop=false;
|
||||
private TimerTask _task;
|
||||
int _scavengePeriodMs=30000;
|
||||
int _savePeriodMs=0; //don't do period saves by default
|
||||
int _idleSavePeriodMs = 0; // don't idle save sessions by default.
|
||||
long _scavengePeriodMs=30000;
|
||||
long _savePeriodMs=0; //don't do period saves by default
|
||||
long _idleSavePeriodMs = 0; // don't idle save sessions by default.
|
||||
private TimerTask _saveTask;
|
||||
File _storeDir;
|
||||
private boolean _lazyLoad=false;
|
||||
|
@ -134,7 +134,7 @@ public class HashSessionManager extends AbstractSessionManager
|
|||
*/
|
||||
public int getScavengePeriod()
|
||||
{
|
||||
return _scavengePeriodMs/1000;
|
||||
return (int)(_scavengePeriodMs/1000);
|
||||
}
|
||||
|
||||
|
||||
|
@ -160,7 +160,7 @@ public class HashSessionManager extends AbstractSessionManager
|
|||
if (_idleSavePeriodMs <= 0)
|
||||
return 0;
|
||||
|
||||
return _idleSavePeriodMs / 1000;
|
||||
return (int)(_idleSavePeriodMs / 1000);
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
|
@ -174,7 +174,7 @@ public class HashSessionManager extends AbstractSessionManager
|
|||
*/
|
||||
public void setIdleSavePeriod(int seconds)
|
||||
{
|
||||
_idleSavePeriodMs = seconds * 1000;
|
||||
_idleSavePeriodMs = seconds * 1000L;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
|
@ -182,7 +182,7 @@ public class HashSessionManager extends AbstractSessionManager
|
|||
public void setMaxInactiveInterval(int seconds)
|
||||
{
|
||||
super.setMaxInactiveInterval(seconds);
|
||||
if (_dftMaxIdleSecs>0&&_scavengePeriodMs>_dftMaxIdleSecs*1000)
|
||||
if (_dftMaxIdleSecs>0&&_scavengePeriodMs>_dftMaxIdleSecs*1000L)
|
||||
setScavengePeriod((_dftMaxIdleSecs+9)/10);
|
||||
}
|
||||
|
||||
|
@ -192,7 +192,7 @@ public class HashSessionManager extends AbstractSessionManager
|
|||
*/
|
||||
public void setSavePeriod (int seconds)
|
||||
{
|
||||
int period = (seconds * 1000);
|
||||
long period = (seconds * 1000L);
|
||||
if (period < 0)
|
||||
period=0;
|
||||
_savePeriodMs=period;
|
||||
|
@ -235,7 +235,7 @@ public class HashSessionManager extends AbstractSessionManager
|
|||
if (_savePeriodMs<=0)
|
||||
return 0;
|
||||
|
||||
return _savePeriodMs/1000;
|
||||
return (int)(_savePeriodMs/1000);
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
|
@ -247,8 +247,8 @@ public class HashSessionManager extends AbstractSessionManager
|
|||
if (seconds==0)
|
||||
seconds=60;
|
||||
|
||||
int old_period=_scavengePeriodMs;
|
||||
int period=seconds*1000;
|
||||
long old_period=_scavengePeriodMs;
|
||||
long period=seconds*1000L;
|
||||
if (period>60000)
|
||||
period=60000;
|
||||
if (period<1000)
|
||||
|
@ -297,7 +297,7 @@ public class HashSessionManager extends AbstractSessionManager
|
|||
for (Iterator<HashedSession> i=_sessions.values().iterator(); i.hasNext();)
|
||||
{
|
||||
HashedSession session=i.next();
|
||||
long idleTime=session.getMaxInactiveInterval()*1000;
|
||||
long idleTime=session.getMaxInactiveInterval()*1000L;
|
||||
if (idleTime>0&&session.getAccessed()+idleTime<now)
|
||||
{
|
||||
// Found a stale session, add it to the list
|
||||
|
|
|
@ -60,7 +60,7 @@ public class HashedSession extends AbstractSession
|
|||
public void setMaxInactiveInterval(int secs)
|
||||
{
|
||||
super.setMaxInactiveInterval(secs);
|
||||
if (getMaxInactiveInterval()>0&&(getMaxInactiveInterval()*1000/10)<_hashSessionManager._scavengePeriodMs)
|
||||
if (getMaxInactiveInterval()>0&&(getMaxInactiveInterval()*1000L/10)<_hashSessionManager._scavengePeriodMs)
|
||||
_hashSessionManager.setScavengePeriod((secs+9)/10);
|
||||
}
|
||||
|
||||
|
|
|
@ -69,7 +69,7 @@ public class JDBCSessionIdManager extends AbstractSessionIdManager
|
|||
protected Timer _timer; //scavenge timer
|
||||
protected TimerTask _task; //scavenge task
|
||||
protected long _lastScavengeTime;
|
||||
protected long _scavengeIntervalMs = 1000 * 60 * 10; //10mins
|
||||
protected long _scavengeIntervalMs = 1000L * 60 * 10; //10mins
|
||||
protected String _blobType; //if not set, is deduced from the type of the database at runtime
|
||||
|
||||
protected String _createSessionIdTable;
|
||||
|
@ -245,7 +245,7 @@ public class JDBCSessionIdManager extends AbstractSessionIdManager
|
|||
sec=60;
|
||||
|
||||
long old_period=_scavengeIntervalMs;
|
||||
long period=sec*1000;
|
||||
long period=sec*1000L;
|
||||
|
||||
_scavengeIntervalMs=period;
|
||||
|
||||
|
|
|
@ -277,11 +277,11 @@ public class JDBCSessionManager extends AbstractSessionManager
|
|||
super(JDBCSessionManager.this,request);
|
||||
_data = new SessionData(getClusterId(),_jdbcAttributes);
|
||||
if (_dftMaxIdleSecs>0)
|
||||
_data.setMaxIdleMs(_dftMaxIdleSecs*1000);
|
||||
_data.setMaxIdleMs(_dftMaxIdleSecs*1000L);
|
||||
_data.setCanonicalContext(canonicalize(_context.getContextPath()));
|
||||
_data.setVirtualHost(getVirtualHost(_context));
|
||||
int maxInterval=getMaxInactiveInterval();
|
||||
_data.setExpiryTime(maxInterval <= 0 ? 0 : (System.currentTimeMillis() + maxInterval*1000));
|
||||
_data.setExpiryTime(maxInterval <= 0 ? 0 : (System.currentTimeMillis() + maxInterval*1000L));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -293,7 +293,7 @@ public class JDBCSessionManager extends AbstractSessionManager
|
|||
super(JDBCSessionManager.this,data.getCreated(), accessed, data.getId());
|
||||
_data=data;
|
||||
if (_dftMaxIdleSecs>0)
|
||||
_data.setMaxIdleMs(_dftMaxIdleSecs*1000);
|
||||
_data.setMaxIdleMs(_dftMaxIdleSecs*1000L);
|
||||
_jdbcAttributes.putAll(_data.getAttributeMap());
|
||||
_data.setAttributeMap(_jdbcAttributes);
|
||||
}
|
||||
|
@ -333,7 +333,7 @@ public class JDBCSessionManager extends AbstractSessionManager
|
|||
_data.setAccessed(time);
|
||||
|
||||
int maxInterval=getMaxInactiveInterval();
|
||||
_data.setExpiryTime(maxInterval <= 0 ? 0 : (time + maxInterval*1000));
|
||||
_data.setExpiryTime(maxInterval <= 0 ? 0 : (time + maxInterval*1000L));
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
@ -357,7 +357,7 @@ public class JDBCSessionManager extends AbstractSessionManager
|
|||
updateSession(_data);
|
||||
didActivate();
|
||||
}
|
||||
else if ((_data._accessed - _data._lastSaved) >= (getSaveInterval() * 1000))
|
||||
else if ((_data._accessed - _data._lastSaved) >= (getSaveInterval() * 1000L))
|
||||
{
|
||||
updateSessionAccessTime(_data);
|
||||
}
|
||||
|
@ -506,23 +506,23 @@ public class JDBCSessionManager extends AbstractSessionManager
|
|||
LOG.debug("getSession("+idInCluster+"): not in session map,"+
|
||||
" now="+now+
|
||||
" lastSaved="+(session==null?0:session._data._lastSaved)+
|
||||
" interval="+(_saveIntervalSec * 1000));
|
||||
" interval="+(_saveIntervalSec * 1000L));
|
||||
else
|
||||
LOG.debug("getSession("+idInCluster+"): in session map, "+
|
||||
" now="+now+
|
||||
" lastSaved="+(session==null?0:session._data._lastSaved)+
|
||||
" interval="+(_saveIntervalSec * 1000)+
|
||||
" interval="+(_saveIntervalSec * 1000L)+
|
||||
" lastNode="+session._data.getLastNode()+
|
||||
" thisNode="+getSessionIdManager().getWorkerName()+
|
||||
" difference="+(now - session._data._lastSaved));
|
||||
}
|
||||
|
||||
if (session==null || ((now - session._data._lastSaved) >= (_saveIntervalSec * 1000)))
|
||||
if (session==null || ((now - session._data._lastSaved) >= (_saveIntervalSec * 1000L)))
|
||||
{
|
||||
LOG.debug("getSession("+idInCluster+"): no session in session map or stale session. Reloading session data from db.");
|
||||
data = loadSession(idInCluster, canonicalize(_context.getContextPath()), getVirtualHost(_context));
|
||||
}
|
||||
else if ((now - session._data._lastSaved) >= (_saveIntervalSec * 1000))
|
||||
else if ((now - session._data._lastSaved) >= (_saveIntervalSec * 1000L))
|
||||
{
|
||||
LOG.debug("getSession("+idInCluster+"): stale session. Reloading session data from db.");
|
||||
data = loadSession(idInCluster, canonicalize(_context.getContextPath()), getVirtualHost(_context));
|
||||
|
|
Loading…
Reference in New Issue