Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Ensure we can disconnect! without exception even if we aren't connect…

…ed. This allows you to sanely

do an ensure connection.disconnect! if you may or may not have an established connection.
(cherry picked from commit 30a26e8)
  • Loading branch information...
commit d6ad77294153ed42ccd971191afc37017e8371a0 1 parent 228e4c2
Marc Slemko authored
Showing with 11 additions and 2 deletions.
  1. +4 −2 lib/cassandra/cassandra.rb
  2. +7 −0 test/cassandra_test.rb
View
6 lib/cassandra/cassandra.rb
@@ -84,8 +84,10 @@ def disable_node_auto_discovery!
end
def disconnect!
- @client.disconnect!
- @client = nil
+ if @client
+ @client.disconnect!
+ @client = nil
+ end
end
def keyspaces
View
7 test/cassandra_test.rb
@@ -413,6 +413,13 @@ def test_disconnect!
assert_nil @twitter.instance_variable_get(:@client)
end
+ def test_disconnect_when_not_connected!
+ assert_nothing_raised do
+ @twitter = Cassandra.new('Twitter', "127.0.0.1:9160", :retries => 2, :exception_classes => [])
+ @twitter.disconnect!
+ end
+ end
+
def test_super_allows_for_non_string_values_while_normal_does_not
columns = {'user_timelines' => {@uuids[4] => '4', @uuids[5] => '5'}}
Please sign in to comment.
Something went wrong with that request. Please try again.