Handle pre-options response errors correctly
This commit is contained in:
@@ -9,7 +9,7 @@ from cassandra.marshal import int8_unpack
|
|||||||
from cassandra.decoder import (ReadyMessage, AuthenticateMessage, OptionsMessage,
|
from cassandra.decoder import (ReadyMessage, AuthenticateMessage, OptionsMessage,
|
||||||
StartupMessage, ErrorMessage, CredentialsMessage,
|
StartupMessage, ErrorMessage, CredentialsMessage,
|
||||||
QueryMessage, ResultMessage, decode_response,
|
QueryMessage, ResultMessage, decode_response,
|
||||||
InvalidRequestException)
|
InvalidRequestException, SupportedMessage)
|
||||||
|
|
||||||
|
|
||||||
log = logging.getLogger(__name__)
|
log = logging.getLogger(__name__)
|
||||||
@@ -194,6 +194,11 @@ class Connection(object):
|
|||||||
def _handle_options_response(self, options_response):
|
def _handle_options_response(self, options_response):
|
||||||
if self.is_defunct:
|
if self.is_defunct:
|
||||||
return
|
return
|
||||||
|
|
||||||
|
if not isinstance(options_response, SupportedMessage):
|
||||||
|
log.error("Did not get expected SupportedMessage response; instead, got: %s", options_response)
|
||||||
|
return
|
||||||
|
|
||||||
log.debug("Received options response on new Connection from %s" % self.host)
|
log.debug("Received options response on new Connection from %s" % self.host)
|
||||||
self.supported_cql_versions = options_response.cql_versions
|
self.supported_cql_versions = options_response.cql_versions
|
||||||
self.remote_supported_compressions = options_response.options['COMPRESSION']
|
self.remote_supported_compressions = options_response.options['COMPRESSION']
|
||||||
|
|||||||
@@ -91,10 +91,7 @@ class LibevConnectionTest(unittest.TestCase):
|
|||||||
# make sure it errored correctly
|
# make sure it errored correctly
|
||||||
self.assertTrue(c.is_defunct)
|
self.assertTrue(c.is_defunct)
|
||||||
self.assertTrue(c.connected_event.is_set())
|
self.assertTrue(c.connected_event.is_set())
|
||||||
try:
|
|
||||||
self.assertTrue(isinstance(c.last_error, ProtocolError))
|
self.assertTrue(isinstance(c.last_error, ProtocolError))
|
||||||
except AssertionError:
|
|
||||||
self.assertTrue(isinstance(c.last_error, AttributeError))
|
|
||||||
|
|
||||||
def test_error_message_on_startup(self, *args):
|
def test_error_message_on_startup(self, *args):
|
||||||
c = self.make_connection()
|
c = self.make_connection()
|
||||||
|
|||||||
Reference in New Issue
Block a user