Skip to content

Commit 4025fd2

Browse files
committed
Merge pull request #72 from datastax/RUBY-116
[RUBY-116] fix thread leak on connection error
2 parents 2bf364d + 2ec256c commit 4025fd2

File tree

3 files changed

+7
-2
lines changed

3 files changed

+7
-2
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ Bug Fixes:
1212
* [RUBY-102] Allow custom types in schema metadata
1313
* [RUBY-97] Allow disabling of the initial population of schema metadata
1414
* [RUBY-95] Speed up generation of large token maps
15+
* [RUBY-116] fix thread leak on connection error
1516

1617
Breaking Changes:
1718

lib/cassandra.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -507,7 +507,7 @@ def self.cluster_async(options = {})
507507

508508
hosts.shuffle!
509509
rescue => e
510-
futures = options.fetch(:futures_factory) { Driver.new.futures_factory }
510+
futures = options.fetch(:futures_factory) { return Future::Error.new(e) }
511511
futures.error(e)
512512
else
513513
driver = Driver.new(options)

lib/cassandra/driver.rb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,11 @@ def connect(addresses)
145145
if f.resolved?
146146
promise.fulfill(cluster)
147147
else
148-
f.on_failure {|e| promise.break(e)}
148+
f.on_failure do |e|
149+
cluster.close_async.on_complete do |_, _|
150+
promise.break(e)
151+
end
152+
end
149153
end
150154
end
151155

0 commit comments

Comments
 (0)