Issue #8460 simplify DefaultSessionIdManager start (#8464)

* Issue #8460 check DefaultSessionIdManager is started
This commit is contained in:
Jan Bartel 2022-11-23 13:47:29 +11:00 committed by GitHub
parent e33c9a1284
commit cd7482a151
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 9 additions and 10 deletions

View File

@ -17,6 +17,7 @@ import java.io.IOException;
import java.io.PrintWriter;
import java.util.Date;
import java.util.Enumeration;
import java.util.UUID;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
@ -75,6 +76,8 @@ public class SessionDump extends HttpServlet
session.setAttribute("test", "value");
session.setAttribute("obj", new ObjectAttributeValue(System.currentTimeMillis()));
session.setAttribute("WEBCL", new MultiMap<>());
UUID uuid = UUID.randomUUID();
session.setAttribute("uuid", uuid);
}
else if (session != null)
{

View File

@ -100,7 +100,6 @@ public class BalancerServletTest
{
DefaultSessionIdManager sessionIdManager = new DefaultSessionIdManager(server);
sessionIdManager.setWorkerName(nodeName);
server.setSessionIdManager(sessionIdManager);
}
return server;

View File

@ -5,7 +5,6 @@
<!-- ===================================================================== -->
<!-- Configure a SessionIdManager -->
<!-- ===================================================================== -->
<Set name="sessionIdManager">
<New id="idMgr" class="org.eclipse.jetty.server.session.DefaultSessionIdManager">
<Arg>
<Ref refid="Server"/>
@ -32,5 +31,4 @@
</New>
</Set>
</New>
</Set>
</Configure>

View File

@ -15,6 +15,7 @@ package org.eclipse.jetty.server.session;
import java.security.SecureRandom;
import java.util.HashSet;
import java.util.Objects;
import java.util.Random;
import java.util.Set;
import java.util.concurrent.atomic.AtomicLong;
@ -67,7 +68,8 @@ public class DefaultSessionIdManager extends ContainerLifeCycle implements Sessi
*/
public DefaultSessionIdManager(Server server)
{
_server = server;
_server = Objects.requireNonNull(server);
_server.setSessionIdManager(this);
}
/**
@ -85,7 +87,8 @@ public class DefaultSessionIdManager extends ContainerLifeCycle implements Sessi
*/
public void setServer(Server server)
{
_server = server;
_server = Objects.requireNonNull(server);
_server.setSessionIdManager(this);
}
/**
@ -270,7 +273,7 @@ public class DefaultSessionIdManager extends ContainerLifeCycle implements Sessi
}
return id;
}
@Override
public boolean isIdInUse(String id)
{
@ -308,9 +311,6 @@ public class DefaultSessionIdManager extends ContainerLifeCycle implements Sessi
@Override
protected void doStart() throws Exception
{
if (_server == null)
throw new IllegalStateException("No Server for SessionIdManager");
initRandom();
if (_workerName == null)

View File

@ -426,7 +426,6 @@ public class SessionHandler extends ScopedHandler
{
Thread.currentThread().setContextClassLoader(serverLoader);
_sessionIdManager = new DefaultSessionIdManager(server);
server.setSessionIdManager(_sessionIdManager);
server.manage(_sessionIdManager);
_sessionIdManager.start();
}