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-catalina/catalina/src/share/org/apache/catalina/startup ExpandWar.java HostConfig.java
Date Sat, 26 Jul 2003 14:24:53 GMT
remm        2003/07/26 07:24:52

  Modified:    catalina/src/share/org/apache/catalina/startup
                        ExpandWar.java HostConfig.java
  Log:
  - Fix possible file descriptor leak.
  - Remove duplicated code.
  
  Revision  Changes    Path
  1.4       +23 -13    jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/startup/ExpandWar.java
  
  Index: ExpandWar.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/startup/ExpandWar.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- ExpandWar.java	21 Jun 2003 23:25:27 -0000	1.3
  +++ ExpandWar.java	26 Jul 2003 14:24:52 -0000	1.4
  @@ -302,16 +302,26 @@
           throws IOException {
   
           File file = new File(docBase, name);
  -        BufferedOutputStream output =
  -            new BufferedOutputStream(new FileOutputStream(file));
  -        byte buffer[] = new byte[2048];
  -        while (true) {
  -            int n = input.read(buffer);
  -            if (n <= 0)
  -                break;
  -            output.write(buffer, 0, n);
  +        BufferedOutputStream output = null;
  +        try {
  +            output = 
  +                new BufferedOutputStream(new FileOutputStream(file));
  +            byte buffer[] = new byte[2048];
  +            while (true) {
  +                int n = input.read(buffer);
  +                if (n <= 0)
  +                    break;
  +                output.write(buffer, 0, n);
  +            }
  +        } finally {
  +            if (output != null) {
  +                try {
  +                    output.close();
  +                } catch (IOException e) {
  +                    // Ignore
  +                }
  +            }
           }
  -        output.close();
   
       }
   
  
  
  
  1.20      +5 -30     jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/startup/HostConfig.java
  
  Index: HostConfig.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/startup/HostConfig.java,v
  retrieving revision 1.19
  retrieving revision 1.20
  diff -u -r1.19 -r1.20
  --- HostConfig.java	25 Jul 2003 16:43:12 -0000	1.19
  +++ HostConfig.java	26 Jul 2003 14:24:52 -0000	1.20
  @@ -787,7 +787,7 @@
                                   if (host.findChild(contextPath) != null) {
                                       ((Deployer) host).remove(contextPath, 
                                                                false);
  -                                    deleteDir(expanded);
  +                                    ExpandWar.deleteDir(expanded);
                                   }
                               } catch (Throwable t) {
                                   log.error(sm.getString
  @@ -841,31 +841,6 @@
           }
           
           return result;
  -    }
  -
  -
  -    /**
  -     * Delete the specified directory, including all of its contents and
  -     * subdirectories recursively.
  -     *
  -     * @param dir File object representing the directory to be deleted
  -     */
  -    protected void deleteDir(File dir) {
  -
  -        String files[] = dir.list();
  -        if (files == null) {
  -            files = new String[0];
  -        }
  -        for (int i = 0; i < files.length; i++) {
  -            File file = new File(dir, files[i]);
  -            if (file.isDirectory()) {
  -                deleteDir(file);
  -            } else {
  -                file.delete();
  -            }
  -        }
  -        dir.delete();
  -
       }
   
   
  
  
  

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


Mime
View raw message