cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cohei...@apache.org
Subject cxf git commit: More try with resources work for rt
Date Tue, 24 Feb 2015 11:35:42 GMT
Repository: cxf
Updated Branches:
  refs/heads/master 8077aaa7e -> a79bb058a


More try with resources work for rt


Project: http://git-wip-us.apache.org/repos/asf/cxf/repo
Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/a79bb058
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/a79bb058
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/a79bb058

Branch: refs/heads/master
Commit: a79bb058aaf71e85dcb5c90e7b2f6e4ab8e63cba
Parents: 8077aaa
Author: Colm O hEigeartaigh <coheigea@apache.org>
Authored: Tue Feb 24 11:26:50 2015 +0000
Committer: Colm O hEigeartaigh <coheigea@apache.org>
Committed: Tue Feb 24 11:26:50 2015 +0000

----------------------------------------------------------------------
 .../org/apache/cxf/jaxrs/provider/SourceProvider.java  |  5 +----
 .../jaxws/interceptors/MessageModeInInterceptor.java   |  7 ++-----
 .../java/org/apache/cxf/js/rhino/ProviderFactory.java  |  9 ++-------
 .../cxf/endpoint/dynamic/DynamicClientFactory.java     |  8 +-------
 .../persistence/FilesystemExchangeDataDAO.java         |  9 +--------
 .../https/httpclient/PublicSuffixMatcherLoader.java    | 10 ++--------
 .../apache/cxf/wsdl/service/factory/ClassReader.java   | 13 +++++--------
 .../apache/cxf/wsdl/service/factory/ParamReader.java   |  7 +------
 8 files changed, 15 insertions(+), 53 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/a79bb058/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/SourceProvider.java
----------------------------------------------------------------------
diff --git a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/SourceProvider.java
b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/SourceProvider.java
index 4ece76b..654a9ff 100644
--- a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/SourceProvider.java
+++ b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/SourceProvider.java
@@ -165,14 +165,11 @@ public class SourceProvider<T> extends AbstractConfigurableProvider
implements
     private InputStream getStreamFromReader(XMLStreamReader input) 
         throws IOException {
         
-        CachedOutputStream out = new CachedOutputStream();
-        try {
+        try (CachedOutputStream out = new CachedOutputStream()) {
             StaxUtils.copy(input, out);
             return out.getInputStream();
         } catch (XMLStreamException ex) {
             throw new IOException("XMLStreamException:" + ex.getMessage());
-        } finally {
-            out.close();
         }
     }
     

http://git-wip-us.apache.org/repos/asf/cxf/blob/a79bb058/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/interceptors/MessageModeInInterceptor.java
----------------------------------------------------------------------
diff --git a/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/interceptors/MessageModeInInterceptor.java
b/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/interceptors/MessageModeInInterceptor.java
index e8823eb..23e20fb 100644
--- a/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/interceptors/MessageModeInInterceptor.java
+++ b/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/interceptors/MessageModeInInterceptor.java
@@ -102,14 +102,11 @@ public class MessageModeInInterceptor extends AbstractPhaseInterceptor<Message>
         
         if (StreamSource.class.isAssignableFrom(type)) {
             try {
-                CachedOutputStream out = new CachedOutputStream();
-                try {
+                try (CachedOutputStream out = new CachedOutputStream()) {
                     XMLStreamWriter xsw = StaxUtils.createXMLStreamWriter(out);
                     StaxUtils.copy(new DOMSource(m.getSOAPPart()), xsw);
                     xsw.close();
                     o = new StreamSource(out.getInputStream());
-                } finally {
-                    out.close();
                 }
             } catch (Exception e) {
                 throw new Fault(e);
@@ -250,4 +247,4 @@ public class MessageModeInInterceptor extends AbstractPhaseInterceptor<Message>
             return ct.substring(0, idx);
         }
     }
-}
\ No newline at end of file
+}

http://git-wip-us.apache.org/repos/asf/cxf/blob/a79bb058/rt/frontend/js/src/main/java/org/apache/cxf/js/rhino/ProviderFactory.java
----------------------------------------------------------------------
diff --git a/rt/frontend/js/src/main/java/org/apache/cxf/js/rhino/ProviderFactory.java b/rt/frontend/js/src/main/java/org/apache/cxf/js/rhino/ProviderFactory.java
index ac143d3..cdf3c2c 100644
--- a/rt/frontend/js/src/main/java/org/apache/cxf/js/rhino/ProviderFactory.java
+++ b/rt/frontend/js/src/main/java/org/apache/cxf/js/rhino/ProviderFactory.java
@@ -74,10 +74,8 @@ public class ProviderFactory {
             throw new Exception(f.getPath() + NO_SUCH_FILE);
         }
         boolean isE4X = f.getName().endsWith(".jsx");
-        BufferedReader bufrd = null;
         StringBuilder sb = new StringBuilder();
-        try {
-            bufrd = new BufferedReader(new FileReader(f));
+        try (BufferedReader bufrd = new BufferedReader(new FileReader(f))) {
             String line = null;
             for (;;) {
                 line = bufrd.readLine();
@@ -86,11 +84,8 @@ public class ProviderFactory {
                 }
                 sb.append(line).append("\n");
             }
-        } finally {
-            if (bufrd != null) {
-                bufrd.close();
-            }
         }
+
         String scriptStr = sb.toString();
 
         Context cx = ContextFactory.getGlobal().enterContext();

http://git-wip-us.apache.org/repos/asf/cxf/blob/a79bb058/rt/frontend/simple/src/main/java/org/apache/cxf/endpoint/dynamic/DynamicClientFactory.java
----------------------------------------------------------------------
diff --git a/rt/frontend/simple/src/main/java/org/apache/cxf/endpoint/dynamic/DynamicClientFactory.java
b/rt/frontend/simple/src/main/java/org/apache/cxf/endpoint/dynamic/DynamicClientFactory.java
index ad06932..cb0b313 100644
--- a/rt/frontend/simple/src/main/java/org/apache/cxf/endpoint/dynamic/DynamicClientFactory.java
+++ b/rt/frontend/simple/src/main/java/org/apache/cxf/endpoint/dynamic/DynamicClientFactory.java
@@ -614,9 +614,7 @@ public class DynamicClientFactory {
     static void addClasspathFromManifest(StringBuilder classPath, File file) 
         throws URISyntaxException, IOException {
         
-        JarFile jar = null;
-        try {
-            jar = new JarFile(file);
+        try (JarFile jar = new JarFile(file)) {
             Attributes attr = null;
             if (jar.getManifest() != null) {
                 attr = jar.getManifest().getMainAttributes();
@@ -645,10 +643,6 @@ public class DynamicClientFactory {
                     }
                 }
             }
-        } finally {
-            if (jar != null) {
-                jar.close();
-            }
         }
     }
 

http://git-wip-us.apache.org/repos/asf/cxf/blob/a79bb058/rt/management/src/main/java/org/apache/cxf/management/persistence/FilesystemExchangeDataDAO.java
----------------------------------------------------------------------
diff --git a/rt/management/src/main/java/org/apache/cxf/management/persistence/FilesystemExchangeDataDAO.java
b/rt/management/src/main/java/org/apache/cxf/management/persistence/FilesystemExchangeDataDAO.java
index 3c0be5b..05bb683 100644
--- a/rt/management/src/main/java/org/apache/cxf/management/persistence/FilesystemExchangeDataDAO.java
+++ b/rt/management/src/main/java/org/apache/cxf/management/persistence/FilesystemExchangeDataDAO.java
@@ -116,15 +116,8 @@ public class FilesystemExchangeDataDAO implements ExchangeDataDAO {
             }
         }
 
-        FileOutputStream fileOutputStream = null;
-        try {
-            fileOutputStream = new FileOutputStream(file);
-
+        try (FileOutputStream fileOutputStream = new FileOutputStream(file)) {
             fileOutputStream.write(stringWriter.getBuffer().toString().getBytes());
-        } finally {
-            if (fileOutputStream != null) {
-                fileOutputStream.close();
-            }
         }
 
         if (LOG.isLoggable(Level.FINE)) {

http://git-wip-us.apache.org/repos/asf/cxf/blob/a79bb058/rt/transports/http/src/main/java/org/apache/cxf/transport/https/httpclient/PublicSuffixMatcherLoader.java
----------------------------------------------------------------------
diff --git a/rt/transports/http/src/main/java/org/apache/cxf/transport/https/httpclient/PublicSuffixMatcherLoader.java
b/rt/transports/http/src/main/java/org/apache/cxf/transport/https/httpclient/PublicSuffixMatcherLoader.java
index d51d0bd..fe48811 100644
--- a/rt/transports/http/src/main/java/org/apache/cxf/transport/https/httpclient/PublicSuffixMatcherLoader.java
+++ b/rt/transports/http/src/main/java/org/apache/cxf/transport/https/httpclient/PublicSuffixMatcherLoader.java
@@ -61,11 +61,8 @@ public final class PublicSuffixMatcherLoader {
         if (url == null) {
             throw new IllegalArgumentException("URL is null");
         }
-        final InputStream in = url.openStream();
-        try {
+        try (final InputStream in = url.openStream()) {
             return load(in);
-        } finally {
-            in.close();
         }
     }
 
@@ -73,11 +70,8 @@ public final class PublicSuffixMatcherLoader {
         if (file == null) {
             throw new IllegalArgumentException("File is null");
         }
-        final InputStream in = new FileInputStream(file);
-        try {
+        try (final InputStream in = new FileInputStream(file)) {
             return load(in);
-        } finally {
-            in.close();
         }
     }
 

http://git-wip-us.apache.org/repos/asf/cxf/blob/a79bb058/rt/wsdl/src/main/java/org/apache/cxf/wsdl/service/factory/ClassReader.java
----------------------------------------------------------------------
diff --git a/rt/wsdl/src/main/java/org/apache/cxf/wsdl/service/factory/ClassReader.java b/rt/wsdl/src/main/java/org/apache/cxf/wsdl/service/factory/ClassReader.java
index 2881623..52680c5 100644
--- a/rt/wsdl/src/main/java/org/apache/cxf/wsdl/service/factory/ClassReader.java
+++ b/rt/wsdl/src/main/java/org/apache/cxf/wsdl/service/factory/ClassReader.java
@@ -85,12 +85,11 @@ class ClassReader extends ByteArrayInputStream {
      * @throws IOException
      */
     protected static byte[] getBytes(Class<?> c) throws IOException {
-        InputStream fin = c.getResourceAsStream('/' + c.getName().replace('.', '/') + ".class");
-        if (fin == null) {
-            throw new IOException();
-        }
-        try {
-            ByteArrayOutputStream out = new ByteArrayOutputStream();
+        try (InputStream fin = c.getResourceAsStream('/' + c.getName().replace('.', '/')
+ ".class");
+            ByteArrayOutputStream out = new ByteArrayOutputStream()) {
+            if (fin == null) {
+                throw new IOException();
+            }
             byte[] buf = new byte[1024];
             int actual;
             do {
@@ -100,8 +99,6 @@ class ClassReader extends ByteArrayInputStream {
                 }
             } while (actual > 0);
             return out.toByteArray();
-        } finally {
-            fin.close();
         }
     }
 

http://git-wip-us.apache.org/repos/asf/cxf/blob/a79bb058/rt/wsdl/src/main/java/org/apache/cxf/wsdl/service/factory/ParamReader.java
----------------------------------------------------------------------
diff --git a/rt/wsdl/src/main/java/org/apache/cxf/wsdl/service/factory/ParamReader.java b/rt/wsdl/src/main/java/org/apache/cxf/wsdl/service/factory/ParamReader.java
index e0eac29..7b86b8e 100644
--- a/rt/wsdl/src/main/java/org/apache/cxf/wsdl/service/factory/ParamReader.java
+++ b/rt/wsdl/src/main/java/org/apache/cxf/wsdl/service/factory/ParamReader.java
@@ -127,14 +127,9 @@ class ParamReader extends ClassReader {
         }
 
         try {
-            // get a parameter reader
-            ParamReader pr = new ParamReader(c);
-            
             // get the parameter names
-            try {
+            try (ParamReader pr = new ParamReader(c)) {
                 return pr.getParameterNames(method);
-            } finally {
-                pr.close();
             }
         } catch (IOException e) {
             // log it and leave


Mime
View raw message