ASF Bugzilla – Attachment 17909 Details for
Bug 38795
[PATCH] StandardContext doesn't always reset thread's contextClassLoader
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Defensive coding patch for all bind/unbind usage NEEDS PEER REVIEW
StandardContext.java.diff (text/plain), 6.08 KB, created by
Darryl Miles
on 2006-03-16 04:38:41 UTC
(
hide
)
Description:
Defensive coding patch for all bind/unbind usage NEEDS PEER REVIEW
Filename:
MIME Type:
Creator:
Darryl Miles
Created:
2006-03-16 04:38:41 UTC
Size:
6.08 KB
patch
obsolete
>diff -u -r -N -x '*~' /bigdata/distrosrc/apache-tomcat-5.5.16-src/container/catalina/src/share/org/apache/catalina/core/StandardContext.java /bigdata/distrosrc/apache-tomcat-5.5.16-src-dlm/container/catalina/src/share/org/apache/catalina/core/StandardContext.java >--- apache-tomcat-5.5.16-src/container/catalina/src/share/org/apache/catalina/core/StandardContext.java 2006-03-05 01:25:30.000000000 +0000 >+++ apache-tomcat-5.5.16-src-dlm/container/catalina/src/share/org/apache/catalina/core/StandardContext.java 2006-03-16 04:17:27.000000000 +0000 >@@ -4059,26 +4068,30 @@ > } > } > >- // Binding thread >- ClassLoader oldCCL = bindThread(); >- >- // Standard container startup >- if (log.isDebugEnabled()) >- log.debug("Processing standard container startup"); >- > if (ok) { >- > boolean mainOk = false; >+ >+ // Binding thread >+ ClassLoader oldCCL = bindThread(); > try { > >+ // Standard container startup >+ if (log.isDebugEnabled()) >+ log.debug("Processing standard container startup"); >+ >+ > started = true; > > // Start our subordinate components, if any > if ((loader != null) && (loader instanceof Lifecycle)) > ((Lifecycle) loader).start(); > >- // Unbinding thread >- unbindThread(oldCCL); >+ try { >+ // Unbinding thread >+ unbindThread(oldCCL); >+ } catch(Throwable t) { >+ oldCCL = null; >+ } > > // Binding thread > oldCCL = bindThread(); >@@ -4142,15 +4155,16 @@ > mainOk = true; > > } finally { >- // Unbinding thread >- unbindThread(oldCCL); >+ if(oldCCL != null) { >+ // Unbinding thread >+ unbindThread(oldCCL); >+ } > if (!mainOk) { > // An exception occurred > // Register with JMX anyway, to allow management > registerJMX(); > } > } >- > } > if (!getConfigured()) { > log.error( "Error getConfigured"); >@@ -4166,40 +4184,42 @@ > mapper.setContext(getPath(), welcomeFiles, resources); > > // Binding thread >- oldCCL = bindThread(); >+ ClassLoader oldCCL = bindThread(); > >- // Create context attributes that will be required >- if (ok) { >- postWelcomeFiles(); >- } >+ try { >+ // Create context attributes that will be required >+ if (ok) { >+ postWelcomeFiles(); >+ } > >- if (ok) { >- // Notify our interested LifecycleListeners >- lifecycle.fireLifecycleEvent(AFTER_START_EVENT, null); >- } >+ if (ok) { >+ // Notify our interested LifecycleListeners >+ lifecycle.fireLifecycleEvent(AFTER_START_EVENT, null); >+ } > >- // Configure and call application event listeners and filters >- if (ok) { >- if (!listenerStart()) { >- log.error( "Error listenerStart"); >- ok = false; >+ // Configure and call application event listeners and filters >+ if (ok) { >+ if (!listenerStart()) { >+ log.error( "Error listenerStart"); >+ ok = false; >+ } > } >- } >- if (ok) { >- if (!filterStart()) { >- log.error( "Error filterStart"); >- ok = false; >+ if (ok) { >+ if (!filterStart()) { >+ log.error( "Error filterStart"); >+ ok = false; >+ } > } >- } > >- // Load and initialize all "load on startup" servlets >- if (ok) { >- loadOnStartup(findChildren()); >+ // Load and initialize all "load on startup" servlets >+ if (ok) { >+ loadOnStartup(findChildren()); >+ } >+ } finally { >+ // Unbinding thread >+ unbindThread(oldCCL); > } > >- // Unbinding thread >- unbindThread(oldCCL); >- > // Set available status depending upon startup success > if (ok) { > if (log.isDebugEnabled()) >@@ -4324,30 +4344,29 @@ > // Binding thread > ClassLoader oldCCL = bindThread(); > >- // Stop our filters >- filterStop(); >- >- // Stop our application listeners >- listenerStop(); >+ try { >+ // Stop our filters >+ filterStop(); > >- // Stop ContainerBackgroundProcessor thread >- super.threadStop(); >+ // Stop our application listeners >+ listenerStop(); > >- if ((manager != null) && (manager instanceof Lifecycle)) { >- ((Lifecycle) manager).stop(); >- } >+ // Stop ContainerBackgroundProcessor thread >+ super.threadStop(); > >- // Finalize our character set mapper >- setCharsetMapper(null); >+ if ((manager != null) && (manager instanceof Lifecycle)) { >+ ((Lifecycle) manager).stop(); >+ } > >- // Normal container shutdown processing >- if (log.isDebugEnabled()) >- log.debug("Processing standard container shutdown"); >- // Notify our interested LifecycleListeners >- lifecycle.fireLifecycleEvent(STOP_EVENT, null); >- started = false; >+ // Finalize our character set mapper >+ setCharsetMapper(null); > >- try { >+ // Normal container shutdown processing >+ if (log.isDebugEnabled()) >+ log.debug("Processing standard container shutdown"); >+ // Notify our interested LifecycleListeners >+ lifecycle.fireLifecycleEvent(STOP_EVENT, null); >+ started = false; > > // Stop the Valves in our pipeline (including the basic), if any > if (pipeline instanceof Lifecycle) {
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 38795
: 17909 |
17923
|
17924