You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nifi.apache.org by tk...@apache.org on 2015/11/09 05:27:20 UTC

[46/50] [abbrv] nifi git commit: NIFI-1073 a couple closes that are probably noops as they were implemented

NIFI-1073 a couple closes that are probably noops as they were implemented


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

Branch: refs/heads/NIFI-1073
Commit: 4e8e2d09e3fdb169f9d4f2c42ffae9562a1e9afa
Parents: e44e89c
Author: Tony Kurc <tr...@gmail.com>
Authored: Mon Oct 26 21:56:12 2015 -0400
Committer: Tony Kurc <tr...@gmail.com>
Committed: Sun Nov 8 21:11:34 2015 -0500

----------------------------------------------------------------------
 .../cluster/manager/impl/WebClusterManager.java  | 14 ++++++++------
 .../org/apache/nifi/web/server/JettyServer.java  | 19 ++++++++++++-------
 2 files changed, 20 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/nifi/blob/4e8e2d09/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/manager/impl/WebClusterManager.java
----------------------------------------------------------------------
diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/manager/impl/WebClusterManager.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/manager/impl/WebClusterManager.java
index 8d246c1..01f11b1 100644
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/manager/impl/WebClusterManager.java
+++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/manager/impl/WebClusterManager.java
@@ -189,6 +189,7 @@ import org.apache.nifi.util.FormatUtils;
 import org.apache.nifi.util.NiFiProperties;
 import org.apache.nifi.util.ObjectHolder;
 import org.apache.nifi.util.ReflectionUtils;
+import org.apache.nifi.util.file.FileUtils;
 import org.apache.nifi.web.OptimisticLockingManager;
 import org.apache.nifi.web.Revision;
 import org.apache.nifi.web.UpdateRevision;
@@ -3401,15 +3402,16 @@ public class WebClusterManager implements HttpClusterManager, ProtocolHandler, C
                 completionService.submit(new Runnable() {
                     @Override
                     public void run() {
+                        final OutputStream drain = new OutputStream() {
+                            @Override
+                            public void write(final int b) { /* drain response */ }
+                        };
                         try {
-                            ((StreamingOutput) nodeResponse.getResponse().getEntity()).write(
-                                    new OutputStream() {
-                                        @Override
-                                        public void write(final int b) { /* drain response */ }
-                                    }
-                            );
+                            ((StreamingOutput) nodeResponse.getResponse().getEntity()).write(drain);
                         } catch (final IOException | WebApplicationException ex) {
                             logger.info("Failed clearing out non-client response buffer due to: " + ex, ex);
+                        } finally {
+                            FileUtils.closeQuietly(drain);
                         }
                     }
                 }, null);

http://git-wip-us.apache.org/repos/asf/nifi/blob/4e8e2d09/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-jetty/src/main/java/org/apache/nifi/web/server/JettyServer.java
----------------------------------------------------------------------
diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-jetty/src/main/java/org/apache/nifi/web/server/JettyServer.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-jetty/src/main/java/org/apache/nifi/web/server/JettyServer.java
index 99c11a8..73cf7c5 100644
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-jetty/src/main/java/org/apache/nifi/web/server/JettyServer.java
+++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-jetty/src/main/java/org/apache/nifi/web/server/JettyServer.java
@@ -38,8 +38,10 @@ import java.util.Map;
 import java.util.Set;
 import java.util.jar.JarEntry;
 import java.util.jar.JarFile;
+
 import javax.servlet.DispatcherType;
 import javax.servlet.ServletContext;
+
 import org.apache.nifi.NiFiServer;
 import org.apache.nifi.controller.FlowSerializationException;
 import org.apache.nifi.controller.FlowSynchronizationException;
@@ -49,6 +51,7 @@ import org.apache.nifi.nar.ExtensionMapping;
 import org.apache.nifi.nar.NarClassLoaders;
 import org.apache.nifi.services.FlowService;
 import org.apache.nifi.util.NiFiProperties;
+import org.apache.nifi.util.file.FileUtils;
 import org.apache.nifi.web.NiFiWebContext;
 import org.apache.commons.collections4.CollectionUtils;
 import org.apache.commons.lang3.StringUtils;
@@ -438,6 +441,7 @@ public class JettyServer implements NiFiServer {
     private List<String> getWarExtensions(final File war, final String path) {
         List<String> processorTypes = new ArrayList<>();
         JarFile jarFile = null;
+        BufferedReader in = null;
         try {
             // load the jar file and attempt to find the nifi-processor entry
             jarFile = new JarFile(war);
@@ -446,7 +450,7 @@ public class JettyServer implements NiFiServer {
             // ensure the nifi-processor entry was found
             if (jarEntry != null) {
                 // get an input stream for the nifi-processor configuration file
-                BufferedReader in = new BufferedReader(new InputStreamReader(jarFile.getInputStream(jarEntry)));
+                in = new BufferedReader(new InputStreamReader(jarFile.getInputStream(jarEntry)));
 
                 // read in each configured type
                 String rawProcessorType;
@@ -461,12 +465,13 @@ public class JettyServer implements NiFiServer {
         } catch (IOException ioe) {
             logger.warn(String.format("Unable to inspect %s for a custom processor UI.", war));
         } finally {
-            try {
-                // close the jar file - which closes all input streams obtained via getInputStream above
-                if (jarFile != null) {
-                    jarFile.close();
-                }
-            } catch (IOException ioe) {
+            // close the jar file - which closes all input streams obtained via getInputStream above
+            if (jarFile != null) {
+                FileUtils.closeQuietly(jarFile);
+            }
+            // close the BufferedReader, this may not be strictly necessary
+            if (in != null){
+                FileUtils.closeQuietly(in);
             }
         }