diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/cassandra/CassandraAutoConfiguration.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/cassandra/CassandraAutoConfiguration.java index f725167545..9664fd883a 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/cassandra/CassandraAutoConfiguration.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/cassandra/CassandraAutoConfiguration.java @@ -83,6 +83,8 @@ public class CassandraAutoConfiguration { map.from(properties::getContactPoints) .as((list) -> StringUtils.toStringArray(list)) .to(builder::addContactPoints); + map.from(properties::isJmxReporting).whenFalse() + .toCall(builder::withoutJMXReporting); customize(builder); return builder.build(); } diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/cassandra/CassandraProperties.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/cassandra/CassandraProperties.java index db3a1dd813..911c8c2c61 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/cassandra/CassandraProperties.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/cassandra/CassandraProperties.java @@ -132,6 +132,12 @@ public class CassandraProperties { */ private boolean ssl = false; + /** + * If JMX reporting should be enabled. Default to false as Cassandra JMX reporting is + * not compatible with Dropwizrd Metrics 4. + */ + private boolean jmxReporting = false; + /** * Pool configuration. */ @@ -272,6 +278,14 @@ public class CassandraProperties { this.ssl = ssl; } + public boolean isJmxReporting() { + return this.jmxReporting; + } + + public void setJmxReporting(boolean jmxReporting) { + this.jmxReporting = jmxReporting; + } + public String getSchemaAction() { return this.schemaAction; } diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/data/cassandra/CassandraDataAutoConfigurationIntegrationTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/data/cassandra/CassandraDataAutoConfigurationIntegrationTests.java index 8c9ccb499a..4ae1543fa4 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/data/cassandra/CassandraDataAutoConfigurationIntegrationTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/data/cassandra/CassandraDataAutoConfigurationIntegrationTests.java @@ -95,8 +95,8 @@ public class CassandraDataAutoConfigurationIntegrationTests { } private void createTestKeyspaceIfNotExists() { - Cluster cluster = Cluster.builder().withPort(cassandra.getMappedPort()) - .addContactPoint("localhost").build(); + Cluster cluster = Cluster.builder().withoutJMXReporting() + .withPort(cassandra.getMappedPort()).addContactPoint("localhost").build(); try (Session session = cluster.connect()) { session.execute("CREATE KEYSPACE IF NOT EXISTS boot_test" + " WITH REPLICATION = { 'class' : 'SimpleStrategy', 'replication_factor' : 1 };"); diff --git a/spring-boot-project/spring-boot-tools/spring-boot-test-support/src/main/java/org/springframework/boot/testsupport/testcontainers/CassandraContainer.java b/spring-boot-project/spring-boot-tools/spring-boot-test-support/src/main/java/org/springframework/boot/testsupport/testcontainers/CassandraContainer.java index 6e8b63e84e..d0a26d3bd3 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-test-support/src/main/java/org/springframework/boot/testsupport/testcontainers/CassandraContainer.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-test-support/src/main/java/org/springframework/boot/testsupport/testcontainers/CassandraContainer.java @@ -67,7 +67,7 @@ public class CassandraContainer extends Container { private Callable checkConnection() { return () -> { - try (Cluster cluster = Cluster.builder() + try (Cluster cluster = Cluster.builder().withoutJMXReporting() .withPort(this.container.getMappedPort(CassandraContainer.PORT)) .addContactPoint("localhost").build()) { cluster.connect();