kikocis/java-driver public
Changesets · Branches · Tags · Compare
| Changeset | 663134961b64738fc9733ac2cde9b0d21531d55a45be8290f9fea4adccf69505 |
|---|---|
| Author | olim7t <omichallat+github@gmail.com> · 2016-03-24 18:38 +01:00 |
| Committer | olim7t <omichallat+github@gmail.com> · 2016-04-26 15:25 +02:00 |
| Parents | b5b377402941 |
3 files changed
modified changelog/README.md +1 −0
| @@ -14,6 +14,7 @@ | ||
| 14 | 14 | - [bug] JAVA-1140: Use same connection to check for schema agreement after a DDL query. |
| 15 | 15 | - [improvement] JAVA-1113: Support Cassandra 3.4 LIKE operator in QueryBuilder. |
| 16 | 16 | - [improvement] JAVA-1086: Support Cassandra 3.2 CAST function in QueryBuilder. |
| 17 | +- [bug] JAVA-1095: Check protocol version for custom payload before sending the query. | |
| 17 | 18 | |
| 18 | 19 | Merged from 2.1 branch: |
| 19 | 20 |
modified driver-core/src/main/java/com/datastax/driver/core/SessionManager.java +3 −0
| @@ -502,6 +502,9 @@ | ||
| 502 | 502 | } else if (serialConsistency == null) |
| 503 | 503 | serialConsistency = configuration().getQueryOptions().getSerialConsistencyLevel(); |
| 504 | 504 | |
| 505 | + if (statement.getOutgoingPayload() != null && protocolVersion.compareTo(ProtocolVersion.V4) < 0) | |
| 506 | + throw new UnsupportedFeatureException(protocolVersion, "Custom payloads are only supported since native protocol V4"); | |
| 507 | + | |
| 505 | 508 | long defaultTimestamp = Long.MIN_VALUE; |
| 506 | 509 | if (protocolVersion.compareTo(ProtocolVersion.V3) >= 0) { |
| 507 | 510 | defaultTimestamp = statement.getDefaultTimestamp(); |
modified driver-core/src/test/java/com/datastax/driver/core/CustomPayloadTest.java +3 −14
| @@ -15,13 +15,10 @@ | ||
| 15 | 15 | */ |
| 16 | 16 | package com.datastax.driver.core; |
| 17 | 17 | |
| 18 | -import com.datastax.driver.core.exceptions.NoHostAvailableException; | |
| 19 | 18 | import com.datastax.driver.core.exceptions.UnsupportedFeatureException; |
| 20 | 19 | import com.datastax.driver.core.utils.CassandraVersion; |
| 21 | -import com.google.common.base.Throwables; | |
| 22 | 20 | import com.google.common.collect.ImmutableMap; |
| 23 | 21 | import org.apache.log4j.Logger; |
| 24 | -import org.assertj.core.api.iterable.Extractor; | |
| 25 | 22 | import org.testng.annotations.BeforeMethod; |
| 26 | 23 | import org.testng.annotations.Test; |
| 27 | 24 | |
| @@ -246,17 +243,9 @@ | ||
| 246 | 243 | statement.setOutgoingPayload(payload1); |
| 247 | 244 | v3session.execute(statement); |
| 248 | 245 | fail("Should not send custom payloads with protocol V3"); |
| 249 | - } catch (NoHostAvailableException nhae) { | |
| 250 | - assertThat(nhae.getErrors().values()) | |
| 251 | - .extracting(new Extractor<Throwable, Throwable>() { | |
| 252 | - @Override | |
| 253 | - public Throwable extract(Throwable input) { | |
| 254 | - return Throwables.getRootCause(input); | |
| 255 | - } | |
| 256 | - }) | |
| 257 | - .hasOnlyElementsOfType(UnsupportedFeatureException.class) | |
| 258 | - .extracting("message") | |
| 259 | - .containsOnly("Unsupported feature with the native protocol V3 (which is currently in use): Custom payloads are only supported since native protocol V4"); | |
| 246 | + } catch (UnsupportedFeatureException e) { | |
| 247 | + assertThat(e.getMessage()).isEqualTo( | |
| 248 | + "Unsupported feature with the native protocol V3 (which is currently in use): Custom payloads are only supported since native protocol V4"); | |
| 260 | 249 | } |
| 261 | 250 | } |
| 262 | 251 |