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, | ||||
|                                StartupMessage, ErrorMessage, CredentialsMessage, | ||||
|                                QueryMessage, ResultMessage, decode_response, | ||||
|                                InvalidRequestException) | ||||
|                                InvalidRequestException, SupportedMessage) | ||||
|  | ||||
|  | ||||
| log = logging.getLogger(__name__) | ||||
| @@ -194,6 +194,11 @@ class Connection(object): | ||||
|     def _handle_options_response(self, options_response): | ||||
|         if self.is_defunct: | ||||
|             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) | ||||
|         self.supported_cql_versions = options_response.cql_versions | ||||
|         self.remote_supported_compressions = options_response.options['COMPRESSION'] | ||||
|   | ||||
| @@ -91,10 +91,7 @@ class LibevConnectionTest(unittest.TestCase): | ||||
|         # make sure it errored correctly | ||||
|         self.assertTrue(c.is_defunct) | ||||
|         self.assertTrue(c.connected_event.is_set()) | ||||
|         try: | ||||
|             self.assertTrue(isinstance(c.last_error, ProtocolError)) | ||||
|         except AssertionError: | ||||
|             self.assertTrue(isinstance(c.last_error, AttributeError)) | ||||
|         self.assertTrue(isinstance(c.last_error, ProtocolError)) | ||||
|  | ||||
|     def test_error_message_on_startup(self, *args): | ||||
|         c = self.make_connection() | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Tyler Hobbs
					Tyler Hobbs