Author: markt
Date: Wed Jan 20 12:21:26 2016
New Revision: 1725706
URL: http://svn.apache.org/viewvc?rev=1725706&view=rev
Log:
Don't need to bind the thread when saving sessions. Classes already have
the necessary reference to their class loader.
Modified:
tomcat/trunk/java/org/apache/catalina/valves/PersistentValve.java
Modified: tomcat/trunk/java/org/apache/catalina/valves/PersistentValve.java
URL:
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/valves/PersistentValve.java?rev=1725706&r1=1725705&r2=1725706&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/valves/PersistentValve.java (original)
+++ tomcat/trunk/java/org/apache/catalina/valves/PersistentValve.java Wed Jan
20 12:21:26 2016
@@ -21,11 +21,7 @@ import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletResponse;
-import org.apache.catalina.Container;
import org.apache.catalina.Context;
-import org.apache.catalina.Engine;
-import org.apache.catalina.Globals;
-import org.apache.catalina.Host;
import org.apache.catalina.Manager;
import org.apache.catalina.Session;
import org.apache.catalina.Store;
@@ -46,14 +42,6 @@ import org.apache.catalina.connector.Res
*/
public class PersistentValve extends ValveBase {
- // Saves a couple of calls to getClassLoader() on every request. Under high
- // load these calls took just long enough to appear as a hot spot (although
- // a very minor one) in a profiler.
- private static final ClassLoader MY_CLASSLOADER =
PersistentValve.class.getClassLoader();
-
- private volatile boolean clBindRequired;
-
-
//------------------------------------------------------ Constructor
public PersistentValve() {
@@ -63,17 +51,6 @@ public class PersistentValve extends Val
// --------------------------------------------------------- Public Methods
- @Override
- public void setContainer(Container container) {
- super.setContainer(container);
- if (container instanceof Engine || container instanceof Host) {
- clBindRequired = true;
- } else {
- clBindRequired = false;
- }
- }
-
-
/**
* Select the appropriate child Context to process this request,
* based on the specified request URI. If no matching Context can
@@ -108,7 +85,6 @@ public class PersistentValve extends Val
session = store.load(sessionId);
} catch (Exception e) {
container.getLogger().error("deserializeError");
- } finally {
}
if (session != null) {
if (!session.isValid() ||
@@ -155,38 +131,31 @@ public class PersistentValve extends Val
container.getLogger().debug("newsessionId: " + newsessionId);
}
if (newsessionId!=null) {
- try {
- bind(context);
-
- /* store the session and remove it from the manager */
- if (manager instanceof StoreManager) {
- Session session = manager.findSession(newsessionId);
- Store store = ((StoreManager) manager).getStore();
- if (store != null && session != null &&
session.isValid() &&
- !isSessionStale(session,
System.currentTimeMillis())) {
- store.save(session);
- ((StoreManager) manager).removeSuper(session);
- session.recycle();
- } else {
- if (container.getLogger().isDebugEnabled()) {
- container.getLogger().debug("newsessionId
store: " +
- store + " session: " + session +
- " valid: " +
- (session == null ? "N/A" :
Boolean.toString(
- session.isValid())) +
- " stale: " + isSessionStale(session,
- System.currentTimeMillis()));
- }
-
- }
+ /* store the session and remove it from the manager */
+ if (manager instanceof StoreManager) {
+ Session session = manager.findSession(newsessionId);
+ Store store = ((StoreManager) manager).getStore();
+ if (store != null && session != null && session.isValid()
&&
+ !isSessionStale(session,
System.currentTimeMillis())) {
+ store.save(session);
+ ((StoreManager) manager).removeSuper(session);
+ session.recycle();
} else {
if (container.getLogger().isDebugEnabled()) {
- container.getLogger().debug("newsessionId Manager:
" +
- manager);
+ container.getLogger().debug("newsessionId store: "
+
+ store + " session: " + session +
+ " valid: " +
+ (session == null ? "N/A" :
Boolean.toString(
+ session.isValid())) +
+ " stale: " + isSessionStale(session,
+ System.currentTimeMillis()));
}
}
- } finally {
- unbind(context);
+ } else {
+ if (container.getLogger().isDebugEnabled()) {
+ container.getLogger().debug("newsessionId Manager: " +
+ manager);
+ }
}
}
}
@@ -217,18 +186,4 @@ public class PersistentValve extends Val
return false;
}
-
-
- private void bind(Context context) {
- if (clBindRequired) {
- context.bind(Globals.IS_SECURITY_ENABLED, MY_CLASSLOADER);
- }
- }
-
-
- private void unbind(Context context) {
- if (clBindRequired) {
- context.unbind(Globals.IS_SECURITY_ENABLED, MY_CLASSLOADER);
- }
- }
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]