Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

package org.springframework.boot.actuate.cassandra;

import com.datastax.oss.driver.api.core.ConsistencyLevel;
import com.datastax.oss.driver.api.core.cql.ResultSet;
import com.datastax.oss.driver.api.core.cql.SimpleStatement;

Expand All @@ -34,6 +35,9 @@
*/
public class CassandraHealthIndicator extends AbstractHealthIndicator {

private static final SimpleStatement SELECT = SimpleStatement
.newInstance("SELECT release_version FROM system.local").setConsistencyLevel(ConsistencyLevel.LOCAL_ONE);

private CassandraOperations cassandraOperations;

public CassandraHealthIndicator() {
Expand All @@ -52,8 +56,7 @@ public CassandraHealthIndicator(CassandraOperations cassandraOperations) {

@Override
protected void doHealthCheck(Health.Builder builder) throws Exception {
SimpleStatement select = SimpleStatement.newInstance("SELECT release_version FROM system.local");
ResultSet results = this.cassandraOperations.getCqlOperations().queryForResultSet(select);
ResultSet results = this.cassandraOperations.getCqlOperations().queryForResultSet(SELECT);
if (results.isFullyFetched()) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I personally think that this check is inaccurate here since this method will always return true for this query. As a consequence, the code beneath the if block is never reached and the health indicator never reports the release version. But since this is not related to the fix I left it for another PR.

builder.up();
return;
Expand Down