Skip to content

Commit 477ad22

Browse files
authored
Downgrade conn for C* connections with versions beyond what we support (#379)
Fix for https://datastax-oss.atlassian.net/browse/NODEJS-634
1 parent ef0e676 commit 477ad22

File tree

2 files changed

+20
-4
lines changed

2 files changed

+20
-4
lines changed

lib/connection.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -254,8 +254,12 @@ class Connection extends events.EventEmitter {
254254

255255
if (lowerVersion === self.protocolVersion) {
256256
lowerVersion = types.protocolVersion.getLowerSupported(self.protocolVersion);
257-
} else if (types.protocolVersion.isBeta(self.protocol.version)) {
258-
// Avoid downgrading the protocol version to a BETA protocol
257+
} else if (!types.protocolVersion.isSupported(self.protocol.version)) {
258+
// If we have an unsupported protocol version or a beta version we need to switch
259+
// to something we can support. Note that dseV1 and dseV2 are excluded from this
260+
// logic as they are supported. Also note that any v5 and greater beta protocols
261+
// are included here since the beta flag was introduced in v5.
262+
self.log('info',`Protocol version ${self.protocol.version} not supported by this driver, downgrading`);
259263
lowerVersion = types.protocolVersion.getLowerSupported(self.protocol.version);
260264
}
261265

lib/types/protocol-version.js

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ const protocolVersion = {
4949
v3: 0x03,
5050
v4: 0x04,
5151
v5: 0x05,
52+
v6: 0x06,
5253
dseV1: 0x41,
5354
dseV2: 0x42,
5455
maxSupported: 0x42,
@@ -64,14 +65,25 @@ const protocolVersion = {
6465
return ((version >= this.dseV1 && version <= this.dseV2));
6566
},
6667
/**
67-
* Determines whether the protocol protocol version is supported by this driver.
68+
* Returns true if the protocol version represents a version of Cassandra
69+
* supported by this driver, false otherwise
70+
* @param {Number} version
71+
* @returns {Boolean}
72+
* @ignore
73+
*/
74+
isSupportedCassandra: function(version) {
75+
return (version <= 0x04 && version >= 0x01);
76+
},
77+
/**
78+
* Determines whether the protocol version is supported by this driver.
6879
* @param {Number} version
6980
* @returns {Boolean}
7081
* @ignore
7182
*/
7283
isSupported: function (version) {
73-
return (this.isDse(version) || (version <= 0x04 && version >= 0x01));
84+
return (this.isDse(version) || this.isSupportedCassandra(version));
7485
},
86+
7587
/**
7688
* Determines whether the protocol includes flags for PREPARE messages.
7789
* @param {Number} version

0 commit comments

Comments
 (0)