From 98f4f261e7f14826978a08574c24433e1665fe2f Mon Sep 17 00:00:00 2001 From: Mikita Hradovich Date: Thu, 6 Nov 2025 21:31:03 +0100 Subject: [PATCH] [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 --- bom/pom.xml | 2 +- .../driver/core/cql/PreparedStatementIT.java | 33 +++++++++++++++++++ 2 files changed, 34 insertions(+), 1 deletion(-) diff --git a/bom/pom.xml b/bom/pom.xml index 0820c46f02c..72c4527de52 100644 --- a/bom/pom.xml +++ b/bom/pom.xml @@ -83,7 +83,7 @@ com.scylladb native-protocol - 1.5.2.0 + 1.5.2.1 diff --git a/integration-tests/src/test/java/com/datastax/oss/driver/core/cql/PreparedStatementIT.java b/integration-tests/src/test/java/com/datastax/oss/driver/core/cql/PreparedStatementIT.java index dbf6ceb7dd5..2af5141c870 100644 --- a/integration-tests/src/test/java/com/datastax/oss/driver/core/cql/PreparedStatementIT.java +++ b/integration-tests/src/test/java/com/datastax/oss/driver/core/cql/PreparedStatementIT.java @@ -44,6 +44,7 @@ import com.datastax.oss.driver.api.core.metrics.DefaultSessionMetric; import com.datastax.oss.driver.api.core.servererrors.InvalidQueryException; import com.datastax.oss.driver.api.core.type.DataTypes; +import com.datastax.oss.driver.api.testinfra.ScyllaOnly; import com.datastax.oss.driver.api.testinfra.ccm.CcmBridge; import com.datastax.oss.driver.api.testinfra.ccm.CcmRule; 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 assertThat(boundStatement.getRoutingKey()).isNull(); } + /** + * Verifies driver behavior when a prepared statement is created on a node that does not support + * the metadata ID feature, but later executed on a node that does. In this scenario, the metadata + * ID is {@code null}, yet the feature flag is enabled. The test ensures that such a mixed-node + * situation is handled gracefully without errors. + */ + @Test + @ScyllaOnly + @SuppressWarnings("ConstantConditions") + public void should_handle_empty_metadata_id_when_executing_statement_when_supported() { + // given + CqlSession session = sessionRule.session(); + PreparedStatement preparedStatement = + session.prepare("SELECT * FROM prepared_statement_test WHERE a = ?"); + if (hasNoScyllaMetadataIdSupport()) { + assertThat(preparedStatement.getResultMetadataId()).isNull(); + } else { + assertThat(preparedStatement.getResultMetadataId()).isNotNull(); + preparedStatement.setResultMetadata(null, preparedStatement.getResultSetDefinitions()); + } + + // when + session.execute(preparedStatement.bind(1)); + + // then + if (hasNoScyllaMetadataIdSupport()) { + assertThat(preparedStatement.getResultMetadataId()).isNull(); + } else { + assertThat(preparedStatement.getResultMetadataId()).isNotNull(); + } + } + private static Iterable firstPageOf(CompletionStage stage) { return CompletableFutures.getUninterruptibly(stage).currentPage(); }