cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cohei...@apache.org
Subject svn commit: r1411133 - in /cxf/trunk: api/src/main/java/org/apache/cxf/ api/src/main/java/org/apache/cxf/configuration/jsse/ api/src/main/java/org/apache/cxf/io/ maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/wsdl2java/ maven-pl...
Date Mon, 19 Nov 2012 11:38:44 GMT
Author: coheigea
Date: Mon Nov 19 11:38:42 2012
New Revision: 1411133

URL: http://svn.apache.org/viewvc?rev=1411133&view=rev
Log:
Final cleanup commit

Modified:
    cxf/trunk/api/src/main/java/org/apache/cxf/BusFactory.java
    cxf/trunk/api/src/main/java/org/apache/cxf/configuration/jsse/SSLUtils.java
    cxf/trunk/api/src/main/java/org/apache/cxf/io/CachedOutputStream.java
    cxf/trunk/api/src/main/java/org/apache/cxf/io/CachedWriter.java
    cxf/trunk/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/wsdl2java/WSDL2JavaMojo.java
    cxf/trunk/maven-plugins/wsdl-validator-plugin/src/main/java/org/apache/cxf/maven_plugin/WSDLValidatorMojo.java
    cxf/trunk/rt/bindings/corba/src/main/java/org/apache/cxf/binding/corba/utils/CorbaUtils.java
    cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/endpoint/dynamic/DynamicClientFactory.java
    cxf/trunk/rt/frontend/js/src/main/java/org/apache/cxf/js/rhino/ProviderFactory.java
    cxf/trunk/rt/management/src/main/java/org/apache/cxf/management/persistence/FilesystemExchangeDataDAO.java
    cxf/trunk/testutils/src/main/java/org/apache/cxf/testutil/common/ServerLauncher.java
    cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/common/ClassUtils.java
    cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/common/ProcessorTestBase.java
    cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/util/JAXBUtils.java
    cxf/trunk/tools/corba/src/main/java/org/apache/cxf/tools/corba/common/SchemaFactory.java
    cxf/trunk/tools/corba/src/main/java/org/apache/cxf/tools/corba/common/WSDLCorbaFactory.java
    cxf/trunk/tools/corba/src/main/java/org/apache/cxf/tools/corba/processors/idl/IDLToWSDLProcessor.java
    cxf/trunk/tools/corba/src/main/java/org/apache/cxf/tools/corba/processors/wsdl/WSDLToCorbaBinding.java
    cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2js/processor/JavaToJSProcessor.java
    cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/generator/wsdl11/WSDL11Generator.java
    cxf/trunk/tools/wadlto/jaxrs/src/main/java/org/apache/cxf/tools/wadlto/jaxrs/SourceGenerator.java
    cxf/trunk/tools/wsdlto/frontend/javascript/src/main/java/org/apache/cxf/tools/wsdlto/javascript/WSDLToJavaScriptProcessor.java

Modified: cxf/trunk/api/src/main/java/org/apache/cxf/BusFactory.java
URL: http://svn.apache.org/viewvc/cxf/trunk/api/src/main/java/org/apache/cxf/BusFactory.java?rev=1411133&r1=1411132&r2=1411133&view=diff
==============================================================================
--- cxf/trunk/api/src/main/java/org/apache/cxf/BusFactory.java (original)
+++ cxf/trunk/api/src/main/java/org/apache/cxf/BusFactory.java Mon Nov 19 11:38:42 2012
@@ -351,10 +351,16 @@ public abstract class BusFactory {
             }
 
             if (is != null) {
-                BufferedReader rd = new BufferedReader(new InputStreamReader(is, "UTF-8"));
-                busFactoryClass = rd.readLine();
-                busFactoryCondition = rd.readLine();
-                rd.close();
+                BufferedReader rd = null;
+                try {
+                    rd = new BufferedReader(new InputStreamReader(is, "UTF-8"));
+                    busFactoryClass = rd.readLine();
+                    busFactoryCondition = rd.readLine();
+                } finally {
+                    if (rd != null) {
+                        rd.close();
+                    }
+                }
             }
             if (isValidBusFactoryClass(busFactoryClass) 
                 && busFactoryCondition != null) {

Modified: cxf/trunk/api/src/main/java/org/apache/cxf/configuration/jsse/SSLUtils.java
URL: http://svn.apache.org/viewvc/cxf/trunk/api/src/main/java/org/apache/cxf/configuration/jsse/SSLUtils.java?rev=1411133&r1=1411132&r2=1411133&view=diff
==============================================================================
--- cxf/trunk/api/src/main/java/org/apache/cxf/configuration/jsse/SSLUtils.java (original)
+++ cxf/trunk/api/src/main/java/org/apache/cxf/configuration/jsse/SSLUtils.java Mon Nov 19 11:38:42 2012
@@ -101,11 +101,18 @@ public final class SSLUtils {
         KeyStore ks = KeyStore.getInstance(keyStoreType);
         
         if (keyStoreType.equalsIgnoreCase(PKCS12_TYPE)) {
-            FileInputStream fis = new FileInputStream(keyStoreLocation);
-            DataInputStream dis = new DataInputStream(fis);
-            byte[] bytes = new byte[dis.available()];
-            dis.readFully(bytes);
-            dis.close();
+            DataInputStream dis = null;
+            byte[] bytes = null;
+            try {
+                FileInputStream fis = new FileInputStream(keyStoreLocation);
+                dis = new DataInputStream(fis);
+                bytes = new byte[dis.available()];
+                dis.readFully(bytes);
+            } finally {
+                if (dis != null) {
+                    dis.close();
+                }
+            }
             ByteArrayInputStream bin = new ByteArrayInputStream(bytes);
             
             if (keyStorePassword != null) {
@@ -212,33 +219,45 @@ public final class SSLUtils {
         if (fileName == null) {
             return null;
         }
-        FileInputStream in = new FileInputStream(fileName);
-        ByteArrayOutputStream out = new ByteArrayOutputStream();
-        byte[] buf = new byte[512];
-        int i = in.read(buf);
-        while (i  > 0) {
-            out.write(buf, 0, i);
-            i = in.read(buf);
+        FileInputStream in = null;
+        try {
+            in = new FileInputStream(fileName);
+            ByteArrayOutputStream out = new ByteArrayOutputStream();
+            byte[] buf = new byte[512];
+            int i = in.read(buf);
+            while (i  > 0) {
+                out.write(buf, 0, i);
+                i = in.read(buf);
+            }
+            return out.toByteArray();
+        } finally {
+            if (in != null) {
+                in.close();
+            }
         }
-        in.close();
-        return out.toByteArray();
     }
 
     protected static byte[] loadCACert(String fileName) throws IOException {
         if (fileName == null) {
             return null;
         }
-        FileInputStream in = new FileInputStream(fileName);
-        ByteArrayOutputStream out = new ByteArrayOutputStream();
-        byte[] buf = new byte[512];
-        int i = in.read(buf);
+        FileInputStream in = null;
+        try {
+            in = new FileInputStream(fileName);
+            ByteArrayOutputStream out = new ByteArrayOutputStream();
+            byte[] buf = new byte[512];
+            int i = in.read(buf);
         
-        while (i > 0) {
-            out.write(buf, 0, i);
-            i = in.read(buf);
+            while (i > 0) {
+                out.write(buf, 0, i);
+                i = in.read(buf);
+            }
+            return out.toByteArray();
+        } finally {
+            if (in != null) {
+                in.close();
+            }
         }
-        in.close();
-        return out.toByteArray();
     }
 
     public static String getKeystore(String keyStoreLocation, Logger log) {

Modified: cxf/trunk/api/src/main/java/org/apache/cxf/io/CachedOutputStream.java
URL: http://svn.apache.org/viewvc/cxf/trunk/api/src/main/java/org/apache/cxf/io/CachedOutputStream.java?rev=1411133&r1=1411132&r2=1411133&view=diff
==============================================================================
--- cxf/trunk/api/src/main/java/org/apache/cxf/io/CachedOutputStream.java (original)
+++ cxf/trunk/api/src/main/java/org/apache/cxf/io/CachedOutputStream.java Mon Nov 19 11:38:42 2012
@@ -324,25 +324,34 @@ public class CachedOutputStream extends 
             }
         } else {
             // read the file
-            InputStream fin = createInputStream(tempFile);
-            Reader reader = new InputStreamReader(fin, charsetName);
-            char bytes[] = new char[1024];
-            long x = reader.read(bytes);
-            while (x != -1) {
-                if ((count + x) > limit) {
-                    x = limit - count;
-                }
-                out.append(bytes, 0, (int)x);
-                count += x;
+            InputStream fin = null;
+            Reader reader = null;
+            try {
+                fin = createInputStream(tempFile);
+                reader = new InputStreamReader(fin, charsetName);
+                char bytes[] = new char[1024];
+                long x = reader.read(bytes);
+                while (x != -1) {
+                    if ((count + x) > limit) {
+                        x = limit - count;
+                    }
+                    out.append(bytes, 0, (int)x);
+                    count += x;
 
-                if (count >= limit) {
-                    x = -1;
-                } else {
-                    x = reader.read(bytes);
+                    if (count >= limit) {
+                        x = -1;
+                    } else {
+                        x = reader.read(bytes);
+                    }
+                }
+            } finally {
+                if (reader != null) {
+                    reader.close();
+                }
+                if (fin != null) {
+                    fin.close();
                 }
             }
-            reader.close();
-            fin.close();
         }
     }
     
@@ -364,16 +373,25 @@ public class CachedOutputStream extends 
             }
         } else {
             // read the file
-            InputStream fin = createInputStream(tempFile);
-            Reader reader = new InputStreamReader(fin, charsetName);
-            char bytes[] = new char[1024];
-            int x = reader.read(bytes);
-            while (x != -1) {
-                out.append(bytes, 0, x);
-                x = reader.read(bytes);
+            InputStream fin = null;
+            Reader reader = null;
+            try {
+                fin = createInputStream(tempFile);
+                reader = new InputStreamReader(fin, charsetName);
+                char bytes[] = new char[1024];
+                int x = reader.read(bytes);
+                while (x != -1) {
+                    out.append(bytes, 0, x);
+                    x = reader.read(bytes);
+                }
+            } finally {
+                if (reader != null) {
+                    reader.close();
+                }
+                if (fin != null) {
+                    fin.close();
+                }
             }
-            reader.close();
-            fin.close();
         }
     }
 

Modified: cxf/trunk/api/src/main/java/org/apache/cxf/io/CachedWriter.java
URL: http://svn.apache.org/viewvc/cxf/trunk/api/src/main/java/org/apache/cxf/io/CachedWriter.java?rev=1411133&r1=1411132&r2=1411133&view=diff
==============================================================================
--- cxf/trunk/api/src/main/java/org/apache/cxf/io/CachedWriter.java (original)
+++ cxf/trunk/api/src/main/java/org/apache/cxf/io/CachedWriter.java Mon Nov 19 11:38:42 2012
@@ -261,16 +261,22 @@ public class CachedWriter extends Writer
             }
         } else {
             // read the file
-            Reader fin = new InputStreamReader(new FileInputStream(tempFile), "UTF-8");
-            CharArrayWriter out = new CharArrayWriter((int)tempFile.length());
-            char bytes[] = new char[1024];
-            int x = fin.read(bytes);
-            while (x != -1) {
-                out.write(bytes, 0, x);
-                x = fin.read(bytes);
+            Reader fin = null;
+            try {
+                fin = new InputStreamReader(new FileInputStream(tempFile), "UTF-8");
+                CharArrayWriter out = new CharArrayWriter((int)tempFile.length());
+                char bytes[] = new char[1024];
+                int x = fin.read(bytes);
+                while (x != -1) {
+                    out.write(bytes, 0, x);
+                    x = fin.read(bytes);
+                }
+                return out.toCharArray();
+            } finally {
+                if (fin != null) {
+                    fin.close();
+                }
             }
-            fin.close();
-            return out.toCharArray();
         }
     }
 
@@ -284,14 +290,20 @@ public class CachedWriter extends Writer
             }
         } else {
             // read the file
-            Reader fin = new InputStreamReader(new FileInputStream(tempFile), "UTF-8");
-            char bytes[] = new char[1024];
-            int x = fin.read(bytes);
-            while (x != -1) {
-                out.write(bytes, 0, x);
-                x = fin.read(bytes);
+            Reader fin = null;
+            try {
+                fin = new InputStreamReader(new FileInputStream(tempFile), "UTF-8");
+                char bytes[] = new char[1024];
+                int x = fin.read(bytes);
+                while (x != -1) {
+                    out.write(bytes, 0, x);
+                    x = fin.read(bytes);
+                }
+            } finally {
+                if (fin != null) {
+                    fin.close();
+                }
             }
-            fin.close();
         }
     }
     
@@ -313,23 +325,29 @@ public class CachedWriter extends Writer
             }
         } else {
             // read the file
-            Reader fin = new InputStreamReader(new FileInputStream(tempFile), "UTF-8");
-            char bytes[] = new char[1024];
-            long x = fin.read(bytes);
-            while (x != -1) {
-                if ((count + x) > limit) {
-                    x = limit - count;
-                }
-                out.append(bytes, 0, (int)x);
-                count += x;
+            Reader fin = null;
+            try {
+                fin = new InputStreamReader(new FileInputStream(tempFile), "UTF-8");
+                char bytes[] = new char[1024];
+                long x = fin.read(bytes);
+                while (x != -1) {
+                    if ((count + x) > limit) {
+                        x = limit - count;
+                    }
+                    out.append(bytes, 0, (int)x);
+                    count += x;
 
-                if (count >= limit) {
-                    x = -1;
-                } else {
-                    x = fin.read(bytes);
+                    if (count >= limit) {
+                        x = -1;
+                    } else {
+                        x = fin.read(bytes);
+                    }
+                }
+            } finally {
+                if (fin != null) {
+                    fin.close();
                 }
             }
-            fin.close();
         }
     }
     
@@ -345,14 +363,20 @@ public class CachedWriter extends Writer
         } else {
             // read the file
             FileInputStream fin = new FileInputStream(tempFile);
-            Reader r = new InputStreamReader(fin, "UTF-8");
-            char chars[] = new char[1024];
-            int x = r.read(chars);
-            while (x != -1) {
-                out.append(chars, 0, x);
-                x = r.read(chars);
+            Reader r = null;
+            try {
+                r = new InputStreamReader(fin, "UTF-8");
+                char chars[] = new char[1024];
+                int x = r.read(chars);
+                while (x != -1) {
+                    out.append(chars, 0, x);
+                    x = r.read(chars);
+                }
+            } finally {
+                if (r != null) {
+                    r.close();
+                }
             }
-            r.close();
         }
     }
 

Modified: cxf/trunk/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/wsdl2java/WSDL2JavaMojo.java
URL: http://svn.apache.org/viewvc/cxf/trunk/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/wsdl2java/WSDL2JavaMojo.java?rev=1411133&r1=1411132&r2=1411133&view=diff
==============================================================================
--- cxf/trunk/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/wsdl2java/WSDL2JavaMojo.java (original)
+++ cxf/trunk/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/wsdl2java/WSDL2JavaMojo.java Mon Nov 19 11:38:42 2012
@@ -271,10 +271,16 @@ public class WSDL2JavaMojo extends Abstr
         doneFile.createNewFile();
         URI basedir = project.getBasedir().toURI();
         String options = wsdlOption.generateCommandLine(null, basedir, wsdlURI, false).toString();
-        DataOutputStream writer = new DataOutputStream(new FileOutputStream(doneFile));
-        writer.writeUTF(options);
-        writer.flush();
-        writer.close();
+        DataOutputStream writer = null;
+        try {
+            writer = new DataOutputStream(new FileOutputStream(doneFile));
+            writer.writeUTF(options);
+            writer.flush();
+        } finally {
+            if (writer != null) {
+                writer.close();
+            }
+        }
     }
     
 

Modified: cxf/trunk/maven-plugins/wsdl-validator-plugin/src/main/java/org/apache/cxf/maven_plugin/WSDLValidatorMojo.java
URL: http://svn.apache.org/viewvc/cxf/trunk/maven-plugins/wsdl-validator-plugin/src/main/java/org/apache/cxf/maven_plugin/WSDLValidatorMojo.java?rev=1411133&r1=1411132&r2=1411133&view=diff
==============================================================================
--- cxf/trunk/maven-plugins/wsdl-validator-plugin/src/main/java/org/apache/cxf/maven_plugin/WSDLValidatorMojo.java (original)
+++ cxf/trunk/maven-plugins/wsdl-validator-plugin/src/main/java/org/apache/cxf/maven_plugin/WSDLValidatorMojo.java Mon Nov 19 11:38:42 2012
@@ -146,10 +146,16 @@ public class WSDLValidatorMojo extends A
                 list.add(file.getCanonicalPath());
                 String[] pargs = list.toArray(new String[list.size()]);
                 
-                InputStream toolspecStream = WSDLValidator.class
-                    .getResourceAsStream("wsdlvalidator.xml");
-                ToolSpec spec = new ToolSpec(toolspecStream, false);
-                toolspecStream.close();
+                ToolSpec spec = null;
+                InputStream toolspecStream = null;
+                try {
+                    toolspecStream = WSDLValidator.class .getResourceAsStream("wsdlvalidator.xml");
+                    spec = new ToolSpec(toolspecStream, false);
+                } finally {
+                    if (toolspecStream != null) {
+                        toolspecStream.close();
+                    }
+                }
                 WSDLValidator validator = new WSDLValidator(spec);
                 validator.setArguments(pargs);
                 boolean ok = validator.executeForMaven();

Modified: cxf/trunk/rt/bindings/corba/src/main/java/org/apache/cxf/binding/corba/utils/CorbaUtils.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/bindings/corba/src/main/java/org/apache/cxf/binding/corba/utils/CorbaUtils.java?rev=1411133&r1=1411132&r2=1411133&view=diff
==============================================================================
--- cxf/trunk/rt/bindings/corba/src/main/java/org/apache/cxf/binding/corba/utils/CorbaUtils.java (original)
+++ cxf/trunk/rt/bindings/corba/src/main/java/org/apache/cxf/binding/corba/utils/CorbaUtils.java Mon Nov 19 11:38:42 2012
@@ -528,21 +528,28 @@ public final class CorbaUtils {
                                                                      String url) {
         org.omg.CORBA.Object result;
 
+        java.io.BufferedReader reader = null;
         try {
             java.io.File file = new java.io.File(url);
             if (!file.exists()) {
                 throw new RuntimeException("Could not find file " + url + " to read the object reference");
             }
-            java.io.BufferedReader reader = new java.io.BufferedReader(new java.io.FileReader(file));
+            reader = new java.io.BufferedReader(new java.io.FileReader(file));
             String ior = reader.readLine();
             if (ior == null) {
-                reader.close();
                 throw new RuntimeException("Invalid object reference found in file " + url);
             }
             result = orb.string_to_object(ior.trim());
-            reader.close();
         } catch (java.io.IOException ex) {
             throw new RuntimeException(ex);
+        } finally {
+            if (reader != null) {
+                try {
+                    reader.close();
+                } catch (java.io.IOException ex) {
+                    throw new RuntimeException(ex);
+                }
+            }
         }
         return result;
     }

Modified: cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/endpoint/dynamic/DynamicClientFactory.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/endpoint/dynamic/DynamicClientFactory.java?rev=1411133&r1=1411132&r2=1411133&view=diff
==============================================================================
--- cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/endpoint/dynamic/DynamicClientFactory.java (original)
+++ cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/endpoint/dynamic/DynamicClientFactory.java Mon Nov 19 11:38:42 2012
@@ -602,36 +602,42 @@ public class DynamicClientFactory {
     static void addClasspathFromManifest(StringBuilder classPath, File file) 
         throws URISyntaxException, IOException {
         
-        JarFile jar = new JarFile(file);
-        Attributes attr = null;
-        if (jar.getManifest() != null) {
-            attr = jar.getManifest().getMainAttributes();
-        }
-        if (attr != null) {
-            String cp = attr.getValue("Class-Path");
-            while (cp != null) {
-                String fileName = cp;
-                int idx = fileName.indexOf(' ');
-                if (idx != -1) {
-                    fileName = fileName.substring(0, idx);
-                    cp =  cp.substring(idx + 1).trim();
-                } else {
-                    cp = null;
-                }
-                URI uri = new URI(fileName);
-                File f2;
-                if (uri.isAbsolute()) {
-                    f2 = new File(uri);
-                } else {
-                    f2 = new File(file, fileName);
-                }
-                if (f2.exists()) {
-                    classPath.append(f2.getAbsolutePath());
-                    classPath.append(File.pathSeparator);
+        JarFile jar = null;
+        try {
+            jar = new JarFile(file);
+            Attributes attr = null;
+            if (jar.getManifest() != null) {
+                attr = jar.getManifest().getMainAttributes();
+            }
+            if (attr != null) {
+                String cp = attr.getValue("Class-Path");
+                while (cp != null) {
+                    String fileName = cp;
+                    int idx = fileName.indexOf(' ');
+                    if (idx != -1) {
+                        fileName = fileName.substring(0, idx);
+                        cp =  cp.substring(idx + 1).trim();
+                    } else {
+                        cp = null;
+                    }
+                    URI uri = new URI(fileName);
+                    File f2;
+                    if (uri.isAbsolute()) {
+                        f2 = new File(uri);
+                    } else {
+                        f2 = new File(file, fileName);
+                    }
+                    if (f2.exists()) {
+                        classPath.append(f2.getAbsolutePath());
+                        classPath.append(File.pathSeparator);
+                    }
                 }
             }
+        } finally {
+            if (jar != null) {
+                jar.close();
+            }
         }
-        jar.close();
     }
 
     static void setupClasspath(StringBuilder classPath, ClassLoader classLoader)

Modified: cxf/trunk/rt/frontend/js/src/main/java/org/apache/cxf/js/rhino/ProviderFactory.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/js/src/main/java/org/apache/cxf/js/rhino/ProviderFactory.java?rev=1411133&r1=1411132&r2=1411133&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/js/src/main/java/org/apache/cxf/js/rhino/ProviderFactory.java (original)
+++ cxf/trunk/rt/frontend/js/src/main/java/org/apache/cxf/js/rhino/ProviderFactory.java Mon Nov 19 11:38:42 2012
@@ -74,17 +74,23 @@ public class ProviderFactory {
             throw new Exception(f.getPath() + NO_SUCH_FILE);
         }
         boolean isE4X = f.getName().endsWith(".jsx");
-        BufferedReader bufrd = new BufferedReader(new FileReader(f));
-        String line = null;
+        BufferedReader bufrd = null;
         StringBuilder sb = new StringBuilder();
-        for (;;) {
-            line = bufrd.readLine();
-            if (line == null) {
-                break;
+        try {
+            bufrd = new BufferedReader(new FileReader(f));
+            String line = null;
+            for (;;) {
+                line = bufrd.readLine();
+                if (line == null) {
+                    break;
+                }
+                sb.append(line).append("\n");
+            }
+        } finally {
+            if (bufrd != null) {
+                bufrd.close();
             }
-            sb.append(line).append("\n");
         }
-        bufrd.close();
         String scriptStr = sb.toString();
 
         Context cx = ContextFactory.getGlobal().enterContext();

Modified: cxf/trunk/rt/management/src/main/java/org/apache/cxf/management/persistence/FilesystemExchangeDataDAO.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/management/src/main/java/org/apache/cxf/management/persistence/FilesystemExchangeDataDAO.java?rev=1411133&r1=1411132&r2=1411133&view=diff
==============================================================================
--- cxf/trunk/rt/management/src/main/java/org/apache/cxf/management/persistence/FilesystemExchangeDataDAO.java (original)
+++ cxf/trunk/rt/management/src/main/java/org/apache/cxf/management/persistence/FilesystemExchangeDataDAO.java Mon Nov 19 11:38:42 2012
@@ -116,11 +116,16 @@ public class FilesystemExchangeDataDAO i
             }
         }
 
-        FileOutputStream fileOutputStream = new FileOutputStream(file);
+        FileOutputStream fileOutputStream = null;
+        try {
+            fileOutputStream = new FileOutputStream(file);
 
-        fileOutputStream.write(stringWriter.getBuffer().toString().getBytes());
-
-        fileOutputStream.close();
+            fileOutputStream.write(stringWriter.getBuffer().toString().getBytes());
+        } finally {
+            if (fileOutputStream != null) {
+                fileOutputStream.close();
+            }
+        }
 
         if (LOG.isLoggable(Level.FINE)) {
             LOG.fine("Exchange data saved in " + file.getAbsolutePath());

Modified: cxf/trunk/testutils/src/main/java/org/apache/cxf/testutil/common/ServerLauncher.java
URL: http://svn.apache.org/viewvc/cxf/trunk/testutils/src/main/java/org/apache/cxf/testutil/common/ServerLauncher.java?rev=1411133&r1=1411132&r2=1411133&view=diff
==============================================================================
--- cxf/trunk/testutils/src/main/java/org/apache/cxf/testutil/common/ServerLauncher.java (original)
+++ cxf/trunk/testutils/src/main/java/org/apache/cxf/testutil/common/ServerLauncher.java Mon Nov 19 11:38:42 2012
@@ -281,6 +281,7 @@ public class ServerLauncher {
         }
 
         public void run() {
+            PrintStream ps = null;
             try {
                 String outputDir = System.getProperty("server.output.dir", "target/surefire-reports/");
                 FileOutputStream fos;
@@ -298,7 +299,7 @@ public class ServerLauncher {
                     file.mkdirs();
                     fos = new FileOutputStream(outputDir + className + ".out");
                 }
-                PrintStream ps = new PrintStream(fos);
+                ps = new PrintStream(fos);
                 boolean running = true;
                 StringBuilder serverOutput = new StringBuilder();
                 for (int ch = in.read(); ch != -1; ch = in.read()) {
@@ -327,11 +328,14 @@ public class ServerLauncher {
                         }
                     }
                 }
-                ps.close();
             } catch (IOException ex) {
                 if (!ex.getMessage().contains("Stream closed")) {
                     ex.printStackTrace();
                 }
+            } finally {
+                if (ps != null) {
+                    ps.close();
+                }
             }
         }
     }

Modified: cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/common/ClassUtils.java
URL: http://svn.apache.org/viewvc/cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/common/ClassUtils.java?rev=1411133&r1=1411132&r2=1411133&view=diff
==============================================================================
--- cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/common/ClassUtils.java (original)
+++ cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/common/ClassUtils.java Mon Nov 19 11:38:42 2012
@@ -22,6 +22,7 @@ package org.apache.cxf.tools.common;
 import java.io.File;
 import java.io.FileInputStream;
 import java.io.FileOutputStream;
+import java.io.IOException;
 import java.util.ArrayList;
 import java.util.HashSet;
 import java.util.Iterator;
@@ -91,7 +92,13 @@ public class ClassUtils {
 
                                 File targetFile = new File(targetDir + File.separator + dirName
                                                            + File.separator + str);
-                                copyXmlFile(otherFile, targetFile);
+                                try {
+                                    copyXmlFile(otherFile, targetFile);
+
+                                } catch (IOException e) {
+                                    Message msg = new Message("FAIL_TO_COPY_GENERATED_RESOURCE_FILE", LOG);
+                                    throw new ToolException(msg, e);
+                                }
                             }
                         }
                     }
@@ -115,15 +122,17 @@ public class ClassUtils {
         }        
     }
     
-    private void copyXmlFile(File from, File to) throws ToolException {
+    private void copyXmlFile(File from, File to) throws ToolException, IOException {
 
+        FileInputStream input = null;
+        FileOutputStream output = null;
         try {
             String dir = to.getCanonicalPath()
                 .substring(0, to.getCanonicalPath().lastIndexOf(File.separator));
             File dirFile = new File(dir);
             dirFile.mkdirs();
-            FileInputStream input = new FileInputStream(from);
-            FileOutputStream output = new FileOutputStream(to);
+            input = new FileInputStream(from);
+            output = new FileOutputStream(to);
             byte[] b = new byte[1024 * 3];
             int len = 0;
             while (len != -1) {
@@ -133,11 +142,16 @@ public class ClassUtils {
                 }
             }
             output.flush();
-            output.close();
-            input.close();
         } catch (Exception e) {
             Message msg = new Message("FAIL_TO_COPY_GENERATED_RESOURCE_FILE", LOG);
             throw new ToolException(msg, e);
+        } finally {
+            if (output != null) {
+                output.close();
+            }
+            if (input != null) {
+                input.close();
+            }
         }
     }    
 }

Modified: cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/common/ProcessorTestBase.java
URL: http://svn.apache.org/viewvc/cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/common/ProcessorTestBase.java?rev=1411133&r1=1411132&r2=1411133&view=diff
==============================================================================
--- cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/common/ProcessorTestBase.java (original)
+++ cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/common/ProcessorTestBase.java Mon Nov 19 11:38:42 2012
@@ -92,28 +92,34 @@ public class ProcessorTestBase extends A
                 }
                 if (filename.indexOf("surefirebooter") != -1) {
                     //surefire 2.4 uses a MANIFEST classpath that javac doesn't like
-                    JarFile jar = new JarFile(filename);
-                    Attributes attr = jar.getManifest().getMainAttributes();
-                    if (attr != null) {
-                        String cp = attr.getValue("Class-Path");
-                        while (cp != null) {
-                            String fileName = cp;
-                            int idx = fileName.indexOf(' ');
-                            if (idx != -1) {
-                                fileName = fileName.substring(0, idx);
-                                cp =  cp.substring(idx + 1).trim();
-                            } else {
-                                cp = null;
-                            }
-                            URI uri = new URI(fileName);
-                            File f2 = new File(uri);
-                            if (f2.exists()) {
-                                classPath.append(f2.getAbsolutePath());
-                                classPath.append(System.getProperty("path.separator"));
+                    JarFile jar = null;
+                    try {
+                        jar = new JarFile(filename);
+                        Attributes attr = jar.getManifest().getMainAttributes();
+                        if (attr != null) {
+                            String cp = attr.getValue("Class-Path");
+                            while (cp != null) {
+                                String fileName = cp;
+                                int idx = fileName.indexOf(' ');
+                                if (idx != -1) {
+                                    fileName = fileName.substring(0, idx);
+                                    cp =  cp.substring(idx + 1).trim();
+                                } else {
+                                    cp = null;
+                                }
+                                URI uri = new URI(fileName);
+                                File f2 = new File(uri);
+                                if (f2.exists()) {
+                                    classPath.append(f2.getAbsolutePath());
+                                    classPath.append(System.getProperty("path.separator"));
+                                }
                             }
                         }
+                    } finally {
+                        if (jar != null) {
+                            jar.close();
+                        }
                     }
-                    jar.close();
                 }
             }
         }

Modified: cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/util/JAXBUtils.java
URL: http://svn.apache.org/viewvc/cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/util/JAXBUtils.java?rev=1411133&r1=1411132&r2=1411133&view=diff
==============================================================================
--- cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/util/JAXBUtils.java (original)
+++ cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/util/JAXBUtils.java Mon Nov 19 11:38:42 2012
@@ -127,13 +127,21 @@ public final class JAXBUtils {
         schemaBindings.appendChild(pkgElement);
         rootElement.appendChild(annoElement);
         File tmpFile = null;
+        FileOutputStream fout = null;
         try {
             tmpFile = FileUtils.createTempFile("customzied", ".xsd");
-            FileOutputStream fout = new FileOutputStream(tmpFile);
+            fout = new FileOutputStream(tmpFile);
             DOMUtils.writeXml(rootElement, fout);
-            fout.close();
         } catch (Exception e) {
             e.printStackTrace();
+        } finally {
+            if (fout != null) {
+                try {
+                    fout.close();
+                } catch (Exception e) {
+                    e.printStackTrace();
+                }
+            }
         }
         return tmpFile;
     }

Modified: cxf/trunk/tools/corba/src/main/java/org/apache/cxf/tools/corba/common/SchemaFactory.java
URL: http://svn.apache.org/viewvc/cxf/trunk/tools/corba/src/main/java/org/apache/cxf/tools/corba/common/SchemaFactory.java?rev=1411133&r1=1411132&r2=1411133&view=diff
==============================================================================
--- cxf/trunk/tools/corba/src/main/java/org/apache/cxf/tools/corba/common/SchemaFactory.java (original)
+++ cxf/trunk/tools/corba/src/main/java/org/apache/cxf/tools/corba/common/SchemaFactory.java Mon Nov 19 11:38:42 2012
@@ -127,10 +127,15 @@ public abstract class SchemaFactory {
             try {
                 Properties properties = new Properties();
                 File propFile = new File(propFileName);
-                FileInputStream fis = new FileInputStream(propFile);
-
-                properties.load(fis);
-                fis.close();
+                FileInputStream fis = null;
+                try {
+                    fis = new FileInputStream(propFile);
+                    properties.load(fis);
+                } finally {
+                    if (fis != null) {
+                        fis.close();
+                    }
+                }
 
                 factoryImplName = properties.getProperty(PROPERTY_NAME);
 

Modified: cxf/trunk/tools/corba/src/main/java/org/apache/cxf/tools/corba/common/WSDLCorbaFactory.java
URL: http://svn.apache.org/viewvc/cxf/trunk/tools/corba/src/main/java/org/apache/cxf/tools/corba/common/WSDLCorbaFactory.java?rev=1411133&r1=1411132&r2=1411133&view=diff
==============================================================================
--- cxf/trunk/tools/corba/src/main/java/org/apache/cxf/tools/corba/common/WSDLCorbaFactory.java (original)
+++ cxf/trunk/tools/corba/src/main/java/org/apache/cxf/tools/corba/common/WSDLCorbaFactory.java Mon Nov 19 11:38:42 2012
@@ -139,10 +139,15 @@ public abstract class WSDLCorbaFactory {
             try {
                 Properties properties = new Properties();
                 File propFile = new File(propFileName);
-                FileInputStream fis = new FileInputStream(propFile);
-
-                properties.load(fis);
-                fis.close();
+                FileInputStream fis = null;
+                try {
+                    fis = new FileInputStream(propFile);
+                    properties.load(fis);
+                } finally {
+                    if (fis != null) {
+                        fis.close();
+                    }
+                }
 
                 factoryImplName = properties.getProperty(PROPERTY_NAME);
 

Modified: cxf/trunk/tools/corba/src/main/java/org/apache/cxf/tools/corba/processors/idl/IDLToWSDLProcessor.java
URL: http://svn.apache.org/viewvc/cxf/trunk/tools/corba/src/main/java/org/apache/cxf/tools/corba/processors/idl/IDLToWSDLProcessor.java?rev=1411133&r1=1411132&r2=1411133&view=diff
==============================================================================
--- cxf/trunk/tools/corba/src/main/java/org/apache/cxf/tools/corba/processors/idl/IDLToWSDLProcessor.java (original)
+++ cxf/trunk/tools/corba/src/main/java/org/apache/cxf/tools/corba/processors/idl/IDLToWSDLProcessor.java Mon Nov 19 11:38:42 2012
@@ -23,6 +23,7 @@ import java.io.BufferedReader;
 import java.io.File;
 import java.io.FileNotFoundException;
 import java.io.FileReader;
+import java.io.IOException;
 import java.io.Writer;
 import java.net.URI;
 import java.util.ArrayList;
@@ -500,14 +501,18 @@ public class IDLToWSDLProcessor extends 
             String addr = null;
             String addrFileName = (String) env.get(ToolCorbaConstants.CFG_ADDRESSFILE); 
             if (addrFileName != null) {
+                BufferedReader bufferedReader = null;
                 try {
                     File addrFile = new File(addrFileName);
                     FileReader fileReader = new FileReader(addrFile);
-                    BufferedReader bufferedReader = new BufferedReader(fileReader);
+                    bufferedReader = new BufferedReader(fileReader);
                     addr = bufferedReader.readLine();
-                    bufferedReader.close();
                 } catch (Exception ex) {
                     throw new ToolException(ex.getMessage(), ex);
+                } finally {
+                    if (bufferedReader != null) {
+                        bufferedReader.close();
+                    }
                 }
             } else {
                 addr = (String) env.get(ToolCorbaConstants.CFG_ADDRESS);
@@ -610,7 +615,7 @@ public class IDLToWSDLProcessor extends 
         return prefix;
     }
 
-    private Map<String, String> getModuleToNSMapping(String mapping) {
+    private Map<String, String> getModuleToNSMapping(String mapping) throws IOException {
         Map<String, String> map = new HashMap<String, String>();
         if ((mapping != null) && (mapping.length() > 0)) {
             if ((mapping.startsWith("[")) && (mapping.endsWith("]"))) {
@@ -630,8 +635,9 @@ public class IDLToWSDLProcessor extends 
                 }
             } else if (mapping.startsWith(":")) {
                 mapping = mapping.substring(1);
+                BufferedReader reader = null;
                 try {
-                    BufferedReader reader = new BufferedReader(new FileReader(mapping));
+                    reader = new BufferedReader(new FileReader(mapping));
                     String token = reader.readLine();
                     while (token != null) {
                         int pos = token.indexOf("=");
@@ -647,10 +653,13 @@ public class IDLToWSDLProcessor extends 
                         map.put(token.substring(0, pos), token.substring(pos + 1));
                         token = reader.readLine();
                     }
-                    reader.close();
                 } catch (Exception ex) {
                     throw new RuntimeException("Incorrect properties file for mns mapping - " + mapping
                                                + ". Cause: " + ex.getMessage());
+                } finally {
+                    if (reader != null) {
+                        reader.close();
+                    }
                 }
             } else {
                 throw new RuntimeException("Option mns should have a start([) & close(]) bracket"

Modified: cxf/trunk/tools/corba/src/main/java/org/apache/cxf/tools/corba/processors/wsdl/WSDLToCorbaBinding.java
URL: http://svn.apache.org/viewvc/cxf/trunk/tools/corba/src/main/java/org/apache/cxf/tools/corba/processors/wsdl/WSDLToCorbaBinding.java?rev=1411133&r1=1411132&r2=1411133&view=diff
==============================================================================
--- cxf/trunk/tools/corba/src/main/java/org/apache/cxf/tools/corba/processors/wsdl/WSDLToCorbaBinding.java (original)
+++ cxf/trunk/tools/corba/src/main/java/org/apache/cxf/tools/corba/processors/wsdl/WSDLToCorbaBinding.java Mon Nov 19 11:38:42 2012
@@ -342,14 +342,18 @@ public class WSDLToCorbaBinding {
 
             String addr = null;
             if (getAddressFile() != null) {
+                BufferedReader bufferedReader = null;
                 try {
                     File addrFile = new File(getAddressFile());
                     FileReader fileReader = new FileReader(addrFile);
-                    BufferedReader bufferedReader = new BufferedReader(fileReader);
+                    bufferedReader = new BufferedReader(fileReader);
                     addr = bufferedReader.readLine();
-                    bufferedReader.close();
                 } catch (Exception ex) {
                     throw new ToolException(ex.getMessage(), ex);
+                } finally {
+                    if (bufferedReader != null) {
+                        bufferedReader.close();
+                    }
                 }
             } else {
                 addr = getAddress();

Modified: cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2js/processor/JavaToJSProcessor.java
URL: http://svn.apache.org/viewvc/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2js/processor/JavaToJSProcessor.java?rev=1411133&r1=1411132&r2=1411133&view=diff
==============================================================================
--- cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2js/processor/JavaToJSProcessor.java (original)
+++ cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2js/processor/JavaToJSProcessor.java Mon Nov 19 11:38:42 2012
@@ -82,6 +82,7 @@ public class JavaToJSProcessor implement
         NamespacePrefixAccumulator prefixManager = new NamespacePrefixAccumulator(serviceInfo
             .getXmlSchemaCollection());
         Collection<SchemaInfo> schemata = serviceInfo.getSchemas();
+        BufferedWriter writer = null;
         try {
             FileOutputStream fileOutputStream = new FileOutputStream(jsFile);
             if (null != context.get(ToolConstants.CFG_JAVASCRIPT_UTILS)) {
@@ -89,7 +90,7 @@ public class JavaToJSProcessor implement
             }
 
             OutputStreamWriter outputStreamWriter = new OutputStreamWriter(fileOutputStream, UTF8);
-            BufferedWriter writer = new BufferedWriter(outputStreamWriter);
+            writer = new BufferedWriter(outputStreamWriter);
 
             for (SchemaInfo schema : schemata) {
                 SchemaJavascriptBuilder jsBuilder = new SchemaJavascriptBuilder(serviceInfo
@@ -103,11 +104,18 @@ public class JavaToJSProcessor implement
             serviceBuilder.walk();
             String serviceJavascript = serviceBuilder.getCode();
             writer.append(serviceJavascript);
-            writer.close();
         } catch (FileNotFoundException e) {
             throw new ToolException(e);
         } catch (IOException e) {
             throw new ToolException(e);
+        } finally {
+            if (writer != null) {
+                try {
+                    writer.close();
+                } catch (IOException e) {
+                    throw new ToolException(e);
+                }
+            }
         }
 
         System.setProperty(JAVA_CLASS_PATH, oldClassPath);

Modified: cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/generator/wsdl11/WSDL11Generator.java
URL: http://svn.apache.org/viewvc/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/generator/wsdl11/WSDL11Generator.java?rev=1411133&r1=1411132&r2=1411133&view=diff
==============================================================================
--- cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/generator/wsdl11/WSDL11Generator.java (original)
+++ cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/generator/wsdl11/WSDL11Generator.java Mon Nov 19 11:38:42 2012
@@ -93,9 +93,15 @@ public class WSDL11Generator extends Abs
                     } else {
                         wsdlFile = new File(outputdir, wsdlDef.getQName().getLocalPart() + ".wsdl");
                     }
-                    OutputStream wsdlOs = new BufferedOutputStream(new FileOutputStream(wsdlFile));
-                    wsdlWriter.writeWSDL(wsdlDef, wsdlOs);
-                    wsdlOs.close();
+                    OutputStream wsdlOs = null;
+                    try {
+                        wsdlOs = new BufferedOutputStream(new FileOutputStream(wsdlFile));
+                        wsdlWriter.writeWSDL(wsdlDef, wsdlOs);
+                    } finally {
+                        if (wsdlOs != null) {
+                            wsdlOs.close();
+                        }
+                    }
                 }
             }
 

Modified: cxf/trunk/tools/wadlto/jaxrs/src/main/java/org/apache/cxf/tools/wadlto/jaxrs/SourceGenerator.java
URL: http://svn.apache.org/viewvc/cxf/trunk/tools/wadlto/jaxrs/src/main/java/org/apache/cxf/tools/wadlto/jaxrs/SourceGenerator.java?rev=1411133&r1=1411132&r2=1411133&view=diff
==============================================================================
--- cxf/trunk/tools/wadlto/jaxrs/src/main/java/org/apache/cxf/tools/wadlto/jaxrs/SourceGenerator.java (original)
+++ cxf/trunk/tools/wadlto/jaxrs/src/main/java/org/apache/cxf/tools/wadlto/jaxrs/SourceGenerator.java Mon Nov 19 11:38:42 2012
@@ -1247,9 +1247,15 @@ public class SourceGenerator {
         
         try {
             file.createNewFile();
-            FileOutputStream fos = new FileOutputStream(file);
-            fos.write(content.getBytes());
-            fos.close();
+            FileOutputStream fos = null;
+            try {
+                fos = new FileOutputStream(file);
+                fos.write(content.getBytes());
+            } finally {
+                if (fos != null) {
+                    fos.close();
+                }
+            }
         } catch (FileNotFoundException ex) {
             LOG.warning(file.getAbsolutePath() + " is not found");
         } catch (IOException ex) {

Modified: cxf/trunk/tools/wsdlto/frontend/javascript/src/main/java/org/apache/cxf/tools/wsdlto/javascript/WSDLToJavaScriptProcessor.java
URL: http://svn.apache.org/viewvc/cxf/trunk/tools/wsdlto/frontend/javascript/src/main/java/org/apache/cxf/tools/wsdlto/javascript/WSDLToJavaScriptProcessor.java?rev=1411133&r1=1411132&r2=1411133&view=diff
==============================================================================
--- cxf/trunk/tools/wsdlto/frontend/javascript/src/main/java/org/apache/cxf/tools/wsdlto/javascript/WSDLToJavaScriptProcessor.java (original)
+++ cxf/trunk/tools/wsdlto/frontend/javascript/src/main/java/org/apache/cxf/tools/wsdlto/javascript/WSDLToJavaScriptProcessor.java Mon Nov 19 11:38:42 2012
@@ -68,7 +68,8 @@ public class WSDLToJavaScriptProcessor e
                 prefixManager.collect(prefixEntry.getValue(), prefixEntry.getKey());
             }
         }
-        
+
+        BufferedWriter writer = null;
         try {
             FileOutputStream fileOutputStream = new FileOutputStream(jsFile);
             if (null != context.get(ToolConstants.CFG_JAVASCRIPT_UTILS)) {
@@ -77,7 +78,7 @@ public class WSDLToJavaScriptProcessor e
             }
             
             OutputStreamWriter outputStreamWriter = new OutputStreamWriter(fileOutputStream, UTF8);
-            BufferedWriter writer = new BufferedWriter(outputStreamWriter);
+            writer = new BufferedWriter(outputStreamWriter);
             
             XmlSchemaCollection collection = serviceInfo.getXmlSchemaCollection().getXmlSchemaCollection();
             SchemaJavascriptBuilder jsBuilder = 
@@ -93,11 +94,18 @@ public class WSDLToJavaScriptProcessor e
             serviceBuilder.walk();
             String serviceJavascript = serviceBuilder.getCode();
             writer.append(serviceJavascript);
-            writer.close();
         } catch (FileNotFoundException e) {
             throw new ToolException(e);
         } catch (IOException e) {
             throw new ToolException(e);
+        } finally {
+            try {
+                if (writer != null) {
+                    writer.close();
+                }
+            } catch (IOException e) {
+                throw new ToolException(e);
+            }
         }
     }
     



Mime
View raw message