You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by cr...@locus.apache.org on 2000/12/22 01:37:53 UTC

cvs commit: jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/startup ContextConfig.java HostConfig.java

craigmcc    00/12/21 16:37:52

  Modified:    catalina/src/share/org/apache/catalina/loader
                        StandardLoader.java
               catalina/src/share/org/apache/catalina/startup
                        ContextConfig.java HostConfig.java
  Log:
  Second (and last) round of changes from File.getAbsolutePath() to
  File.getCanonicalPath().  With these changes, the following assertions can
  be made:
  
  * The URLClassLoader for a web application will never be handed a "file:"
    URL that is not normalized.
  
  * The document root directory for a web application will always be
    normalized.
  
  * The URL returned by ServletContext.getResource() will always be
    normalized.
  
  This should clean up the cases where URLClassLoader on some platforms does
  not deal nicely with unnormalized repositories, and causes classes (or
  resources) to mysteriously not load, or not load from the correct place.
  
  Submitted by:	Stuart Roebuck <st...@adolos.com>
  
  Revision  Changes    Path
  1.13      +12 -9     jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/loader/StandardLoader.java
  
  Index: StandardLoader.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/loader/StandardLoader.java,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- StandardLoader.java	2000/12/14 22:32:16	1.12
  +++ StandardLoader.java	2000/12/22 00:37:50	1.13
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/loader/StandardLoader.java,v 1.12 2000/12/14 22:32:16 craigmcc Exp $
  - * $Revision: 1.12 $
  - * $Date: 2000/12/14 22:32:16 $
  + * $Header: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/loader/StandardLoader.java,v 1.13 2000/12/22 00:37:50 craigmcc Exp $
  + * $Revision: 1.13 $
  + * $Date: 2000/12/22 00:37:50 $
    *
    * ====================================================================
    *
  @@ -101,7 +101,7 @@
    * is not present, the system class loader will be used instead.
    *
    * @author Craig R. McClanahan
  - * @version $Revision: 1.12 $ $Date: 2000/12/14 22:32:16 $
  + * @version $Revision: 1.13 $ $Date: 2000/12/22 00:37:50 $
    */
   
   public final class StandardLoader
  @@ -191,7 +191,6 @@
        * <code>Reloader</code> interface.
        */
       private String loaderClass =
  -        //	"org.apache.catalina.loader.FileClassLoader";
   	"org.apache.catalina.loader.StandardClassLoader";
   
   
  @@ -875,10 +874,14 @@
   		    if (!filenames[i].endsWith(".jar"))
   		        continue;
   		    File jarFile = new File(libFile, filenames[i]);
  -		    if (debug > 0)
  -		        log(" Adding '" + "file: " +
  -                            jarFile.getAbsolutePath() + "'");
  -                    addRepository("file:" + jarFile.getAbsolutePath());
  +                    try {
  +                        if (debug > 0)
  +                            log(" Adding '" + "file: " +
  +                                jarFile.getCanonicalPath() + "'");
  +                        addRepository("file:" + jarFile.getCanonicalPath());
  +                    } catch (IOException e) {
  +                        log(jarFile.getAbsolutePath(), e);
  +                    }
   		}
   	    }
   	}
  
  
  
  1.35      +18 -10    jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/startup/ContextConfig.java
  
  Index: ContextConfig.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/startup/ContextConfig.java,v
  retrieving revision 1.34
  retrieving revision 1.35
  diff -u -r1.34 -r1.35
  --- ContextConfig.java	2000/12/01 19:25:31	1.34
  +++ ContextConfig.java	2000/12/22 00:37:52	1.35
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/startup/ContextConfig.java,v 1.34 2000/12/01 19:25:31 craigmcc Exp $
  - * $Revision: 1.34 $
  - * $Date: 2000/12/01 19:25:31 $
  + * $Header: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/startup/ContextConfig.java,v 1.35 2000/12/22 00:37:52 craigmcc Exp $
  + * $Revision: 1.35 $
  + * $Date: 2000/12/22 00:37:52 $
    *
    * ====================================================================
    *
  @@ -118,7 +118,7 @@
    * of that Context, and the associated defined servlets.
    *
    * @author Craig R. McClanahan
  - * @version $Revision: 1.34 $ $Date: 2000/12/01 19:25:31 $
  + * @version $Revision: 1.35 $ $Date: 2000/12/22 00:37:52 $
    */
   
   public final class ContextConfig
  @@ -678,10 +678,13 @@
   			    File.separator + Constants.DefaultWebXml);
   	FileInputStream stream = null;
   	try {
  -	    stream = new FileInputStream(file.getAbsolutePath());
  +	    stream = new FileInputStream(file.getCanonicalPath());
   	} catch (FileNotFoundException e) {
  -	    log(sm.getString("context.Config.defaultMissing"));
  +	    log(sm.getString("contextConfig.defaultMissing"));
   	    return;
  +        } catch (IOException e) {
  +            log(sm.getString("contextConfig.defaultMissing"), e);
  +            return;
   	}
   
   	// Process the default web.xml file
  @@ -796,8 +799,13 @@
           commonPerms.add(new FilePermission(baseFile, "read"));
           File workDir = (File)
               context.getServletContext().getAttribute(Globals.WORK_DIR_ATTR);
  -        commonPerms.add(new FilePermission(workDir.getAbsolutePath() + "/-",
  -                                           "read,write,delete"));
  +        try {
  +            commonPerms.add(new FilePermission(workDir.getCanonicalPath() +
  +                                               "/-",
  +                                               "read,write,delete"));
  +        } catch (IOException e) {
  +            log("permissionsConfig.filePerm", e);
  +        }
           if (debug >= 1)
               log(" commonPerms=" + commonPerms.toString());
   
  @@ -838,10 +846,10 @@
               log("Building work directory code source");
           URL workURL = null;
           try {
  -            workURL = new URL("file", null, workDir.getAbsolutePath());
  +            workURL = new URL("file", null, workDir.getCanonicalPath());
               if (debug >= 1)
                   log(" workURL=" + workURL.toString());
  -        } catch (MalformedURLException e) {
  +        } catch (IOException e) {
               log("permissionsConfig.workURL", e);
           }
           CodeSource workSource = new CodeSource(workURL, null);
  
  
  
  1.4       +6 -6      jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/startup/HostConfig.java
  
  Index: HostConfig.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/startup/HostConfig.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- HostConfig.java	2000/11/02 01:00:16	1.3
  +++ HostConfig.java	2000/12/22 00:37:52	1.4
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/startup/HostConfig.java,v 1.3 2000/11/02 01:00:16 craigmcc Exp $
  - * $Revision: 1.3 $
  - * $Date: 2000/11/02 01:00:16 $
  + * $Header: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/startup/HostConfig.java,v 1.4 2000/12/22 00:37:52 craigmcc Exp $
  + * $Revision: 1.4 $
  + * $Date: 2000/12/22 00:37:52 $
    *
    * ====================================================================
    *
  @@ -93,7 +93,7 @@
    * of that Host, and the associated defined contexts.
    *
    * @author Craig R. McClanahan
  - * @version $Revision: 1.3 $ $Date: 2000/11/02 01:00:16 $
  + * @version $Revision: 1.4 $ $Date: 2000/12/22 00:37:52 $
    */
   
   public final class HostConfig
  @@ -290,7 +290,7 @@
                   if (debug >= 1)
                       log(sm.getString("hostConfig.deployDir", files[i]));
                   try {
  -                    URL url = new URL("file", null, dir.getAbsolutePath());
  +                    URL url = new URL("file", null, dir.getCanonicalPath());
                       ((Deployer) host).deploy(contextPath, url);
                   } catch (Throwable t) {
                       log(sm.getString("hostConfig.deployDir.error", files[i]),
  @@ -313,7 +313,7 @@
                   if (debug >= 1)
                       log(sm.getString("hostConfig.deployJar", files[i]));
                   try {
  -                    URL url = new URL("file", null, dir.getAbsolutePath());
  +                    URL url = new URL("file", null, dir.getCanonicalPath());
                       url = new URL("jar:" + url.toString() + "!/");
                       ((Deployer) host).deploy(contextPath, url);
                   } catch (Throwable t) {