Skip to content

Conversation

@arvy
Copy link

@arvy arvy commented Dec 10, 2025

Description

adds a new parameter to facilitate connecting to Astra DB

Motivation and Context

Ability to query data in Astra DB

Impact

none

Test Plan

Unit test: used mocked Cluster.Builder to verify parameter is handled properly.
Functional test (manual): verified ability to query data in Astra DB via presto-cli

Contributor checklist

  • Please make sure your submission complies with our contributing guide, in particular code style and commit standards.
  • PR description addresses the issue accurately and concisely. If the change is non-trivial, a GitHub Issue is referenced.
  • Documented new properties (with its default value), SQL syntax, functions, or other functionality.
  • If release notes are required, they follow the release notes guidelines.
  • Adequate tests were added if applicable.
  • CI passed.
  • If adding new dependencies, verified they have an OpenSSF Scorecard score of 5.0 or higher (or obtained explicit TSC approval for lower scores).

Release Notes

Please follow release notes guidelines and fill in the release notes below.

== RELEASE NOTES ==

Cassandra Connector Changes
* adds support for Astra DB (via new configuration property ``cassandra.astra-secure-connect-bundle-path``)

@arvy arvy requested a review from a team as a code owner December 10, 2025 06:03
@sourcery-ai
Copy link
Contributor

sourcery-ai bot commented Dec 10, 2025

Reviewer's Guide

Adds Astra DB support to the Cassandra connector by introducing a new configuration property for secure connect bundles, updating session creation to handle either contact points or Astra bundles, and adding focused tests and dependencies to validate the new behavior.

Sequence diagram for Cassandra session creation with Astra DB support

sequenceDiagram
    participant Connector as CassandraConnector
    participant Module as CassandraClientModule
    participant Config as CassandraClientConfig
    participant Builder as Cluster_Builder
    participant Cluster as Cluster
    participant Session as NativeCassandraSession
    participant RCluster as ReopeningCluster

    Connector->>Module: createCassandraSession(connectorId, config, extraColumnMetadataCodec)
    Module->>Cluster: builder()
    Cluster-->>Module: Builder
    Module->>Builder: withProtocolVersion(config.getProtocolVersion())
    Module->>Config: getAstraSecureConnectBundlePath()
    Config-->>Module: astraSecureConnectBundlePath

    alt astraSecureConnectBundlePath is null
        Module->>Config: getContactPoints()
        Config-->>Module: contactPoints
        Module->>Module: check contactPoints not empty
        loop for each contactPoint
            Module->>Builder: addContactPoint(contactPoint)
        end
    else astraSecureConnectBundlePath is set
        Module->>Module: assert contactPoints is null or empty
        Module->>Builder: withCloudSecureConnectBundle(File(astraSecureConnectBundlePath))
    end

    Module->>Builder: withPort(config.getNativeProtocolPort())
    Module->>Builder: withReconnectionPolicy(ExponentialReconnectionPolicy)
    Module->>Builder: withRetryPolicy(config.getRetryPolicy().getPolicy())
    Module->>Builder: withLoadBalancingPolicy(RoundRobinPolicy or DCAwareRoundRobinPolicy)
    Module->>Builder: withQueryOptions(QueryOptions)
    Module->>Builder: build()
    Builder-->>Module: Cluster

    Module->>RCluster: new ReopeningCluster(() -> Cluster)
    Module->>Session: new NativeCassandraSession(connectorId, extraColumnMetadataCodec, RCluster, noHostAvailableRetryTimeout, caseSensitiveNameMatchingEnabled)
    Module-->>Connector: CassandraSession
Loading

Class diagram for updated Cassandra client configuration and session creation

classDiagram
    class CassandraClientConfig {
        - ConsistencyLevel consistencyLevel
        - int fetchSize
        - List~String~ contactPoints
        - String astraSecureConnectBundlePath
        - int nativeProtocolPort
        - int partitionSizeForBatchSelect
        - int splitSize
        - boolean caseSensitiveNameMatchingEnabled
        + List~String~ getContactPoints()
        + CassandraClientConfig setContactPoints(String contactPoints)
        + String getAstraSecureConnectBundlePath()
        + setAstraSecureConnectBundlePath(String astraSecureConnectBundlePath)
        + int getNativeProtocolPort()
    }

    class CassandraClientModule {
        + configure(Binder binder)
        + createCassandraSession(CassandraConnectorId connectorId, CassandraClientConfig config, JsonCodec extraColumnMetadataCodec) CassandraSession
        + createCassandraSession(ClusterBuilder clusterBuilder, CassandraConnectorId connectorId, CassandraClientConfig config, JsonCodec extraColumnMetadataCodec) CassandraSession
    }

    class CassandraSession {
    }

    class NativeCassandraSession {
        + NativeCassandraSession(String connectorId, JsonCodec extraColumnMetadataCodec, ReopeningCluster reopeningCluster, Duration noHostAvailableRetryTimeout, boolean caseSensitiveNameMatchingEnabled)
    }

    class ReopeningCluster {
        + ReopeningCluster(ClusterFactory clusterFactory)
    }

    class Cluster {
        + static ClusterBuilder builder()
    }

    class ClusterBuilder {
        + ClusterBuilder withProtocolVersion(ProtocolVersion protocolVersion)
        + ClusterBuilder addContactPoint(String contactPoint)
        + ClusterBuilder withCloudSecureConnectBundle(File secureConnectBundle)
        + ClusterBuilder withPort(int port)
        + ClusterBuilder withReconnectionPolicy(ReconnectionPolicy policy)
        + ClusterBuilder withRetryPolicy(RetryPolicy policy)
        + ClusterBuilder withLoadBalancingPolicy(LoadBalancingPolicy policy)
        + ClusterBuilder withQueryOptions(QueryOptions options)
        + Cluster build()
    }

    CassandraClientModule --> CassandraClientConfig : uses
    CassandraClientModule --> CassandraSession : creates
    CassandraClientModule --> NativeCassandraSession : instantiates
    CassandraClientModule --> ReopeningCluster : wraps Cluster
    CassandraClientModule --> ClusterBuilder : configures
    CassandraClientConfig --> ClusterBuilder : provides connection configuration
    NativeCassandraSession --> ReopeningCluster : depends on
    ReopeningCluster --> Cluster : builds
Loading

File-Level Changes

Change Details Files
Extend Cassandra session creation to support Astra secure connect bundle configuration in addition to traditional contact points, with mutual exclusivity validation.
  • Refactor createCassandraSession to introduce an overload that accepts a Cluster.Builder, delegating from the original method
  • Configure Cluster.Builder with protocol version, reconnection and retry policies, and load balancing as before, but conditionally add contact points only when no Astra secure connect bundle path is configured
  • Add validation to prohibit simultaneous use of contact points and Astra secure connect bundle path
  • Use withCloudSecureConnectBundle when an Astra secure connect bundle path is provided
  • Build the Cluster once and pass it to ReopeningCluster instead of re-adding contact points on reopen
presto-cassandra/src/main/java/com/facebook/presto/cassandra/CassandraClientModule.java
Introduce Astra secure connect bundle configuration to Cassandra client configuration.
  • Add astraSecureConnectBundlePath field and corresponding getter
  • Add @config("cassandra.astra-secure-connect-bundle-path") setter to bind the new configuration property
  • Remove @SiZe(min = 1) constraint from contactPoints to allow empty contact points when using Astra bundles
presto-cassandra/src/main/java/com/facebook/presto/cassandra/CassandraClientConfig.java
Add unit tests for Astra bundle vs contact point behavior and supporting test dependencies.
  • Add Mockito core and inline dependencies to the Cassandra module pom for testing
  • Introduce CassandraClientModuleTest to verify: contact-points-only mode adds all contact points; specifying both contact points and Astra bundle throws IllegalArgumentException; Astra-bundle-only mode invokes withCloudSecureConnectBundle
  • Mock Cluster.Builder with RETURNS_SELF to support fluent API verification
presto-cassandra/pom.xml
presto-cassandra/src/test/java/com/facebook/presto/cassandra/CassandraClientModuleTest.java
Update embedded Cassandra test container version.
  • Bump Cassandra Docker image in CassandraServer test helper from 2.1.16 to 3.11.19
presto-cassandra/src/test/java/com/facebook/presto/cassandra/CassandraServer.java

Possibly linked issues


Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@linux-foundation-easycla
Copy link

linux-foundation-easycla bot commented Dec 10, 2025

CLA Missing ID CLA Not Signed

Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey there - I've reviewed your changes and found some issues that need to be addressed.

  • The change from creating a new Cluster inside ReopeningCluster to building it once and reusing the same instance (new ReopeningCluster(() -> cluster)) appears to alter the original semantics around reconnect/reopen and may break scenarios that relied on a fresh Cluster being created on each reopen; consider preserving the lazy-rebuild behavior while still allowing the builder to be injected for tests.
  • The checkArgument guarding simultaneous use of contact points and the Astra secure connect bundle is hard to read due to the negated compound condition; consider rewriting it in a positive, simpler form (e.g., checkArgument(!(hasBundle && hasContactPoints), ...) or extracting helpers) to make the intent clearer.
  • The tests add both mockito-core and mockito-inline with explicit versions to the module POM, which may be unnecessary and could conflict with the parent dependency management; if inline mocking is not required, prefer using only the existing/mockito dependency aligned with the project’s BOM.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- The change from creating a new `Cluster` inside `ReopeningCluster` to building it once and reusing the same instance (`new ReopeningCluster(() -> cluster)`) appears to alter the original semantics around reconnect/reopen and may break scenarios that relied on a fresh `Cluster` being created on each reopen; consider preserving the lazy-rebuild behavior while still allowing the builder to be injected for tests.
- The `checkArgument` guarding simultaneous use of contact points and the Astra secure connect bundle is hard to read due to the negated compound condition; consider rewriting it in a positive, simpler form (e.g., `checkArgument(!(hasBundle && hasContactPoints), ...)` or extracting helpers) to make the intent clearer.
- The tests add both `mockito-core` and `mockito-inline` with explicit versions to the module POM, which may be unnecessary and could conflict with the parent dependency management; if inline mocking is not required, prefer using only the existing/mockito dependency aligned with the project’s BOM.

## Individual Comments

### Comment 1
<location> `presto-cassandra/src/main/java/com/facebook/presto/cassandra/CassandraClientModule.java:170-175` </location>
<code_context>
                     config.getSpeculativeExecutionLimit())); // maximum number of executions
         }

+        Cluster cluster = clusterBuilder.build();
+
         return new NativeCassandraSession(
                 connectorId.toString(),
                 extraColumnMetadataCodec,
-                new ReopeningCluster(() -> {
-                    contactPoints.forEach(clusterBuilder::addContactPoint);
-                    return clusterBuilder.build();
-                }),
+                new ReopeningCluster(() -> cluster ),
                 config.getNoHostAvailableRetryTimeout(), config.isCaseSensitiveNameMatchingEnabled());
     }
</code_context>

<issue_to_address>
**issue (bug_risk):** ReopeningCluster now reuses a single Cluster instance instead of recreating it, which likely breaks the reopening behavior.

The original supplier rebuilt the `Cluster` (and re-added contact points) on each invocation, while the new version always returns the same pre-built `cluster` instance. After that instance is closed, `ReopeningCluster` will keep returning a closed `Cluster`, breaking the reopening behavior and likely causing runtime errors. The supplier should instead construct a new `Cluster` on each call (with the necessary configuration) or otherwise guarantee it never returns a previously closed instance.
</issue_to_address>

### Comment 2
<location> `presto-cassandra/src/test/java/com/facebook/presto/cassandra/CassandraClientModuleTest.java:50-51` </location>
<code_context>
+        mockExtraColumnMetadataCodec = Mockito.mock(JsonCodec.class);
+    }
+
+    @Test
+    public void testContactPointsOnly() {
+        ccConfig.setContactPoints("127.0.0.1", "127.0.0.2", "127.0.0.3");
+        CassandraClientModule.createCassandraSession(mockClusterBuilder, ccId, ccConfig, mockExtraColumnMetadataCodec);
</code_context>

<issue_to_address>
**suggestion (testing):** Add a test for the case where neither contact points nor an Astra bundle are configured

Since `createCassandraSession` now throws `IllegalArgumentException` when `astraSecureConnectBundlePath` is null and `contactPoints` is empty, please add a test (e.g. `testNoContactPointsAndNoAstraBundleThrowsError`) that uses the default config and asserts that this exception is thrown. This will lock in the validation behavior and document the expected configuration contract.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Comment on lines +170 to +175
Cluster cluster = clusterBuilder.build();

return new NativeCassandraSession(
connectorId.toString(),
extraColumnMetadataCodec,
new ReopeningCluster(() -> {
contactPoints.forEach(clusterBuilder::addContactPoint);
return clusterBuilder.build();
}),
new ReopeningCluster(() -> cluster ),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

issue (bug_risk): ReopeningCluster now reuses a single Cluster instance instead of recreating it, which likely breaks the reopening behavior.

The original supplier rebuilt the Cluster (and re-added contact points) on each invocation, while the new version always returns the same pre-built cluster instance. After that instance is closed, ReopeningCluster will keep returning a closed Cluster, breaking the reopening behavior and likely causing runtime errors. The supplier should instead construct a new Cluster on each call (with the necessary configuration) or otherwise guarantee it never returns a previously closed instance.

Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey there - I've reviewed your changes and found some issues that need to be addressed.

  • Changing ReopeningCluster to capture a single built Cluster instance (new ReopeningCluster(() -> cluster)) removes the ability to reopen with a freshly built cluster and may defeat its purpose; consider keeping a supplier that rebuilds from clusterBuilder instead of reusing one instance.
  • The mutual-exclusion check for contact points and astraSecureConnectBundlePath is hard to read (!(config.getAstraSecureConnectBundlePath() != null && ...)); consider simplifying this into two straightforward checkArgument calls or extracting it into a small helper to make the configuration constraints clearer.
  • The new overload of createCassandraSession that accepts a Cluster.Builder should be documented in a brief Javadoc (especially around expected usage and lifecycle of the builder) to avoid accidental misuse outside of tests.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- Changing `ReopeningCluster` to capture a single built `Cluster` instance (`new ReopeningCluster(() -> cluster)`) removes the ability to reopen with a freshly built cluster and may defeat its purpose; consider keeping a supplier that rebuilds from `clusterBuilder` instead of reusing one instance.
- The mutual-exclusion check for contact points and `astraSecureConnectBundlePath` is hard to read (`!(config.getAstraSecureConnectBundlePath() != null && ...)`); consider simplifying this into two straightforward `checkArgument` calls or extracting it into a small helper to make the configuration constraints clearer.
- The new overload of `createCassandraSession` that accepts a `Cluster.Builder` should be documented in a brief Javadoc (especially around expected usage and lifecycle of the builder) to avoid accidental misuse outside of tests.

## Individual Comments

### Comment 1
<location> `presto-cassandra/src/main/java/com/facebook/presto/cassandra/CassandraClientModule.java:170-175` </location>
<code_context>
                     config.getSpeculativeExecutionLimit())); // maximum number of executions
         }

+        Cluster cluster = clusterBuilder.build();
+
         return new NativeCassandraSession(
                 connectorId.toString(),
                 extraColumnMetadataCodec,
-                new ReopeningCluster(() -> {
-                    contactPoints.forEach(clusterBuilder::addContactPoint);
-                    return clusterBuilder.build();
-                }),
+                new ReopeningCluster(() -> cluster ),
                 config.getNoHostAvailableRetryTimeout(), config.isCaseSensitiveNameMatchingEnabled());
     }
</code_context>

<issue_to_address>
**issue (bug_risk):** ReopeningCluster now always returns the same Cluster instance, which defeats the purpose and risks using a closed Cluster.

With the original code, `ReopeningCluster` rebuilt a fresh `Cluster` on each call via `clusterBuilder.build()`. After this change, the same `Cluster` instance is always returned. Once that instance is closed, all subsequent "reopens" will still return a closed `Cluster`, leading to runtime errors.

Keep the `Cluster` construction inside the supplier so each reopen creates a new instance, e.g.:

```java
return new NativeCassandraSession(
        connectorId.toString(),
        extraColumnMetadataCodec,
        new ReopeningCluster(clusterBuilder::build),
        config.getNoHostAvailableRetryTimeout(),
        config.isCaseSensitiveNameMatchingEnabled());
```

Any conditional logic around contact points vs. secure bundle can still be handled inside that supplier while ensuring a new `Cluster` is built each time.
</issue_to_address>

### Comment 2
<location> `presto-cassandra/src/test/java/com/facebook/presto/cassandra/CassandraClientModuleTest.java:31` </location>
<code_context>
+import static org.mockito.Mockito.*;
+
+
+public class CassandraClientModuleTest {
+
+    private CassandraConnectorId ccId;
</code_context>

<issue_to_address>
**issue (testing):** Add a test for the case where neither contact points nor Astra bundle are configured

The updated `createCassandraSession` now throws `IllegalArgumentException("empty contactPoints")` when `astraSecureConnectBundlePath` is null and `contactPoints` is empty, but this path isn’t tested. Please add a test that uses the default empty `contactPoints` and a null `astraSecureConnectBundlePath`, and asserts that `createCassandraSession` throws this exception to cover this configuration gap.
</issue_to_address>

### Comment 3
<location> `presto-cassandra/src/test/java/com/facebook/presto/cassandra/CassandraClientModuleTest.java:50-51` </location>
<code_context>
+        mockExtraColumnMetadataCodec = Mockito.mock(JsonCodec.class);
+    }
+
+    @Test
+    public void testContactPointsOnly() {
+        ccConfig.setContactPoints("127.0.0.1", "127.0.0.2", "127.0.0.3");
+        CassandraClientModule.createCassandraSession(mockClusterBuilder, ccId, ccConfig, mockExtraColumnMetadataCodec);
</code_context>

<issue_to_address>
**suggestion (testing):** Also assert that the Astra bundle is not used when only contact points are configured

In `testContactPointsOnly`, in addition to verifying the three `addContactPoint` calls, please also assert that `withCloudSecureConnectBundle` is never invoked, e.g. `verify(mockClusterBuilder, never()).withCloudSecureConnectBundle(any(File.class));`. This will explicitly validate the mutual exclusion between contact points and the Astra bundle path.

Suggested implementation:

```java
    @Test
    public void testContactPointsOnly() {
        ccConfig.setContactPoints("127.0.0.1", "127.0.0.2", "127.0.0.3");
        CassandraClientModule.createCassandraSession(mockClusterBuilder, ccId, ccConfig, mockExtraColumnMetadataCodec);
        verify(mockClusterBuilder, times(3)).addContactPoint(anyString());
        verify(mockClusterBuilder, never()).withCloudSecureConnectBundle(any(java.io.File.class));
    }

```

1. If you prefer to avoid the fully-qualified `java.io.File` in the test body, add `import java.io.File;` at the top of the file and change the new line to `withCloudSecureConnectBundle(any(File.class));`.
2. Ensure there is a static import for `never` and `any` if not already present, e.g. `import static org.mockito.Mockito.*;` or the specific static imports you use elsewhere in the test file.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Comment on lines +170 to +175
Cluster cluster = clusterBuilder.build();

return new NativeCassandraSession(
connectorId.toString(),
extraColumnMetadataCodec,
new ReopeningCluster(() -> {
contactPoints.forEach(clusterBuilder::addContactPoint);
return clusterBuilder.build();
}),
new ReopeningCluster(() -> cluster ),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

issue (bug_risk): ReopeningCluster now always returns the same Cluster instance, which defeats the purpose and risks using a closed Cluster.

With the original code, ReopeningCluster rebuilt a fresh Cluster on each call via clusterBuilder.build(). After this change, the same Cluster instance is always returned. Once that instance is closed, all subsequent "reopens" will still return a closed Cluster, leading to runtime errors.

Keep the Cluster construction inside the supplier so each reopen creates a new instance, e.g.:

return new NativeCassandraSession(
        connectorId.toString(),
        extraColumnMetadataCodec,
        new ReopeningCluster(clusterBuilder::build),
        config.getNoHostAvailableRetryTimeout(),
        config.isCaseSensitiveNameMatchingEnabled());

Any conditional logic around contact points vs. secure bundle can still be handled inside that supplier while ensuring a new Cluster is built each time.

import static org.mockito.Mockito.*;


public class CassandraClientModuleTest {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

issue (testing): Add a test for the case where neither contact points nor Astra bundle are configured

The updated createCassandraSession now throws IllegalArgumentException("empty contactPoints") when astraSecureConnectBundlePath is null and contactPoints is empty, but this path isn’t tested. Please add a test that uses the default empty contactPoints and a null astraSecureConnectBundlePath, and asserts that createCassandraSession throws this exception to cover this configuration gap.

Comment on lines +50 to +51
@Test
public void testContactPointsOnly() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion (testing): Also assert that the Astra bundle is not used when only contact points are configured

In testContactPointsOnly, in addition to verifying the three addContactPoint calls, please also assert that withCloudSecureConnectBundle is never invoked, e.g. verify(mockClusterBuilder, never()).withCloudSecureConnectBundle(any(File.class));. This will explicitly validate the mutual exclusion between contact points and the Astra bundle path.

Suggested implementation:

    @Test
    public void testContactPointsOnly() {
        ccConfig.setContactPoints("127.0.0.1", "127.0.0.2", "127.0.0.3");
        CassandraClientModule.createCassandraSession(mockClusterBuilder, ccId, ccConfig, mockExtraColumnMetadataCodec);
        verify(mockClusterBuilder, times(3)).addContactPoint(anyString());
        verify(mockClusterBuilder, never()).withCloudSecureConnectBundle(any(java.io.File.class));
    }
  1. If you prefer to avoid the fully-qualified java.io.File in the test body, add import java.io.File; at the top of the file and change the new line to withCloudSecureConnectBundle(any(File.class));.
  2. Ensure there is a static import for never and any if not already present, e.g. import static org.mockito.Mockito.*; or the specific static imports you use elsewhere in the test file.

@arvy arvy force-pushed the cassandra-connector-astra-support branch from 98842c5 to e8cd1b1 Compare December 10, 2025 17:12
config.getContactPoints() != null &&
!config.getContactPoints().isEmpty()) , "Contact points and Astra Secure Connect Bundle cannot both be specified!");

if( config.getAstraSecureConnectBundlePath() == null ) {
Copy link

@msmygit msmygit Dec 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#nitpick should this be checking for null or empty or just spaces?

@tdcmeehan tdcmeehan self-assigned this Dec 11, 2025
Copy link
Contributor

@tdcmeehan tdcmeehan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this contribution, I have some comments and questions.

private ConsistencyLevel consistencyLevel = ConsistencyLevel.ONE;
private int fetchSize = 5_000;
private List<String> contactPoints = ImmutableList.of();
private String astraSecureConnectBundlePath = null;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Although not evident in this file, our typical convention is to express this as an Optional and for the default value to be Optional.empty(). See our guidelines on nullable objects: https://github.com/prestodb/presto/blob/master/CONTRIBUTING.md#java

import static org.mockito.Mockito.*;


public class CassandraClientModuleTest {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Our convention is Test is first, i.e. TestCassandraClientModule. Also, it's not typical to test Guice modules, as this is more or less configuration. Would it be possible to create an end to end test that proves the configuration is being used?

<artifactId>mockito-inline</artifactId>
<version>5.2.0</version>
<scope>test</scope>
</dependency>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't use Mockito in this project--is there any other way to test this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants