You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by di...@apache.org on 2006/09/19 00:00:47 UTC

svn commit: r447586 - in /webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/deployment: DeploymentEngine.java repository/util/ArchiveReader.java util/Utils.java

Author: dims
Date: Mon Sep 18 15:00:47 2006
New Revision: 447586

URL: http://svn.apache.org/viewvc?view=rev&rev=447586
Log:
ensure that files are closed.


Modified:
    webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/deployment/DeploymentEngine.java
    webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/deployment/repository/util/ArchiveReader.java
    webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/deployment/util/Utils.java

Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/deployment/DeploymentEngine.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/deployment/DeploymentEngine.java?view=diff&rev=447586&r1=447585&r2=447586
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/deployment/DeploymentEngine.java (original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/deployment/DeploymentEngine.java Mon Sep 18 15:00:47 2006
@@ -451,8 +451,9 @@
             File out = new File(webLocation, serviceFileName);
             int BUFFER = 1024;
             byte data[] = new byte[BUFFER];
+            FileInputStream fin = new FileInputStream(in);
             ZipInputStream zin = new ZipInputStream(
-                    new FileInputStream(in));
+                    fin);
             ZipEntry entry;
             while ((entry = zin.getNextEntry()) != null) {
                 ZipEntry zip = new ZipEntry(entry);
@@ -475,6 +476,7 @@
                 }
             }
             zin.close();
+            fin.close();
         } catch (IOException e) {
             log.info(e.getMessage());
         }

Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/deployment/repository/util/ArchiveReader.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/deployment/repository/util/ArchiveReader.java?view=diff&rev=447586&r1=447585&r2=447586
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/deployment/repository/util/ArchiveReader.java (original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/deployment/repository/util/ArchiveReader.java Mon Sep 18 15:00:47 2006
@@ -106,8 +106,10 @@
         // get attribute values
         if (!extractService) {
             ZipInputStream zin = null;
+            FileInputStream fin = null;
             try {
-                zin = new ZipInputStream(new FileInputStream(filename));
+                fin = new FileInputStream(filename);
+                zin = new ZipInputStream(fin);
                 ZipEntry entry;
                 while ((entry = zin.getNextEntry()) != null) {
                     if (entry.getName().equalsIgnoreCase(SERVICES_XML)) {
@@ -128,6 +130,13 @@
                         log.info(Messages.getMessage("errorininputstreamclose"));
                     }
                 }
+                if (fin != null) {
+                    try {
+                        fin.close();
+                    } catch (IOException e) {
+                        log.info(Messages.getMessage("errorininputstreamclose"));
+                    }
+                }
             }
         } else {
             File file = new File(filename, SERVICES_XML);
@@ -259,9 +268,10 @@
             }
         } else {
             ZipInputStream zin;
-
+            FileInputStream fin;
             try {
-                zin = new ZipInputStream(new FileInputStream(serviceFile));
+                fin = new FileInputStream(serviceFile);
+                zin = new ZipInputStream(fin);
 
                 //TODO Check whether this WSDL is empty
 
@@ -315,6 +325,11 @@
                 } catch (IOException e) {
                     log.info(e);
                 }
+                try {
+                    fin.close();
+                } catch (IOException e) {
+                    log.info(e);
+                }
             } catch (FileNotFoundException e) {
                 throw new DeploymentException(e);
             } catch (IOException e) {
@@ -335,8 +350,10 @@
         boolean foundmoduleXML = false;
         if (!explodedDir) {
             ZipInputStream zin;
+            FileInputStream fin;
             try {
-                zin = new ZipInputStream(new FileInputStream(archiveFile.getAbsolutePath()));
+                fin = new FileInputStream(archiveFile.getAbsolutePath());
+                zin = new ZipInputStream(fin);
                 ZipEntry entry;
                 while ((entry = zin.getNextEntry()) != null) {
                     if (entry.getName().equalsIgnoreCase(MODULE_XML)) {
@@ -352,6 +369,7 @@
                     }
                 }
                 zin.close();
+                fin.close();
                 if (!foundmoduleXML) {
                     throw new DeploymentException(
                             Messages.getMessage(
@@ -364,7 +382,7 @@
             File file = new File(archiveFile.getAbsolutePath(), MODULE_XML);
 
             if (file.exists() || (file = new File(archiveFile.getAbsolutePath(), MODULE_XML.toLowerCase())).exists()) {
-                InputStream in;
+                InputStream in = null;
                 try {
                     in = new FileInputStream(file);
                     ModuleBuilder builder = new ModuleBuilder(in, module, axisConfig);
@@ -377,6 +395,14 @@
                 } catch (FileNotFoundException e) {
                     throw new DeploymentException(
                             Messages.getMessage(DeploymentErrorMsgs.FILE_NOT_FOUND, e.getMessage()));
+                } finally {
+                    if (in != null) {
+                        try {
+                            in.close();
+                        } catch (IOException e) {
+                            log.info(Messages.getMessage("errorininputstreamclose"));
+                        }
+                    }
                 }
             } else {
                 throw new DeploymentException(

Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/deployment/util/Utils.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/deployment/util/Utils.java?view=diff&rev=447586&r1=447585&r2=447586
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/deployment/util/Utils.java (original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/deployment/util/Utils.java Mon Sep 18 15:00:47 2006
@@ -94,11 +94,13 @@
             String urlString = url.toString();
             InputStream in = url.openStream();
             ZipInputStream zin;
+            FileInputStream fin = null;
             if (antiJARLocking) {
                 File inputFile = createTempFile(urlString.substring(urlString.length() - 4), in);
                 in.close();
                 array.add(inputFile.toURL());
-                zin = new ZipInputStream(new FileInputStream(inputFile));
+                fin = new FileInputStream(inputFile);
+                zin = new ZipInputStream(fin);
             } else {
                 array.add(url);
                 zin = new ZipInputStream(in);
@@ -119,6 +121,12 @@
                 }
             }
             zin.close();
+            if (!antiJARLocking) {
+                in.close();
+            }
+            if (fin != null) {
+                fin.close();
+            }
             return (URL[]) array.toArray(new URL[array.size()]);
         } catch (Exception e) {
             throw new RuntimeException(e);



---------------------------------------------------------------------
To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-cvs-help@ws.apache.org