You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by bu...@apache.org on 2004/10/26 21:30:42 UTC

DO NOT REPLY [Bug 31903] New: - WebappClassLoader fails to load class form local repository

DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=31903>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=31903

WebappClassLoader fails to load class form local repository 

           Summary: WebappClassLoader fails to load class form local
                    repository
           Product: Tomcat 5
           Version: 5.0.28
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: Normal
          Priority: Other
         Component: Catalina
        AssignedTo: tomcat-dev@jakarta.apache.org
        ReportedBy: jzhou@workforcesoftware.com


WebappClassLoader may fail to load class from local repository when multiple
threads are trying to load same class concurrently. 

Need to change method findClassInternal (line 1577 ),  

        if ((entry == null) || (entry.binaryContent == null))
            throw new ClassNotFoundException(name);

to 

        if ((entry == null) || (entry.binaryContent == null &&
entry.loadedClass==null))
            throw new ClassNotFoundException(name);

since after one thread calls defineClass() on the entry, the entry's
binaryContent is set to null, but in this case, the class is already loaded, so
the code should not throw ClassNotFoundException. 

Also in method findClassInternal, following code still use double checked
locking, which is proven broken -  

        if (entry.loadedClass == null) {
            synchronized (this) {
                if (entry.loadedClass == null) {
                    clazz = defineClass(name, entry.binaryContent, 0,
                                        entry.binaryContent.length,
                                        codeSource);
                    entry.loadedClass = clazz;
                    entry.binaryContent = null;
                    entry.source = null;
                    entry.codeBase = null;
                    entry.manifest = null;
                    entry.certificates = null;
                } else {
                    clazz = entry.loadedClass;
                }
            }
        } else {
            clazz = entry.loadedClass;
        }

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