cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dbros...@apache.org
Subject git commit: make sure streams get closed
Date Mon, 05 Aug 2013 01:16:08 GMT
Updated Branches:
  refs/heads/trunk 25c9293f2 -> c552c29df


make sure streams get closed


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

Branch: refs/heads/trunk
Commit: c552c29dffc848dfb91216bf520d379b5a25e150
Parents: 25c9293
Author: Dave Brosius <dbrosius@apache.org>
Authored: Sun Aug 4 21:13:59 2013 -0400
Committer: Dave Brosius <dbrosius@apache.org>
Committed: Sun Aug 4 21:13:59 2013 -0400

----------------------------------------------------------------------
 src/java/org/apache/cassandra/locator/Ec2Snitch.java | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/c552c29d/src/java/org/apache/cassandra/locator/Ec2Snitch.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/locator/Ec2Snitch.java b/src/java/org/apache/cassandra/locator/Ec2Snitch.java
index 5dc8638..37301c1 100644
--- a/src/java/org/apache/cassandra/locator/Ec2Snitch.java
+++ b/src/java/org/apache/cassandra/locator/Ec2Snitch.java
@@ -26,14 +26,15 @@ import java.net.URL;
 import java.util.Map;
 
 import com.google.common.base.Charsets;
+
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
-
 import org.apache.cassandra.db.SystemKeyspace;
 import org.apache.cassandra.exceptions.ConfigurationException;
 import org.apache.cassandra.gms.ApplicationState;
 import org.apache.cassandra.gms.EndpointState;
 import org.apache.cassandra.gms.Gossiper;
+import org.apache.cassandra.io.util.FileUtils;
 import org.apache.cassandra.utils.FBUtilities;
 
 /**
@@ -71,6 +72,7 @@ public class Ec2Snitch extends AbstractNetworkTopologySnitch
     {
         // Populate the region and zone by introspection, fail if 404 on metadata
         HttpURLConnection conn = (HttpURLConnection) new URL(url).openConnection();
+        DataInputStream d = null;
         try
         {
             conn.setRequestMethod("GET");
@@ -80,12 +82,13 @@ public class Ec2Snitch extends AbstractNetworkTopologySnitch
             // Read the information. I wish I could say (String) conn.getContent() here...
             int cl = conn.getContentLength();
             byte[] b = new byte[cl];
-            DataInputStream d = new DataInputStream((FilterInputStream) conn.getContent());
+            d = new DataInputStream((FilterInputStream) conn.getContent());
             d.readFully(b);
             return new String(b, Charsets.UTF_8);
         }
         finally
         {
+            FileUtils.close(d);
             conn.disconnect();
         }
     }


Mime
View raw message