[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
Re: [jetty-users] Issues with Jetty 9.4 session IDs
|
Hi Silvio,
To get rid of the workername prefix, you should be able to set it to "". To get rid of the .workername suffix, then it is sufficient to override the DefaultSessionIdManager.getExtendedId(String,HttpServletRequest) method - if you're still seeing the suffix, that is wierd, because it is only that method that creates it!
I'm going to make a change for 9.4.1 as follows:
* DefaultSessionIdManager.setWorkerName(null) will coerce null to ""
* if DefaultSessionIdManager.setWorkerName(String) is never called, then the current code to set up a default worker name will be called
* ensure that the tests for prepending the workername and for suffixing the .workername all skip the addition iff it is the empty string or null
I'm attaching a diff that I'm working on if you want to apply it to your local build before 9.4.1 comes out (which should be soonish).
Jan
diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/session/DefaultSessionIdManager.java b/jetty-server/src/main/java/org/eclipse/jetty/server/session/DefaultSessionIdManager.java
index 96fb1fe..6503a2e 100644
--- a/jetty-server/src/main/java/org/eclipse/jetty/server/session/DefaultSessionIdManager.java
+++ b/jetty-server/src/main/java/org/eclipse/jetty/server/session/DefaultSessionIdManager.java
@@ -30,6 +30,7 @@ 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.StringUtil;
import org.eclipse.jetty.util.component.ContainerLifeCycle;
import org.eclipse.jetty.util.log.Log;
import org.eclipse.jetty.util.log.Logger;
@@ -157,9 +158,14 @@ public class DefaultSessionIdManager extends ContainerLifeCycle implements Sessi
{
if (isRunning())
throw new IllegalStateException(getState());
- if (workerName.contains("."))
- throw new IllegalArgumentException("Name cannot contain '.'");
- _workerName=workerName;
+ if (workerName == null)
+ _workerName = "";
+ else
+ {
+ if (workerName.contains("."))
+ throw new IllegalArgumentException("Name cannot contain '.'");
+ _workerName=workerName;
+ }
}
/* ------------------------------------------------------------ */
@@ -281,7 +287,7 @@ public class DefaultSessionIdManager extends ContainerLifeCycle implements Sessi
//add in the id of the node to ensure unique id across cluster
//NOTE this is different to the node suffix which denotes which node the request was received on
- if (_workerName!=null)
+ if (!StringUtil.isBlank(_workerName))
id=_workerName + id;
id = id+Long.toString(COUNTER.getAndIncrement());
@@ -417,7 +423,7 @@ public class DefaultSessionIdManager extends ContainerLifeCycle implements Sessi
@Override
public String getExtendedId(String clusterId, HttpServletRequest request)
{
- if (_workerName!=null)
+ if (!StringUtil.isBlank(_workerName))
{
if (_workerAttr==null)
return clusterId+'.'+_workerName;
@@ -472,7 +478,7 @@ public class DefaultSessionIdManager extends ContainerLifeCycle implements Sessi
for (SessionHandler manager:getSessionHandlers())
{
manager.invalidate(id);
- }
+ }
}