Skip to content

Commit

Permalink
Issue #8460 simplify DefaultSessionIdManager start (#8464)
Browse files Browse the repository at this point in the history
* Issue #8460 check DefaultSessionIdManager is started
  • Loading branch information
janbartel committed Nov 23, 2022
1 parent a44af98 commit c4e1db5
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import java.security.SecureRandom;
import java.util.Collection;
import java.util.HashSet;
import java.util.Objects;
import java.util.Random;
import java.util.Set;
import java.util.concurrent.atomic.AtomicLong;
Expand Down Expand Up @@ -66,7 +67,8 @@ public class DefaultSessionIdManager extends ContainerLifeCycle implements Sessi
*/
public DefaultSessionIdManager(Server server)
{
_server = server;
_server = Objects.requireNonNull(server);
_server.setSessionIdManager(this);
}

/**
Expand All @@ -84,7 +86,8 @@ public DefaultSessionIdManager(Server server, Random random)
*/
public void setServer(Server server)
{
_server = server;
_server = Objects.requireNonNull(server);
_server.setSessionIdManager(this);
}

/**
Expand Down Expand Up @@ -263,7 +266,7 @@ public String newSessionId(long seedTerm)
}
return id;
}

@Override
public boolean isIdInUse(String id)
{
Expand Down Expand Up @@ -301,9 +304,6 @@ public boolean isIdInUse(String id)
@Override
protected void doStart() throws Exception
{
if (_server == null)
throw new IllegalStateException("No Server for SessionIdManager");

initRandom();

if (_workerName == null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import java.io.PrintWriter;
import java.util.Date;
import java.util.Enumeration;
import java.util.UUID;

import jakarta.servlet.RequestDispatcher;
import jakarta.servlet.ServletConfig;
Expand Down Expand Up @@ -75,6 +76,8 @@ protected void handleForm(HttpServletRequest request)
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)
{
Expand Down

0 comments on commit c4e1db5

Please sign in to comment.