From 96c2d08fc4be55d4ec4b102fffcc5002b355b628 Mon Sep 17 00:00:00 2001 From: Andy Wilkinson Date: Wed, 18 May 2022 11:28:46 +0100 Subject: [PATCH] Remove support for Solr as it is not compatible with Jetty 11 Closes gh-31054 --- .../build.gradle | 3 - ...olrHealthContributorAutoConfiguration.java | 55 ------- .../autoconfigure/solr/package-info.java | 20 --- ...itional-spring-configuration-metadata.json | 6 - ...ot.autoconfigure.AutoConfiguration.imports | 1 - ...intsAutoConfigurationIntegrationTests.java | 3 +- ...althContributorAutoConfigurationTests.java | 51 ------ .../spring-boot-actuator/build.gradle | 3 - .../actuate/solr/SolrHealthIndicator.java | 136 ---------------- .../boot/actuate/solr/package-info.java | 20 --- .../solr/SolrHealthIndicatorTests.java | 145 ------------------ .../spring-boot-autoconfigure/build.gradle | 3 - .../solr/SolrAutoConfiguration.java | 54 ------- .../autoconfigure/solr/SolrProperties.java | 56 ------- .../boot/autoconfigure/solr/package-info.java | 20 --- ...ot.autoconfigure.AutoConfiguration.imports | 1 - .../spring-boot-dependencies/build.gradle | 23 --- .../spring-boot-docs/build.gradle | 4 - .../src/docs/asciidoc/actuator/endpoints.adoc | 4 - .../docs/asciidoc/anchor-rewrite.properties | 4 - .../src/docs/asciidoc/data/nosql.adoc | 21 +-- .../data/nosql/solr/connecting/MyBean.java | 42 ----- .../docs/data/nosql/solr/connecting/MyBean.kt | 32 ---- 23 files changed, 2 insertions(+), 705 deletions(-) delete mode 100644 spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/solr/SolrHealthContributorAutoConfiguration.java delete mode 100644 spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/solr/package-info.java delete mode 100644 spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/solr/SolrHealthContributorAutoConfigurationTests.java delete mode 100644 spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/solr/SolrHealthIndicator.java delete mode 100644 spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/solr/package-info.java delete mode 100644 spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/solr/SolrHealthIndicatorTests.java delete mode 100644 spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/solr/SolrAutoConfiguration.java delete mode 100644 spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/solr/SolrProperties.java delete mode 100644 spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/solr/package-info.java delete mode 100644 spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/data/nosql/solr/connecting/MyBean.java delete mode 100644 spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/data/nosql/solr/connecting/MyBean.kt diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/build.gradle b/spring-boot-project/spring-boot-actuator-autoconfigure/build.gradle index 1a77ab50c6..548da5bd61 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/build.gradle +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/build.gradle @@ -93,9 +93,6 @@ dependencies { } optional("org.apache.kafka:kafka-clients") optional("org.apache.kafka:kafka-streams") - optional("org.apache.solr:solr-solrj") { - exclude group: "org.slf4j", module: "jcl-over-slf4j" - } optional("org.apache.tomcat.embed:tomcat-embed-core") optional("org.apache.tomcat.embed:tomcat-embed-el") optional("org.apache.tomcat:tomcat-jdbc") diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/solr/SolrHealthContributorAutoConfiguration.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/solr/SolrHealthContributorAutoConfiguration.java deleted file mode 100644 index 0a3819b9ce..0000000000 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/solr/SolrHealthContributorAutoConfiguration.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright 2012-2022 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.boot.actuate.autoconfigure.solr; - -import java.util.Map; - -import org.apache.solr.client.solrj.SolrClient; - -import org.springframework.boot.actuate.autoconfigure.health.CompositeHealthContributorConfiguration; -import org.springframework.boot.actuate.autoconfigure.health.ConditionalOnEnabledHealthIndicator; -import org.springframework.boot.actuate.health.HealthContributor; -import org.springframework.boot.actuate.solr.SolrHealthIndicator; -import org.springframework.boot.autoconfigure.AutoConfiguration; -import org.springframework.boot.autoconfigure.EnableAutoConfiguration; -import org.springframework.boot.autoconfigure.condition.ConditionalOnBean; -import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; -import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; -import org.springframework.boot.autoconfigure.solr.SolrAutoConfiguration; -import org.springframework.context.annotation.Bean; - -/** - * {@link EnableAutoConfiguration Auto-configuration} for {@link SolrHealthIndicator}. - * - * @author Andy Wilkinson - * @author Stephane Nicoll - * @since 2.0.0 - */ -@AutoConfiguration(after = SolrAutoConfiguration.class) -@ConditionalOnClass(SolrClient.class) -@ConditionalOnBean(SolrClient.class) -@ConditionalOnEnabledHealthIndicator("solr") -public class SolrHealthContributorAutoConfiguration - extends CompositeHealthContributorConfiguration { - - @Bean - @ConditionalOnMissingBean(name = { "solrHealthIndicator", "solrHealthContributor" }) - public HealthContributor solrHealthContributor(Map solrClients) { - return createContributor(solrClients); - } - -} diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/solr/package-info.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/solr/package-info.java deleted file mode 100644 index bfeccec834..0000000000 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/solr/package-info.java +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Copyright 2012-2019 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** - * Auto-configuration for actuator Solr concerns. - */ -package org.springframework.boot.actuate.autoconfigure.solr; diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/resources/META-INF/additional-spring-configuration-metadata.json b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/resources/META-INF/additional-spring-configuration-metadata.json index 316290f82b..be1d0202b3 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/resources/META-INF/additional-spring-configuration-metadata.json +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/resources/META-INF/additional-spring-configuration-metadata.json @@ -267,12 +267,6 @@ "description": "Whether to enable Redis health check.", "defaultValue": true }, - { - "name": "management.health.solr.enabled", - "type": "java.lang.Boolean", - "description": "Whether to enable Solr health check.", - "defaultValue": true - }, { "name": "management.health.status.order", "defaultValue": [ diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports index fa1d6a147c..88fa82af3d 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports @@ -91,7 +91,6 @@ org.springframework.boot.actuate.autoconfigure.scheduling.ScheduledTasksEndpoint org.springframework.boot.actuate.autoconfigure.security.reactive.ReactiveManagementWebSecurityAutoConfiguration org.springframework.boot.actuate.autoconfigure.security.servlet.ManagementWebSecurityAutoConfiguration org.springframework.boot.actuate.autoconfigure.session.SessionsEndpointAutoConfiguration -org.springframework.boot.actuate.autoconfigure.solr.SolrHealthContributorAutoConfiguration org.springframework.boot.actuate.autoconfigure.startup.StartupEndpointAutoConfiguration org.springframework.boot.actuate.autoconfigure.system.DiskSpaceHealthContributorAutoConfiguration org.springframework.boot.actuate.autoconfigure.trace.http.HttpTraceAutoConfiguration diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/integrationtest/WebEndpointsAutoConfigurationIntegrationTests.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/integrationtest/WebEndpointsAutoConfigurationIntegrationTests.java index c945ccc576..3e1a5243a4 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/integrationtest/WebEndpointsAutoConfigurationIntegrationTests.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/integrationtest/WebEndpointsAutoConfigurationIntegrationTests.java @@ -41,7 +41,6 @@ import org.springframework.boot.autoconfigure.hazelcast.HazelcastAutoConfigurati import org.springframework.boot.autoconfigure.liquibase.LiquibaseAutoConfiguration; import org.springframework.boot.autoconfigure.mongo.MongoAutoConfiguration; import org.springframework.boot.autoconfigure.mongo.MongoReactiveAutoConfiguration; -import org.springframework.boot.autoconfigure.solr.SolrAutoConfiguration; import org.springframework.boot.context.annotation.UserConfigurations; import org.springframework.boot.test.context.runner.ReactiveWebApplicationContextRunner; import org.springframework.boot.test.context.runner.WebApplicationContextRunner; @@ -82,7 +81,7 @@ class WebEndpointsAutoConfigurationIntegrationTests { Neo4jRepositoriesAutoConfiguration.class, MongoAutoConfiguration.class, MongoDataAutoConfiguration.class, MongoReactiveAutoConfiguration.class, MongoReactiveDataAutoConfiguration.class, RepositoryRestMvcAutoConfiguration.class, HazelcastAutoConfiguration.class, - ElasticsearchDataAutoConfiguration.class, SolrAutoConfiguration.class, RedisAutoConfiguration.class, + ElasticsearchDataAutoConfiguration.class, RedisAutoConfiguration.class, RedisRepositoriesAutoConfiguration.class, MetricsAutoConfiguration.class, WavefrontAutoConfiguration.class, BraveAutoConfiguration.class, OpenTelemetryAutoConfiguration.class }) @SpringBootConfiguration diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/solr/SolrHealthContributorAutoConfigurationTests.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/solr/SolrHealthContributorAutoConfigurationTests.java deleted file mode 100644 index 562568ea59..0000000000 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/solr/SolrHealthContributorAutoConfigurationTests.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright 2012-2020 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.boot.actuate.autoconfigure.solr; - -import org.junit.jupiter.api.Test; - -import org.springframework.boot.actuate.autoconfigure.health.HealthContributorAutoConfiguration; -import org.springframework.boot.actuate.solr.SolrHealthIndicator; -import org.springframework.boot.autoconfigure.AutoConfigurations; -import org.springframework.boot.autoconfigure.solr.SolrAutoConfiguration; -import org.springframework.boot.test.context.runner.ApplicationContextRunner; - -import static org.assertj.core.api.Assertions.assertThat; - -/** - * Tests for {@link SolrHealthContributorAutoConfiguration}. - * - * @author Phillip Webb - */ -class SolrHealthContributorAutoConfigurationTests { - - private final ApplicationContextRunner contextRunner = new ApplicationContextRunner() - .withConfiguration(AutoConfigurations.of(SolrAutoConfiguration.class, - SolrHealthContributorAutoConfiguration.class, HealthContributorAutoConfiguration.class)); - - @Test - void runShouldCreateIndicator() { - this.contextRunner.run((context) -> assertThat(context).hasSingleBean(SolrHealthIndicator.class)); - } - - @Test - void runWhenDisabledShouldNotCreateIndicator() { - this.contextRunner.withPropertyValues("management.health.solr.enabled:false") - .run((context) -> assertThat(context).doesNotHaveBean(SolrHealthIndicator.class)); - } - -} diff --git a/spring-boot-project/spring-boot-actuator/build.gradle b/spring-boot-project/spring-boot-actuator/build.gradle index 2a9613bb60..bcf404ac08 100644 --- a/spring-boot-project/spring-boot-actuator/build.gradle +++ b/spring-boot-project/spring-boot-actuator/build.gradle @@ -36,9 +36,6 @@ dependencies { } optional("javax.cache:cache-api") optional("jakarta.jms:jakarta.jms-api") - optional("org.apache.solr:solr-solrj") { - exclude group: "org.slf4j", module: "jcl-over-slf4j" - } optional("org.apache.tomcat.embed:tomcat-embed-core") optional("org.aspectj:aspectjweaver") optional("org.cache2k:cache2k-micrometer") diff --git a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/solr/SolrHealthIndicator.java b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/solr/SolrHealthIndicator.java deleted file mode 100644 index 83d4482194..0000000000 --- a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/solr/SolrHealthIndicator.java +++ /dev/null @@ -1,136 +0,0 @@ -/* - * Copyright 2012-2020 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.boot.actuate.solr; - -import org.apache.solr.client.solrj.SolrClient; -import org.apache.solr.client.solrj.impl.BaseHttpSolrClient.RemoteSolrException; -import org.apache.solr.client.solrj.request.CoreAdminRequest; -import org.apache.solr.common.params.CoreAdminParams; - -import org.springframework.boot.actuate.health.AbstractHealthIndicator; -import org.springframework.boot.actuate.health.Health; -import org.springframework.boot.actuate.health.HealthIndicator; -import org.springframework.boot.actuate.health.Status; - -/** - * {@link HealthIndicator} for Apache Solr. - * - * @author Andy Wilkinson - * @author Stephane Nicoll - * @author Markus Schuch - * @author Phillip Webb - * @since 2.0.0 - */ -public class SolrHealthIndicator extends AbstractHealthIndicator { - - private static final int HTTP_NOT_FOUND_STATUS = 404; - - private final SolrClient solrClient; - - private volatile StatusCheck statusCheck; - - public SolrHealthIndicator(SolrClient solrClient) { - super("Solr health check failed"); - this.solrClient = solrClient; - } - - @Override - protected void doHealthCheck(Health.Builder builder) throws Exception { - int statusCode = initializeStatusCheck(); - Status status = (statusCode != 0) ? Status.DOWN : Status.UP; - builder.status(status).withDetail("status", statusCode).withDetail("detectedPathType", - this.statusCheck.getPathType()); - } - - private int initializeStatusCheck() throws Exception { - StatusCheck statusCheck = this.statusCheck; - if (statusCheck != null) { - // Already initialized - return statusCheck.getStatus(this.solrClient); - } - try { - return initializeStatusCheck(new RootStatusCheck()); - } - catch (RemoteSolrException ex) { - // 404 is thrown when SolrClient has a baseUrl pointing to a particular core. - if (ex.code() == HTTP_NOT_FOUND_STATUS) { - return initializeStatusCheck(new ParticularCoreStatusCheck()); - } - throw ex; - } - } - - private int initializeStatusCheck(StatusCheck statusCheck) throws Exception { - int result = statusCheck.getStatus(this.solrClient); - this.statusCheck = statusCheck; - return result; - } - - /** - * Strategy used to perform the status check. - */ - private abstract static class StatusCheck { - - private final String pathType; - - StatusCheck(String pathType) { - this.pathType = pathType; - } - - abstract int getStatus(SolrClient client) throws Exception; - - String getPathType() { - return this.pathType; - } - - } - - /** - * {@link StatusCheck} used when {@code baseUrl} points to the root context. - */ - private static class RootStatusCheck extends StatusCheck { - - RootStatusCheck() { - super("root"); - } - - @Override - public int getStatus(SolrClient client) throws Exception { - CoreAdminRequest request = new CoreAdminRequest(); - request.setAction(CoreAdminParams.CoreAdminAction.STATUS); - return request.process(client).getStatus(); - } - - } - - /** - * {@link StatusCheck} used when {@code baseUrl} points to the particular core. - */ - private static class ParticularCoreStatusCheck extends StatusCheck { - - ParticularCoreStatusCheck() { - super("particular core"); - } - - @Override - public int getStatus(SolrClient client) throws Exception { - return client.ping().getStatus(); - } - - } - -} diff --git a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/solr/package-info.java b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/solr/package-info.java deleted file mode 100644 index 5ecbb16bf6..0000000000 --- a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/solr/package-info.java +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Copyright 2012-2019 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** - * Actuator support for Solr. - */ -package org.springframework.boot.actuate.solr; diff --git a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/solr/SolrHealthIndicatorTests.java b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/solr/SolrHealthIndicatorTests.java deleted file mode 100644 index 31223253ac..0000000000 --- a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/solr/SolrHealthIndicatorTests.java +++ /dev/null @@ -1,145 +0,0 @@ -/* - * Copyright 2012-2022 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.boot.actuate.solr; - -import java.io.IOException; - -import org.apache.solr.client.solrj.SolrClient; -import org.apache.solr.client.solrj.impl.BaseHttpSolrClient.RemoteSolrException; -import org.apache.solr.client.solrj.request.CoreAdminRequest; -import org.apache.solr.client.solrj.response.SolrPingResponse; -import org.apache.solr.common.util.NamedList; -import org.junit.jupiter.api.Test; - -import org.springframework.boot.actuate.health.Health; -import org.springframework.boot.actuate.health.Status; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.ArgumentMatchers.isNull; -import static org.mockito.BDDMockito.given; -import static org.mockito.BDDMockito.then; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.times; - -/** - * Tests for {@link SolrHealthIndicator} - * - * @author Andy Wilkinson - * @author Markus Schuch - * @author Phillip Webb - */ -class SolrHealthIndicatorTests { - - @Test - void healthWhenSolrStatusUpAndBaseUrlPointsToRootReturnsUp() throws Exception { - SolrClient solrClient = mock(SolrClient.class); - given(solrClient.request(any(CoreAdminRequest.class), isNull())).willReturn(mockResponse(0)); - SolrHealthIndicator healthIndicator = new SolrHealthIndicator(solrClient); - assertHealth(healthIndicator, Status.UP, 0, "root"); - then(solrClient).should().request(any(CoreAdminRequest.class), isNull()); - then(solrClient).shouldHaveNoMoreInteractions(); - } - - @Test - void healthWhenSolrStatusDownAndBaseUrlPointsToRootReturnsDown() throws Exception { - SolrClient solrClient = mock(SolrClient.class); - given(solrClient.request(any(CoreAdminRequest.class), isNull())).willReturn(mockResponse(400)); - SolrHealthIndicator healthIndicator = new SolrHealthIndicator(solrClient); - assertHealth(healthIndicator, Status.DOWN, 400, "root"); - then(solrClient).should().request(any(CoreAdminRequest.class), isNull()); - then(solrClient).shouldHaveNoMoreInteractions(); - } - - @Test - void healthWhenSolrStatusUpAndBaseUrlPointsToParticularCoreReturnsUp() throws Exception { - SolrClient solrClient = mock(SolrClient.class); - given(solrClient.request(any(CoreAdminRequest.class), isNull())) - .willThrow(new RemoteSolrException("mock", 404, "", null)); - given(solrClient.ping()).willReturn(mockPingResponse(0)); - SolrHealthIndicator healthIndicator = new SolrHealthIndicator(solrClient); - assertHealth(healthIndicator, Status.UP, 0, "particular core"); - then(solrClient).should().request(any(CoreAdminRequest.class), isNull()); - then(solrClient).should().ping(); - then(solrClient).shouldHaveNoMoreInteractions(); - } - - @Test - void healthWhenSolrStatusDownAndBaseUrlPointsToParticularCoreReturnsDown() throws Exception { - SolrClient solrClient = mock(SolrClient.class); - given(solrClient.request(any(CoreAdminRequest.class), isNull())) - .willThrow(new RemoteSolrException("mock", 404, "", null)); - given(solrClient.ping()).willReturn(mockPingResponse(400)); - SolrHealthIndicator healthIndicator = new SolrHealthIndicator(solrClient); - assertHealth(healthIndicator, Status.DOWN, 400, "particular core"); - then(solrClient).should().request(any(CoreAdminRequest.class), isNull()); - then(solrClient).should().ping(); - then(solrClient).shouldHaveNoMoreInteractions(); - } - - @Test - void healthWhenSolrConnectionFailsReturnsDown() throws Exception { - SolrClient solrClient = mock(SolrClient.class); - given(solrClient.request(any(CoreAdminRequest.class), isNull())) - .willThrow(new IOException("Connection failed")); - SolrHealthIndicator healthIndicator = new SolrHealthIndicator(solrClient); - Health health = healthIndicator.health(); - assertThat(health.getStatus()).isEqualTo(Status.DOWN); - assertThat((String) health.getDetails().get("error")).contains("Connection failed"); - then(solrClient).should().request(any(CoreAdminRequest.class), isNull()); - then(solrClient).shouldHaveNoMoreInteractions(); - } - - @Test - void healthWhenMakingMultipleCallsRemembersStatusStrategy() throws Exception { - SolrClient solrClient = mock(SolrClient.class); - given(solrClient.request(any(CoreAdminRequest.class), isNull())) - .willThrow(new RemoteSolrException("mock", 404, "", null)); - given(solrClient.ping()).willReturn(mockPingResponse(0)); - SolrHealthIndicator healthIndicator = new SolrHealthIndicator(solrClient); - healthIndicator.health(); - then(solrClient).should().request(any(CoreAdminRequest.class), isNull()); - then(solrClient).should().ping(); - then(solrClient).shouldHaveNoMoreInteractions(); - healthIndicator.health(); - then(solrClient).should(times(2)).ping(); - then(solrClient).shouldHaveNoMoreInteractions(); - } - - private void assertHealth(SolrHealthIndicator healthIndicator, Status expectedStatus, int expectedStatusCode, - String expectedPathType) { - Health health = healthIndicator.health(); - assertThat(health.getStatus()).isEqualTo(expectedStatus); - assertThat(health.getDetails().get("status")).isEqualTo(expectedStatusCode); - assertThat(health.getDetails().get("detectedPathType")).isEqualTo(expectedPathType); - } - - private NamedList mockResponse(int status) { - NamedList response = new NamedList<>(); - NamedList headers = new NamedList<>(); - headers.add("status", status); - response.add("responseHeader", headers); - return response; - } - - private SolrPingResponse mockPingResponse(int status) { - SolrPingResponse pingResponse = new SolrPingResponse(); - pingResponse.setResponse(mockResponse(status)); - return pingResponse; - } - -} diff --git a/spring-boot-project/spring-boot-autoconfigure/build.gradle b/spring-boot-project/spring-boot-autoconfigure/build.gradle index 8f2e627450..c95c909f12 100644 --- a/spring-boot-project/spring-boot-autoconfigure/build.gradle +++ b/spring-boot-project/spring-boot-autoconfigure/build.gradle @@ -58,9 +58,6 @@ dependencies { } optional("org.apache.httpcomponents.client5:httpclient5") optional("org.apache.kafka:kafka-streams") - optional("org.apache.solr:solr-solrj") { - exclude group: "org.slf4j", module: "jcl-over-slf4j" - } optional("org.apache.tomcat.embed:tomcat-embed-core") optional("org.apache.tomcat.embed:tomcat-embed-el") optional("org.apache.tomcat.embed:tomcat-embed-websocket") diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/solr/SolrAutoConfiguration.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/solr/SolrAutoConfiguration.java deleted file mode 100644 index e2ae3a9dec..0000000000 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/solr/SolrAutoConfiguration.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright 2012-2022 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.boot.autoconfigure.solr; - -import java.util.Arrays; -import java.util.Optional; - -import org.apache.solr.client.solrj.SolrClient; -import org.apache.solr.client.solrj.impl.CloudSolrClient; -import org.apache.solr.client.solrj.impl.HttpSolrClient; - -import org.springframework.boot.autoconfigure.AutoConfiguration; -import org.springframework.boot.autoconfigure.EnableAutoConfiguration; -import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; -import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; -import org.springframework.boot.context.properties.EnableConfigurationProperties; -import org.springframework.context.annotation.Bean; -import org.springframework.util.StringUtils; - -/** - * {@link EnableAutoConfiguration Auto-configuration} for Solr. - * - * @author Christoph Strobl - * @since 1.1.0 - */ -@AutoConfiguration -@ConditionalOnClass({ HttpSolrClient.class, CloudSolrClient.class }) -@EnableConfigurationProperties(SolrProperties.class) -public class SolrAutoConfiguration { - - @Bean - @ConditionalOnMissingBean - public SolrClient solrClient(SolrProperties properties) { - if (StringUtils.hasText(properties.getZkHost())) { - return new CloudSolrClient.Builder(Arrays.asList(properties.getZkHost()), Optional.empty()).build(); - } - return new HttpSolrClient.Builder(properties.getHost()).build(); - } - -} diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/solr/SolrProperties.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/solr/SolrProperties.java deleted file mode 100644 index 4380386bc7..0000000000 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/solr/SolrProperties.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright 2012-2019 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.boot.autoconfigure.solr; - -import org.springframework.boot.context.properties.ConfigurationProperties; - -/** - * {@link ConfigurationProperties @ConfigurationProperties} for Solr. - * - * @author Christoph Strobl - * @since 1.1.0 - */ -@ConfigurationProperties(prefix = "spring.data.solr") -public class SolrProperties { - - /** - * Solr host. Ignored if "zk-host" is set. - */ - private String host = "http://127.0.0.1:8983/solr"; - - /** - * ZooKeeper host address in the form HOST:PORT. - */ - private String zkHost; - - public String getHost() { - return this.host; - } - - public void setHost(String host) { - this.host = host; - } - - public String getZkHost() { - return this.zkHost; - } - - public void setZkHost(String zkHost) { - this.zkHost = zkHost; - } - -} diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/solr/package-info.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/solr/package-info.java deleted file mode 100644 index e771482a1e..0000000000 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/solr/package-info.java +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Copyright 2012-2019 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** - * Auto-configuration for Solr. - */ -package org.springframework.boot.autoconfigure.solr; diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports b/spring-boot-project/spring-boot-autoconfigure/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports index 1b4cfa2d40..beb66e6521 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports @@ -99,7 +99,6 @@ org.springframework.boot.autoconfigure.security.oauth2.client.servlet.OAuth2Clie org.springframework.boot.autoconfigure.security.oauth2.client.reactive.ReactiveOAuth2ClientAutoConfiguration org.springframework.boot.autoconfigure.security.oauth2.resource.servlet.OAuth2ResourceServerAutoConfiguration org.springframework.boot.autoconfigure.security.oauth2.resource.reactive.ReactiveOAuth2ResourceServerAutoConfiguration -org.springframework.boot.autoconfigure.solr.SolrAutoConfiguration org.springframework.boot.autoconfigure.sql.init.SqlInitializationAutoConfiguration org.springframework.boot.autoconfigure.task.TaskExecutionAutoConfiguration org.springframework.boot.autoconfigure.task.TaskSchedulingAutoConfiguration diff --git a/spring-boot-project/spring-boot-dependencies/build.gradle b/spring-boot-project/spring-boot-dependencies/build.gradle index 2709f5c158..779cea3371 100644 --- a/spring-boot-project/spring-boot-dependencies/build.gradle +++ b/spring-boot-project/spring-boot-dependencies/build.gradle @@ -1360,29 +1360,6 @@ bom { ] } } - library("Solr", "8.11.1") { - group("org.apache.solr") { - modules = [ - "solr-analysis-extras", - "solr-analytics", - "solr-cell", - "solr-core", - "solr-dataimporthandler", - "solr-dataimporthandler-extras", - "solr-gcs-repository", - "solr-jaegertracer-configurator", - "solr-langid", - "solr-ltr", - "solr-prometheus-exporter", - "solr-s3-repository", - "solr-solrj" { - exclude group: "org.slf4j", module: "jcl-over-slf4j" - }, - "solr-test-framework", - "solr-velocity" - ] - } - } library("Spring AMQP", "3.0.0-M3") { group("org.springframework.amqp") { modules = [ diff --git a/spring-boot-project/spring-boot-docs/build.gradle b/spring-boot-project/spring-boot-docs/build.gradle index 3cf635f967..988493520d 100644 --- a/spring-boot-project/spring-boot-docs/build.gradle +++ b/spring-boot-project/spring-boot-docs/build.gradle @@ -95,10 +95,6 @@ dependencies { } implementation("org.apache.kafka:kafka-streams") implementation("org.apache.logging.log4j:log4j-to-slf4j") - implementation("org.apache.solr:solr-solrj") { - exclude group: "commons-logging", module: "commons-logging" - exclude group: "org.slf4j", module: "jcl-over-slf4j" - } implementation("org.apache.tomcat.embed:tomcat-embed-core") implementation("org.assertj:assertj-core") implementation("org.cache2k:cache2k-spring") diff --git a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/actuator/endpoints.adoc b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/actuator/endpoints.adoc index a2c3b3d5bd..1f50114dd4 100644 --- a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/actuator/endpoints.adoc +++ b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/actuator/endpoints.adoc @@ -711,10 +711,6 @@ with the `key` listed in the following table: | `redis` | {spring-boot-actuator-module-code}/redis/RedisHealthIndicator.java[`RedisHealthIndicator`] | Checks that a Redis server is up. - -| `solr` -| {spring-boot-actuator-module-code}/solr/SolrHealthIndicator.java[`SolrHealthIndicator`] -| Checks that a Solr server is up. |=== TIP: You can disable them all by setting the configprop:management.health.defaults.enabled[] property. diff --git a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/anchor-rewrite.properties b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/anchor-rewrite.properties index 2f7c536089..20e6b39918 100644 --- a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/anchor-rewrite.properties +++ b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/anchor-rewrite.properties @@ -252,8 +252,6 @@ boot-features-spring-data-mongo-repositories=features.nosql.mongodb.repositories boot-features-neo4j=features.nosql.neo4j boot-features-connecting-to-neo4j=features.nosql.neo4j.connecting boot-features-spring-data-neo4j-repositories=features.nosql.neo4j.repositories -boot-features-solr=features.nosql.solr -boot-features-connecting-to-solr=features.nosql.solr.connecting boot-features-elasticsearch=features.nosql.elasticsearch boot-features-connecting-to-elasticsearch-rest=features.nosql.elasticsearch.connecting-using-rest boot-features-connecting-to-elasticsearch-reactive-rest=features.nosql.elasticsearch.connecting-using-reactive-rest @@ -808,8 +806,6 @@ features.nosql.mongodb.repositories=data.nosql.mongodb.repositories features.nosql.neo4j=data.nosql.neo4j features.nosql.neo4j.connecting=data.nosql.neo4j.connecting features.nosql.neo4j.repositories=data.nosql.neo4j.repositories -features.nosql.solr=data.nosql.solr -features.nosql.solr.connecting=data.nosql.solr.connecting features.nosql.elasticsearch=data.nosql.elasticsearch features.nosql.elasticsearch.connecting-using-rest=data.nosql.elasticsearch.connecting-using-rest features.nosql.elasticsearch.connecting-using-reactive-rest=data.nosql.elasticsearch.connecting-using-reactive-rest diff --git a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/data/nosql.adoc b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/data/nosql.adoc index c91af38bfe..682b7f7b0b 100644 --- a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/data/nosql.adoc +++ b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/data/nosql.adoc @@ -11,7 +11,7 @@ Spring Data provides additional projects that help you access a variety of NoSQL * {spring-data-couchbase}[Couchbase] * {spring-data-ldap}[LDAP] -Spring Boot provides auto-configuration for Redis, MongoDB, Neo4j, Solr, Elasticsearch, Cassandra, Couchbase, LDAP and InfluxDB. +Spring Boot provides auto-configuration for Redis, MongoDB, Neo4j, Elasticsearch, Cassandra, Couchbase, LDAP and InfluxDB. Additionally, {spring-boot-for-apache-geode}[Spring Boot for Apache Geode] provides {spring-boot-for-apache-geode-docs}#geode-repositories[auto-configuration for Apache Geode]. You can make use of the other projects, but you must configure them yourself. See the appropriate reference documentation at {spring-data}. @@ -196,25 +196,6 @@ include::code:MyNeo4jConfiguration[] -[[data.nosql.solr]] -=== Solr -https://lucene.apache.org/solr/[Apache Solr] is a search engine. -Spring Boot offers basic auto-configuration for the Solr 5 client library. - - - -[[data.nosql.solr.connecting]] -==== Connecting to Solr -You can inject an auto-configured `SolrClient` instance as you would any other Spring bean. -By default, the instance tries to connect to a server at `http://localhost:8983/solr`. -The following example shows how to inject a Solr bean: - -include::code:MyBean[] - -If you add your own `@Bean` of type `SolrClient`, it replaces the default. - - - [[data.nosql.elasticsearch]] === Elasticsearch https://www.elastic.co/products/elasticsearch[Elasticsearch] is an open source, distributed, RESTful search and analytics engine. diff --git a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/data/nosql/solr/connecting/MyBean.java b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/data/nosql/solr/connecting/MyBean.java deleted file mode 100644 index 55c5cc0e9b..0000000000 --- a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/data/nosql/solr/connecting/MyBean.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright 2012-2021 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.boot.docs.data.nosql.solr.connecting; - -import java.io.IOException; - -import org.apache.solr.client.solrj.SolrClient; -import org.apache.solr.client.solrj.SolrServerException; -import org.apache.solr.client.solrj.response.SolrPingResponse; - -import org.springframework.stereotype.Component; - -@Component -public class MyBean { - - private final SolrClient solr; - - public MyBean(SolrClient solr) { - this.solr = solr; - } - - // @fold:on // ... - public SolrPingResponse someMethod() throws SolrServerException, IOException { - return this.solr.ping("users"); - } - // @fold:off - -} diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/data/nosql/solr/connecting/MyBean.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/data/nosql/solr/connecting/MyBean.kt deleted file mode 100644 index 12ff0a3ae4..0000000000 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/data/nosql/solr/connecting/MyBean.kt +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright 2012-2022 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.boot.docs.data.nosql.solr.connecting - -import org.apache.solr.client.solrj.SolrClient -import org.apache.solr.client.solrj.response.SolrPingResponse -import org.springframework.stereotype.Component - -@Component -class MyBean(private val solr: SolrClient) { - - // @fold:on // ... - fun someMethod(): SolrPingResponse { - return solr.ping("users") - } - // @fold:off - -} \ No newline at end of file