Skip to content

Commit c20380b

Browse files
nikagradkropachev
andcommitted
[java-driver#756] Handle empty metadataid when metadataid feature is on.
- Updating `native-protocol` to `1.5.2.1` (includes empty `resultMetadataId` fix). - Adding integration test covering the case. Co-authored-by: Dmitry Kropachev <[email protected]>
1 parent aa8545d commit c20380b

File tree

2 files changed

+34
-1
lines changed

2 files changed

+34
-1
lines changed

bom/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@
8383
<dependency>
8484
<groupId>com.scylladb</groupId>
8585
<artifactId>native-protocol</artifactId>
86-
<version>1.5.2.0</version>
86+
<version>1.5.2.1</version>
8787
</dependency>
8888
</dependencies>
8989
</dependencyManagement>

integration-tests/src/test/java/com/datastax/oss/driver/core/cql/PreparedStatementIT.java

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
import com.datastax.oss.driver.api.core.metrics.DefaultSessionMetric;
4545
import com.datastax.oss.driver.api.core.servererrors.InvalidQueryException;
4646
import com.datastax.oss.driver.api.core.type.DataTypes;
47+
import com.datastax.oss.driver.api.testinfra.ScyllaOnly;
4748
import com.datastax.oss.driver.api.testinfra.ccm.CcmBridge;
4849
import com.datastax.oss.driver.api.testinfra.ccm.CcmRule;
4950
import com.datastax.oss.driver.api.testinfra.requirement.BackendRequirement;
@@ -681,6 +682,38 @@ private void should_return_null_routing_information_when_single_partition_key_is
681682
assertThat(boundStatement.getRoutingKey()).isNull();
682683
}
683684

685+
/**
686+
* Verifies driver behavior when a prepared statement is created on a node that does not support
687+
* the metadata ID feature, but later executed on a node that does. In this scenario, the metadata
688+
* ID is {@code null}, yet the feature flag is enabled. The test ensures that such a mixed-node
689+
* situation is handled gracefully without errors.
690+
*/
691+
@Test
692+
@ScyllaOnly
693+
@SuppressWarnings("ConstantConditions")
694+
public void should_handle_empty_metadata_id_when_executing_statement_when_supported() {
695+
// given
696+
CqlSession session = sessionRule.session();
697+
PreparedStatement preparedStatement =
698+
session.prepare("SELECT * FROM prepared_statement_test WHERE a = ?");
699+
if (hasNoScyllaMetadataIdSupport()) {
700+
assertThat(preparedStatement.getResultMetadataId()).isNull();
701+
} else {
702+
assertThat(preparedStatement.getResultMetadataId()).isNotNull();
703+
preparedStatement.setResultMetadata(null, preparedStatement.getResultSetDefinitions());
704+
}
705+
706+
// when
707+
session.execute(preparedStatement.bind(1));
708+
709+
// then
710+
if (hasNoScyllaMetadataIdSupport()) {
711+
assertThat(preparedStatement.getResultMetadataId()).isNull();
712+
} else {
713+
assertThat(preparedStatement.getResultMetadataId()).isNotNull();
714+
}
715+
}
716+
684717
private static Iterable<Row> firstPageOf(CompletionStage<AsyncResultSet> stage) {
685718
return CompletableFutures.getUninterruptibly(stage).currentPage();
686719
}

0 commit comments

Comments
 (0)