Repository: incubator-slider
Updated Branches:
  refs/heads/develop 6de357cc8 -> 2f63856e7


SLIDER-1152 Resource leaks found in code


Project: http://git-wip-us.apache.org/repos/asf/incubator-slider/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-slider/commit/2f63856e
Tree: http://git-wip-us.apache.org/repos/asf/incubator-slider/tree/2f63856e
Diff: http://git-wip-us.apache.org/repos/asf/incubator-slider/diff/2f63856e

Branch: refs/heads/develop
Commit: 2f63856e7bfb373c3b9503c8978e143d2235efee
Parents: 6de357c
Author: Gour Saha <gourks...@apache.org>
Authored: Tue Jul 12 15:13:08 2016 -0700
Committer: Gour Saha <gourks...@apache.org>
Committed: Tue Jul 12 15:13:08 2016 -0700

----------------------------------------------------------------------
 .../java/org/apache/slider/api/proto/RestTypeMarshalling.java  | 6 +++++-
 .../src/main/java/org/apache/slider/client/SliderClient.java   | 6 +++++-
 2 files changed, 10 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/2f63856e/slider-core/src/main/java/org/apache/slider/api/proto/RestTypeMarshalling.java
----------------------------------------------------------------------
diff --git 
a/slider-core/src/main/java/org/apache/slider/api/proto/RestTypeMarshalling.java
 
b/slider-core/src/main/java/org/apache/slider/api/proto/RestTypeMarshalling.java
index feebe1d..766ee83 100644
--- 
a/slider-core/src/main/java/org/apache/slider/api/proto/RestTypeMarshalling.java
+++ 
b/slider-core/src/main/java/org/apache/slider/api/proto/RestTypeMarshalling.java
@@ -109,7 +109,11 @@ public class RestTypeMarshalling {
   private static byte[] getStoreBytes(SecurityStore securityStore)
       throws IOException {
     InputStream is = new FileInputStream(securityStore.getFile());
-    return IOUtils.toByteArray(is);
+    byte[] storeBytes = IOUtils.toByteArray(is);
+    if (is != null) {
+      is.close();
+    }
+    return storeBytes;
   }
 
   public static byte[] unmarshall(Messages.GetCertificateStoreResponseProto 
response) {

http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/2f63856e/slider-core/src/main/java/org/apache/slider/client/SliderClient.java
----------------------------------------------------------------------
diff --git 
a/slider-core/src/main/java/org/apache/slider/client/SliderClient.java 
b/slider-core/src/main/java/org/apache/slider/client/SliderClient.java
index dd90e46..7ef3168 100644
--- a/slider-core/src/main/java/org/apache/slider/client/SliderClient.java
+++ b/slider-core/src/main/java/org/apache/slider/client/SliderClient.java
@@ -1181,7 +1181,11 @@ public class SliderClient extends 
AbstractSliderLaunchedService implements RunSe
     byte[] keystore = createClusterOperations(clientInfo.name)
         .getClientCertificateStore(hostname, "client", password, type.name());
     // persist to file
-    IOUtils.write(keystore, new FileOutputStream(storeFile));
+    FileOutputStream storeFileOutputStream = new FileOutputStream(storeFile);
+    IOUtils.write(keystore, storeFileOutputStream);
+    if (storeFileOutputStream != null) {
+      storeFileOutputStream.close();
+    }
 
     return EXIT_SUCCESS;
   }

Reply via email to