tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From r...@apache.org
Subject cvs commit: jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/loader WebappClassLoader.java
Date Thu, 15 Nov 2001 02:20:33 GMT
remm        01/11/14 18:20:32

  Modified:    catalina/src/share/org/apache/catalina/loader
                        WebappClassLoader.java
  Log:
  - Fix 4830.
  
  Revision  Changes    Path
  1.28      +56 -47    jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/loader/WebappClassLoader.java
  
  Index: WebappClassLoader.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/loader/WebappClassLoader.java,v
  retrieving revision 1.27
  retrieving revision 1.28
  diff -u -r1.27 -r1.28
  --- WebappClassLoader.java	2001/11/14 00:10:44	1.27
  +++ WebappClassLoader.java	2001/11/15 02:20:32	1.28
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/loader/WebappClassLoader.java,v
1.27 2001/11/14 00:10:44 remm Exp $
  - * $Revision: 1.27 $
  - * $Date: 2001/11/14 00:10:44 $
  + * $Header: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/loader/WebappClassLoader.java,v
1.28 2001/11/15 02:20:32 remm Exp $
  + * $Revision: 1.28 $
  + * $Date: 2001/11/15 02:20:32 $
    *
    * ====================================================================
    *
  @@ -122,7 +122,7 @@
    *
    * @author Remy Maucherat
    * @author Craig R. McClanahan
  - * @version $Revision: 1.27 $ $Date: 2001/11/14 00:10:44 $
  + * @version $Revision: 1.28 $ $Date: 2001/11/15 02:20:32 $
    */
   public class WebappClassLoader
       extends URLClassLoader
  @@ -1546,7 +1546,7 @@
               entry = findResourceInternal(name, classPath);
           }
   
  -        if (entry == null)
  +        if ((entry == null) || (entry.binaryContent == null))
               throw new ClassNotFoundException(name);
   
           Class clazz = entry.loadedClass;
  @@ -1653,10 +1653,9 @@
                   String fullPath = repositories[i] + path;
   
                   Object lookupResult = resources.lookup(fullPath);
  -                if (!(lookupResult instanceof Resource))
  -                    continue;
  -
  -                resource = (Resource) lookupResult;
  +                if (lookupResult instanceof Resource) {
  +                    resource = (Resource) lookupResult;
  +                }
   
                   // Note : Not getting an exception here means the resource was
                   // found
  @@ -1671,30 +1670,36 @@
                       (ResourceAttributes) resources.getAttributes(fullPath);
                   contentLength = (int) attributes.getContentLength();
                   entry.lastModified = attributes.getLastModified();
  -                try {
  -                    binaryStream = resource.streamContent();
  -                } catch (IOException e) {
  -                    return null;
  -                }
   
  -                // Register the full path for modification checking
  -                synchronized (paths) {
  +                if (resource != null) {
   
  -                    int j;
  -
  -                    long[] result2 = new long[lastModifiedDates.length + 1];
  -                    for (j = 0; j < lastModifiedDates.length; j++) {
  -                        result2[j] = lastModifiedDates[j];
  +                    try {
  +                        binaryStream = resource.streamContent();
  +                    } catch (IOException e) {
  +                        return null;
                       }
  -                    result2[lastModifiedDates.length] = entry.lastModified;
  -                    lastModifiedDates = result2;
  +
  +                    // Register the full path for modification checking
  +                    synchronized (paths) {
  +
  +                        int j;
  +
  +                        long[] result2 = 
  +                            new long[lastModifiedDates.length + 1];
  +                        for (j = 0; j < lastModifiedDates.length; j++) {
  +                            result2[j] = lastModifiedDates[j];
  +                        }
  +                        result2[lastModifiedDates.length] = entry.lastModified;
  +                        lastModifiedDates = result2;
  +
  +                        String[] result = new String[paths.length + 1];
  +                        for (j = 0; j < paths.length; j++) {
  +                            result[j] = paths[j];
  +                        }
  +                        result[paths.length] = fullPath;
  +                        paths = result;
   
  -                    String[] result = new String[paths.length + 1];
  -                    for (j = 0; j < paths.length; j++) {
  -                        result[j] = paths[j];
                       }
  -                    result[paths.length] = fullPath;
  -                    paths = result;
   
                   }
   
  @@ -1741,27 +1746,31 @@
               return null;
           }
   
  -        byte[] binaryContent = new byte[contentLength];
  +        if (binaryStream != null) {
   
  -        try {
  -            int pos = 0;
  -            while (true) {
  -                int n = binaryStream.read(binaryContent, pos,
  -                                          binaryContent.length - pos);
  -                if (n <= 0)
  -                    break;
  -                pos += n;
  -            }
  -            binaryStream.close();
  -        } catch (IOException e) {
  -            e.printStackTrace();
  -            return null;
  -        } catch (Exception e) {
  -            e.printStackTrace();
  -            return null;
  -        }
  +            byte[] binaryContent = new byte[contentLength];
  +
  +            try {
  +                int pos = 0;
  +                while (true) {
  +                    int n = binaryStream.read(binaryContent, pos,
  +                                              binaryContent.length - pos);
  +                    if (n <= 0)
  +                        break;
  +                    pos += n;
  +                }
  +                binaryStream.close();
  +            } catch (IOException e) {
  +                e.printStackTrace();
  +                return null;
  +            } catch (Exception e) {
  +                e.printStackTrace();
  +                return null;
  +            }
  +
  +            entry.binaryContent = binaryContent;
   
  -        entry.binaryContent = binaryContent;
  +        }
   
           // Add the entry in the local resource repository
           synchronized (this) {
  
  
  

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


Mime
View raw message