Skip to content

Commit 3980cd0

Browse files
authored
JAVA-2924: Consider protocol version unsupported when server requires USE_BETA flag for it (#1534)
1 parent e20f79c commit 3980cd0

File tree

3 files changed

+12
-8
lines changed

3 files changed

+12
-8
lines changed

changelog/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
- [improvement] JAVA-2705: Remove protocol v5 beta status, add v6-beta.
1111
- [bug] JAVA-2923: Detect and use Guava's new HostAndPort.getHost method.
1212
- [bug] JAVA-2922: Switch to modern framing format inside a channel handler.
13+
- [bug] JAVA-2924: Consider protocol version unsupported when server requires USE_BETA flag for it.
1314

1415
## 3.10.2
1516

driver-core/src/main/java/com/datastax/driver/core/Connection.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -572,7 +572,9 @@ private boolean isUnsupportedProtocolVersion(Responses.Error error) {
572572
// Testing for a specific string is a tad fragile but well, we don't have much choice
573573
// C* 2.1 reports a server error instead of protocol error, see CASSANDRA-9451
574574
return (error.code == ExceptionCode.PROTOCOL_ERROR || error.code == ExceptionCode.SERVER_ERROR)
575-
&& error.message.contains("Invalid or unsupported protocol version");
575+
&& (error.message.contains("Invalid or unsupported protocol version")
576+
// JAVA-2924: server is behind driver and considers the proposed version as beta
577+
|| error.message.contains("Beta version of the protocol used"));
576578
}
577579

578580
private UnsupportedProtocolVersionException unsupportedProtocolVersionException(

driver-core/src/test/java/com/datastax/driver/core/ProtocolVersionRenegotiationTest.java

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
package com.datastax.driver.core;
1717

1818
import static com.datastax.driver.core.ProtocolVersion.V1;
19-
import static com.datastax.driver.core.ProtocolVersion.V4;
19+
import static com.datastax.driver.core.ProtocolVersion.V5;
2020
import static com.datastax.driver.core.ProtocolVersion.V6;
2121
import static org.assertj.core.api.Assertions.assertThat;
2222

@@ -55,13 +55,14 @@ public void should_fail_when_version_provided_and_too_low_3_8_plus() throws Exce
5555
/** @jira_ticket JAVA-1367 */
5656
@Test(groups = "short")
5757
public void should_fail_when_version_provided_and_too_high() throws Exception {
58-
if (ccm().getCassandraVersion().compareTo(VersionNumber.parse("2.2")) >= 0) {
59-
throw new SkipException("Server supports protocol V4");
58+
if (ccm().getCassandraVersion().compareTo(VersionNumber.parse("3.10")) >= 0) {
59+
throw new SkipException("Server supports protocol V5");
6060
}
61-
UnsupportedProtocolVersionException e = connectWithUnsupportedVersion(V4);
62-
assertThat(e.getUnsupportedVersion()).isEqualTo(V4);
63-
// pre-CASSANDRA-11464: server replies with its own version
64-
assertThat(e.getServerVersion()).isEqualTo(protocolVersion);
61+
UnsupportedProtocolVersionException e = connectWithUnsupportedVersion(V5);
62+
assertThat(e.getUnsupportedVersion()).isEqualTo(V5);
63+
// see CASSANDRA-11464: for C* < 3.0.9 and 3.8, server replies with its own version;
64+
// otherwise it replies with the client's version.
65+
assertThat(e.getServerVersion()).isIn(V5, protocolVersion);
6566
}
6667

6768
/** @jira_ticket JAVA-1367 */

0 commit comments

Comments
 (0)