Make sync on id generation more tightly scoped.
This commit is contained in:
Jan Bartel 2016-12-08 11:29:13 +11:00
parent be3085d5f7
commit 8e0725db1c
1 changed files with 65 additions and 63 deletions

View File

@ -30,7 +30,6 @@ import org.eclipse.jetty.server.Handler;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.server.SessionIdManager;
import org.eclipse.jetty.server.handler.ContextHandler;
import org.eclipse.jetty.util.component.AbstractLifeCycle;
import org.eclipse.jetty.util.component.ContainerLifeCycle;
import org.eclipse.jetty.util.log.Log;
import org.eclipse.jetty.util.log.Logger;
@ -208,8 +207,6 @@ public class DefaultSessionIdManager extends ContainerLifeCycle implements Sessi
*/
@Override
public String newSessionId(HttpServletRequest request, long created)
{
synchronized (this)
{
if (request==null)
return newSessionId(created);
@ -235,7 +232,8 @@ public class DefaultSessionIdManager extends ContainerLifeCycle implements Sessi
request.setAttribute(__NEW_SESSION_ID,id);
return id;
}
}
/* ------------------------------------------------------------ */
/**
@ -246,6 +244,9 @@ public class DefaultSessionIdManager extends ContainerLifeCycle implements Sessi
{
// pick a new unique ID!
String id=null;
synchronized (_random)
{
while (id==null||id.length()==0)
{
long r0=_weakRandom
@ -286,6 +287,7 @@ public class DefaultSessionIdManager extends ContainerLifeCycle implements Sessi
id = id+Long.toString(COUNTER.getAndIncrement());
}
}
return id;
}