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/naming/resources DirContextURLConnection.java
Date Fri, 27 Apr 2001 19:21:05 GMT
remm        01/04/27 12:21:05

  Modified:    catalina/src/share/org/apache/naming/resources
                        DirContextURLConnection.java
  Log:
  - Some NPE could happen when calling getLastModified() or getHeaderField().
  
  Revision  Changes    Path
  1.8       +15 -4     jakarta-tomcat-4.0/catalina/src/share/org/apache/naming/resources/DirContextURLConnection.java
  
  Index: DirContextURLConnection.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/naming/resources/DirContextURLConnection.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- DirContextURLConnection.java	2001/04/25 04:15:38	1.7
  +++ DirContextURLConnection.java	2001/04/27 19:21:04	1.8
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/naming/resources/DirContextURLConnection.java,v
1.7 2001/04/25 04:15:38 glenn Exp $
  - * $Revision: 1.7 $
  - * $Date: 2001/04/25 04:15:38 $
  + * $Header: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/naming/resources/DirContextURLConnection.java,v
1.8 2001/04/27 19:21:04 remm Exp $
  + * $Revision: 1.8 $
  + * $Date: 2001/04/27 19:21:04 $
    *
    * ====================================================================
    *
  @@ -91,7 +91,7 @@
    * content is directly returned.
    * 
    * @author <a href="mailto:remm@apache.org">Remy Maucherat</a>
  - * @version $Revision: 1.7 $
  + * @version $Revision: 1.8 $
    */
   public class DirContextURLConnection 
       extends URLConnection {
  @@ -236,6 +236,7 @@
        * Return the last modified date.
        */
       public long getLastModified() {
  +
           if (!connected) {
               // Try to connect (silently)
               try {
  @@ -243,6 +244,10 @@
               } catch (IOException e) {
               }
           }
  +
  +        if (attributes == null)
  +            return 0;
  +
           Attribute lastModified = 
               attributes.get(ResourceAttributes.LAST_MODIFIED);
           if (lastModified != null) {
  @@ -252,6 +257,7 @@
               } catch (Exception e) {
               }
           }
  +
           return 0;
       }
       
  @@ -260,6 +266,7 @@
        * Returns the name of the specified header field.
        */
       public String getHeaderField(String name) {
  +
           if (!connected) {
               // Try to connect (silently)
               try {
  @@ -268,12 +275,16 @@
               }
           }
           
  +        if (attributes == null)
  +            return (null);
  +
           Attribute attribute = attributes.get(name);
           try {
               return attribute.get().toString();
           } catch (Exception e) {
               // Shouldn't happen, unless the attribute has no value
           }
  +
           return (null);
           
       }
  
  
  

Mime
View raw message