ASF Bugzilla – Attachment 32769 Details for
Bug 57977
The original class loader isn't re-bound to the thread in PersistentValve.invoke()
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
patch against trunk
PersistentValve.patch (text/plain), 9.49 KB, created by
Kyohei Nakamura
on 2015-06-01 07:40:43 UTC
(
hide
)
Description:
patch against trunk
Filename:
MIME Type:
Creator:
Kyohei Nakamura
Created:
2015-06-01 07:40:43 UTC
Size:
9.49 KB
patch
obsolete
>Index: java/org/apache/catalina/valves/PersistentValve.java >=================================================================== >--- java/org/apache/catalina/valves/PersistentValve.java (revision 1682815) >+++ java/org/apache/catalina/valves/PersistentValve.java (working copy) >@@ -76,101 +76,107 @@ > return; > } > >- // Bind the context CL to the current thread >- Thread.currentThread().setContextClassLoader >- (context.getLoader().getClassLoader()); >+ ClassLoader oldClassLoader = Thread.currentThread().getContextClassLoader(); > >- // Update the session last access time for our session (if any) >- String sessionId = request.getRequestedSessionId(); >- Manager manager = context.getManager(); >- if (sessionId != null && manager != null) { >- if (manager instanceof StoreManager) { >- Store store = ((StoreManager) manager).getStore(); >- if (store != null) { >- Session session = null; >- try { >- session = store.load(sessionId); >- } catch (Exception e) { >- container.getLogger().error("deserializeError"); >- } >- if (session != null) { >- if (!session.isValid() || >- isSessionStale(session, System.currentTimeMillis())) { >- if (container.getLogger().isDebugEnabled()) { >- container.getLogger().debug("session swapped in is invalid or expired"); >+ try { >+ // Bind the context CL to the current thread >+ Thread.currentThread().setContextClassLoader >+ (context.getLoader().getClassLoader()); >+ >+ // Update the session last access time for our session (if any) >+ String sessionId = request.getRequestedSessionId(); >+ Manager manager = context.getManager(); >+ if (sessionId != null && manager != null) { >+ if (manager instanceof StoreManager) { >+ Store store = ((StoreManager) manager).getStore(); >+ if (store != null) { >+ Session session = null; >+ try { >+ session = store.load(sessionId); >+ } catch (Exception e) { >+ container.getLogger().error("deserializeError"); >+ } >+ if (session != null) { >+ if (!session.isValid() || >+ isSessionStale(session, System.currentTimeMillis())) { >+ if (container.getLogger().isDebugEnabled()) { >+ container.getLogger().debug("session swapped in is invalid or expired"); >+ } >+ session.expire(); >+ store.remove(sessionId); >+ } else { >+ session.setManager(manager); >+ // session.setId(sessionId); Only if new ??? >+ manager.add(session); >+ // ((StandardSession)session).activate(); >+ session.access(); >+ session.endAccess(); > } >- session.expire(); >- store.remove(sessionId); >- } else { >- session.setManager(manager); >- // session.setId(sessionId); Only if new ??? >- manager.add(session); >- // ((StandardSession)session).activate(); >- session.access(); >- session.endAccess(); > } > } > } > } >- } >- if (container.getLogger().isDebugEnabled()) { >- container.getLogger().debug("sessionId: " + sessionId); >- } >+ if (container.getLogger().isDebugEnabled()) { >+ container.getLogger().debug("sessionId: " + sessionId); >+ } > >- // Ask the next valve to process the request. >- getNext().invoke(request, response); >+ // Ask the next valve to process the request. >+ getNext().invoke(request, response); > >- // If still processing async, don't try to store the session >- // TODO: Are there some async states where it would be safe to store >- // the session? >- if (!request.isAsync()) { >- // Read the sessionid after the response. >- // HttpSession hsess = hreq.getSession(false); >- Session hsess; >- try { >- hsess = request.getSessionInternal(false); >- } catch (Exception ex) { >- hsess = null; >- } >- String newsessionId = null; >- if (hsess!=null) { >- newsessionId = hsess.getIdInternal(); >- } >+ // If still processing async, don't try to store the session >+ // TODO: Are there some async states where it would be safe to store >+ // the session? >+ if (!request.isAsync()) { >+ // Read the sessionid after the response. >+ // HttpSession hsess = hreq.getSession(false); >+ Session hsess; >+ try { >+ hsess = request.getSessionInternal(false); >+ } catch (Exception ex) { >+ hsess = null; >+ } >+ String newsessionId = null; >+ if (hsess!=null) { >+ newsessionId = hsess.getIdInternal(); >+ } > >- if (container.getLogger().isDebugEnabled()) { >- container.getLogger().debug("newsessionId: " + newsessionId); >- } >- if (newsessionId!=null) { >- /* 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())) { >- // ((StandardSession)session).passivate(); >- store.save(session); >- ((StoreManager) manager).removeSuper(session); >- session.recycle(); >+ if (container.getLogger().isDebugEnabled()) { >+ container.getLogger().debug("newsessionId: " + newsessionId); >+ } >+ if (newsessionId!=null) { >+ /* 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())) { >+ // ((StandardSession)session).passivate(); >+ 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())); >+ } >+ >+ } > } 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())); >+ container.getLogger().debug("newsessionId Manager: " + >+ manager); > } >- >- } >- } else { >- if (container.getLogger().isDebugEnabled()) { >- container.getLogger().debug("newsessionId Manager: " + >- manager); > } > } > } >+ } finally { >+ Thread.currentThread().setContextClassLoader(oldClassLoader); > } > } >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 57977
:
32769
|
32776