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: [EMAIL PROTECTED]
        ReportedBy: [EMAIL PROTECTED]


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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to