diff --git a/CHANGES.txt b/CHANGES.txt index ec32945e84..82348d5e03 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -1,5 +1,5 @@ 3.0.10 - * Fix potential socket leak (CASSANDRA-12329) + * Fix potential socket leak (CASSANDRA-12329, CASSANDRA-12330) * Fix ViewTest.testCompaction (CASSANDRA-12789) * Improve avg aggregate functions (CASSANDRA-12417) * Preserve quoted reserved keyword column names in MV creation (CASSANDRA-11803) diff --git a/src/java/org/apache/cassandra/streaming/DefaultConnectionFactory.java b/src/java/org/apache/cassandra/streaming/DefaultConnectionFactory.java index 5c27ff3465..77ee0f1f00 100644 --- a/src/java/org/apache/cassandra/streaming/DefaultConnectionFactory.java +++ b/src/java/org/apache/cassandra/streaming/DefaultConnectionFactory.java @@ -47,15 +47,24 @@ public class DefaultConnectionFactory implements StreamConnectionFactory int attempts = 0; while (true) { + Socket socket = null; try { - Socket socket = OutboundTcpConnectionPool.newSocket(peer); + socket = OutboundTcpConnectionPool.newSocket(peer); socket.setSoTimeout(DatabaseDescriptor.getStreamingSocketTimeout()); socket.setKeepAlive(true); return socket; } catch (IOException e) { + if (socket != null) + { + try + { + socket.close(); + } + catch (IOException ignore) {} + } if (++attempts >= MAX_CONNECT_ATTEMPTS) throw e;