You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by re...@apache.org on 2006/09/01 15:54:51 UTC

svn commit: r439322 - in /tomcat/container/tc5.5.x/catalina/src/share/org/apache/catalina: core/StandardContext.java startup/ContextRuleSet.java

Author: remm
Date: Fri Sep  1 06:54:50 2006
New Revision: 439322

URL: http://svn.apache.org/viewvc?rev=439322&view=rev
Log:
- Revert the fix, since the situation described in the bug is not valid (and I'm afraid my boss would murder me 
  if there's a regression).
- Cleanup getParentCL so that it returns consistent results when using privileged="true". This might have been
  causing problems in some cases.
- After looking a bit everywhere, the CreateLoaderRule will use the same parent CL as the one which would be set
  by the CopyParentCL rule, so I don't see how a problem could occur.

Modified:
    tomcat/container/tc5.5.x/catalina/src/share/org/apache/catalina/core/StandardContext.java
    tomcat/container/tc5.5.x/catalina/src/share/org/apache/catalina/startup/ContextRuleSet.java

Modified: tomcat/container/tc5.5.x/catalina/src/share/org/apache/catalina/core/StandardContext.java
URL: http://svn.apache.org/viewvc/tomcat/container/tc5.5.x/catalina/src/share/org/apache/catalina/core/StandardContext.java?rev=439322&r1=439321&r2=439322&view=diff
==============================================================================
--- tomcat/container/tc5.5.x/catalina/src/share/org/apache/catalina/core/StandardContext.java (original)
+++ tomcat/container/tc5.5.x/catalina/src/share/org/apache/catalina/core/StandardContext.java Fri Sep  1 06:54:50 2006
@@ -1423,6 +1423,23 @@
 
 
     /**
+     * Return the parent class loader (if any) for this web application.
+     * This call is meaningful only <strong>after</strong> a Loader has
+     * been configured.
+     */
+    public ClassLoader getParentClassLoader() {
+        if (parentClassLoader != null)
+            return (parentClassLoader);
+        if (getPrivileged()) {
+            return this.getClass().getClassLoader();
+        } else if (parent != null) {
+            return (parent.getParentClassLoader());
+        }
+        return (ClassLoader.getSystemClassLoader());
+    }
+
+
+    /**
      * Return the context path for this Context.
      */
     public String getPath() {
@@ -4035,17 +4052,7 @@
         }
         
         if (getLoader() == null) {
-            ClassLoader parent = null;
-            if (getPrivileged()) {
-                if (log.isDebugEnabled())
-                    log.debug("Configuring privileged default Loader");
-                parent = this.getClass().getClassLoader();
-            } else {
-                if (log.isDebugEnabled())
-                    log.debug("Configuring non-privileged default Loader");
-                parent = getParentClassLoader();
-            }
-            WebappLoader webappLoader = new WebappLoader(parent);
+            WebappLoader webappLoader = new WebappLoader(getParentClassLoader());
             webappLoader.setDelegate(getDelegate());
             setLoader(webappLoader);
         }

Modified: tomcat/container/tc5.5.x/catalina/src/share/org/apache/catalina/startup/ContextRuleSet.java
URL: http://svn.apache.org/viewvc/tomcat/container/tc5.5.x/catalina/src/share/org/apache/catalina/startup/ContextRuleSet.java?rev=439322&r1=439321&r2=439322&view=diff
==============================================================================
--- tomcat/container/tc5.5.x/catalina/src/share/org/apache/catalina/startup/ContextRuleSet.java (original)
+++ tomcat/container/tc5.5.x/catalina/src/share/org/apache/catalina/startup/ContextRuleSet.java Fri Sep  1 06:54:50 2006
@@ -126,8 +126,6 @@
 
         if (create) {
             digester.addRule(prefix + "Context",
-                    new CopyParentClassLoaderRule());
-            digester.addRule(prefix + "Context",
                              new LifecycleListenerRule
                                  ("org.apache.catalina.startup.ContextConfig",
                                   "configClass"));



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


Re: svn commit: r439322 - in /tomcat/container/tc5.5.x/catalina/src/share/org/apache/catalina: core/StandardContext.java startup/ContextRuleSet.java

Posted by Remy Maucherat <re...@apache.org>.
Mark Thomas wrote:
> Remy Maucherat wrote:
>> It's possible it would not cause any regression, I don't know for sure
>> (it's a bit the issue).
>>
>> The original claim was to fix 39704, which cannot be fixed (the bug is
>> really invalid, for the reasons I stated inside the bug, since when
>> creating the loader the privileged flag value will always be "false";
>> other similar bugs may be valid, but this one is not), so I tried to
>> find something a bit safer for the 5.5 branch. I cleaned up the creation
>> of the Loader in TC 6, so that it's no longer mandatory to pass the
>> parent CL when creating the object (and it should fix this mess without
>> all the creative hacks).
> 
> How about porting the changes from TC6 but adding an option to the
> Loader that defaults to the existing behaviour but can be set to use
> the TC6 behaviour? This way we have:
> - no regression risk
> - no API change
> - cleaner code
> 
> Assuming there are no objections, I'll do this later this week.

That could work.

Rémy


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


Re: svn commit: r439322 - in /tomcat/container/tc5.5.x/catalina/src/share/org/apache/catalina: core/StandardContext.java startup/ContextRuleSet.java

Posted by Mark Thomas <ma...@apache.org>.
Remy Maucherat wrote:
> It's possible it would not cause any regression, I don't know for sure
> (it's a bit the issue).
> 
> The original claim was to fix 39704, which cannot be fixed (the bug is
> really invalid, for the reasons I stated inside the bug, since when
> creating the loader the privileged flag value will always be "false";
> other similar bugs may be valid, but this one is not), so I tried to
> find something a bit safer for the 5.5 branch. I cleaned up the creation
> of the Loader in TC 6, so that it's no longer mandatory to pass the
> parent CL when creating the object (and it should fix this mess without
> all the creative hacks).

How about porting the changes from TC6 but adding an option to the
Loader that defaults to the existing behaviour but can be set to use
the TC6 behaviour? This way we have:
- no regression risk
- no API change
- cleaner code

Assuming there are no objections, I'll do this later this week.

Mark

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


Re: svn commit: r439322 - in /tomcat/container/tc5.5.x/catalina/src/share/org/apache/catalina: core/StandardContext.java startup/ContextRuleSet.java

Posted by Remy Maucherat <re...@apache.org>.
Mark Thomas wrote:
> The reverted fix for 39704 was careful to avoid creating a regression
> for http://jira.jboss.com/jira/browse/JBAS-1688. The fix for JBAS-1688
> removed the CopyParentCL rule in all cases. The reverted fix added it
> back only on context creation which means the CopyParentCL rule is not
> used in the code path described by
> http://jira.jboss.com/jira/browse/JBAS-1688
> 
> I can't see how adding back the CopyParentCL rule as per the fix for
> 39704 could cause a regression. Certainly, it won't for JBAS-1688. Can
> you provide a sample scenario where the 39704 would cause problems?

It's possible it would not cause any regression, I don't know for sure 
(it's a bit the issue).

The original claim was to fix 39704, which cannot be fixed (the bug is 
really invalid, for the reasons I stated inside the bug, since when 
creating the loader the privileged flag value will always be "false"; 
other similar bugs may be valid, but this one is not), so I tried to 
find something a bit safer for the 5.5 branch. I cleaned up the creation 
of the Loader in TC 6, so that it's no longer mandatory to pass the 
parent CL when creating the object (and it should fix this mess without 
all the creative hacks).

Rémy

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


Re: svn commit: r439322 - in /tomcat/container/tc5.5.x/catalina/src/share/org/apache/catalina: core/StandardContext.java startup/ContextRuleSet.java

Posted by Mark Thomas <ma...@apache.org>.
remm@apache.org wrote:
> Author: remm
> Date: Fri Sep  1 06:54:50 2006
> New Revision: 439322
> 
> URL: http://svn.apache.org/viewvc?rev=439322&view=rev
> Log:
> - Revert the fix, since the situation described in the bug is not valid (and I'm afraid my boss would murder me 
>   if there's a regression).
The situation described in 39704 and the numerous duplicates is
valid. There are actually two separate issues in the bug, both caused
by the fix to http://jira.jboss.com/jira/browse/JBAS-1688 which is
included in 5.5.10+. Specifically:
1. parent classloader when privilege="true"
2. parent classloader when a custom Loader is used

> - Cleanup getParentCL so that it returns consistent results when using privileged="true". This might have been
>   causing problems in some cases.
This is issue 1 which has been fixed (under bug 36852) in 5.5.13+. The
clean-up appears to make the fix (in ContextRuleSet) redundant but I
haven't tested this thoroughly (so I haven't removed the possibly
redundant code).

> - After looking a bit everywhere, the CreateLoaderRule will use the same parent CL as the one which would be set
>   by the CopyParentCL rule, so I don't see how a problem could occur.
It comes down to timing which is why it is hard to see just by looking
at the code. Stepping through the code with a debugger shows that if a
custom loader is specified in server.xml then at the time the call is
made to getParentClassLoader Context.parent is null so the system
classloader is returned. As far as I can tell this only happens for
custom loaders specified in server.xml.

A simple test, that does not require a custom loader, is to define a
context in server.xml and add an empty <Loader /> tag. If all was
working as it should, this should have the same effect as not
specifying the tag at all. With the current code, this breaks even the
most basic web application.

Some versions of Eclipse WTP appear integrate with Tomcat via custom
loaders defined in server.xml, hence the slew of bug reports.

The reverted fix for 39704 was careful to avoid creating a regression
for http://jira.jboss.com/jira/browse/JBAS-1688. The fix for JBAS-1688
removed the CopyParentCL rule in all cases. The reverted fix added it
back only on context creation which means the CopyParentCL rule is not
used in the code path described by
http://jira.jboss.com/jira/browse/JBAS-1688

I can't see how adding back the CopyParentCL rule as per the fix for
39704 could cause a regression. Certainly, it won't for JBAS-1688. Can
you provide a sample scenario where the 39704 would cause problems?

Mark

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