svn commit: r1044746 - /tomcat/trunk/java/org/apache/catalina/core/StandardContext.java

2010-12-11 Thread slaurent
Author: slaurent
Date: Sun Dec 12 00:10:39 2010
New Revision: 1044746

URL: http://svn.apache.org/viewvc?rev=1044746view=rev
Log:
bug 50459: StandardContext.bindThread() and unbindThread() are not symmetrical 
and not limited to current thread 
https://issues.apache.org/bugzilla/show_bug.cgi?id=50459

This fixes the bug that was introduced by 
http://svn.apache.org/viewvc?rev=1044145view=rev (introduced a dedicated 
thread when starting and stopping web applications to avoid mem leak)

Modified:
tomcat/trunk/java/org/apache/catalina/core/StandardContext.java

Modified: tomcat/trunk/java/org/apache/catalina/core/StandardContext.java
URL: 
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/core/StandardContext.java?rev=1044746r1=1044745r2=1044746view=diff
==
--- tomcat/trunk/java/org/apache/catalina/core/StandardContext.java (original)
+++ tomcat/trunk/java/org/apache/catalina/core/StandardContext.java Sun Dec 12 
00:10:39 2010
@@ -4862,10 +4862,10 @@ public class StandardContext extends Con
 if ((loader != null)  (loader instanceof Lifecycle))
 ((Lifecycle) loader).start();
 
-// Unbinding thread
+// since the loader just started, the webapp classloader is now
+// created by calling unbindThread and bindThread in a row, we
+// setup the current Thread CCL to be the webapp classloader
 unbindThread(oldCCL);
-
-// Binding thread
 oldCCL = bindThread();
 
 // Initialize logger again. Other components might have used 
it too early, 
@@ -5542,7 +5542,7 @@ public class StandardContext extends Con
 (getLoader().getClassLoader());
 }
 
-DirContextURLStreamHandler.bind(getResources());
+DirContextURLStreamHandler.bindThread(getResources());
 
 if (isUseNaming()) {
 try {
@@ -5563,16 +5563,13 @@ public class StandardContext extends Con
  */
 private void unbindThread(ClassLoader oldContextClassLoader) {
 
-Thread.currentThread().setContextClassLoader(oldContextClassLoader);
-
-oldContextClassLoader = null;
-
 if (isUseNaming()) {
 ContextBindings.unbindThread(this, this);
 }
 
-DirContextURLStreamHandler.unbind();
+DirContextURLStreamHandler.unbindThread();
 
+Thread.currentThread().setContextClassLoader(oldContextClassLoader);
 }
 
 



-
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org



Re: svn commit: r1044746 - /tomcat/trunk/java/org/apache/catalina/core/StandardContext.java

2010-12-11 Thread Mark Thomas
On 12/12/2010 00:10, slaur...@apache.org wrote:
 Author: slaurent
 Date: Sun Dec 12 00:10:39 2010
 New Revision: 1044746
 
 @@ -4862,10 +4862,10 @@ public class StandardContext extends Con
  if ((loader != null)  (loader instanceof Lifecycle))
  ((Lifecycle) loader).start();
  
 -// Unbinding thread
 +// since the loader just started, the webapp classloader is 
 now
 +// created by calling unbindThread and bindThread in a row, 
 we
 +// setup the current Thread CCL to be the webapp classloader
  unbindThread(oldCCL);
 -
 -// Binding thread
  oldCCL = bindThread();

That new comment doesn't look right. The class loader is not created by
calling unbindThread and bindThread in a row.

Mark

-
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org



Re: svn commit: r1044746 - /tomcat/trunk/java/org/apache/catalina/core/StandardContext.java

2010-12-11 Thread Sylvain Laurent
oops, I just forgot a dot and a new line... fixed in rev 1044747.

On 12 déc. 2010, at 01:13, Mark Thomas wrote:

 On 12/12/2010 00:10, slaur...@apache.org wrote:
 Author: slaurent
 Date: Sun Dec 12 00:10:39 2010
 New Revision: 1044746
 
 @@ -4862,10 +4862,10 @@ public class StandardContext extends Con
 if ((loader != null)  (loader instanceof Lifecycle))
 ((Lifecycle) loader).start();
 
 -// Unbinding thread
 +// since the loader just started, the webapp classloader is 
 now
 +// created by calling unbindThread and bindThread in a row, 
 we
 +// setup the current Thread CCL to be the webapp classloader
 unbindThread(oldCCL);
 -
 -// Binding thread
 oldCCL = bindThread();
 
 That new comment doesn't look right. The class loader is not created by
 calling unbindThread and bindThread in a row.
 
 Mark
 
 -
 To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
 For additional commands, e-mail: dev-h...@tomcat.apache.org
 


-
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org