Skip to content

Commit 6d50e65

Browse files
committed
Revert "Add support for InfluxDB 2.x"
This reverts commit 52fedb2. See gh-25891
1 parent 4d30eb4 commit 6d50e65

File tree

6 files changed

+14
-142
lines changed

6 files changed

+14
-142
lines changed

spring-boot-project/spring-boot-autoconfigure/build.gradle

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ dependencies {
2323
optional("com.hazelcast:hazelcast")
2424
optional("com.hazelcast:hazelcast-spring")
2525
optional("com.h2database:h2")
26-
optional("com.influxdb:influxdb-client-java")
2726
optional("com.nimbusds:oauth2-oidc-sdk")
2827
optional("com.oracle.database.jdbc:ojdbc8")
2928
optional("com.oracle.database.jdbc:ucp")

spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/influx/InfluxDbAutoConfiguration.java

Lines changed: 12 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,6 @@
1616

1717
package org.springframework.boot.autoconfigure.influx;
1818

19-
import com.influxdb.client.InfluxDBClient;
20-
import com.influxdb.client.InfluxDBClientFactory;
21-
import com.influxdb.client.InfluxDBClientOptions;
22-
import com.influxdb.client.InfluxDBClientOptions.Builder;
2319
import okhttp3.OkHttpClient;
2420
import org.influxdb.InfluxDB;
2521
import org.influxdb.impl.InfluxDBImpl;
@@ -32,7 +28,6 @@
3228
import org.springframework.boot.context.properties.EnableConfigurationProperties;
3329
import org.springframework.context.annotation.Bean;
3430
import org.springframework.context.annotation.Configuration;
35-
import org.springframework.util.StringUtils;
3631

3732
/**
3833
* {@link EnableAutoConfiguration Auto-configuration} for InfluxDB.
@@ -43,51 +38,26 @@
4338
* @since 2.0.0
4439
*/
4540
@Configuration(proxyBeanMethods = false)
46-
@ConditionalOnProperty("spring.influx.url")
41+
@ConditionalOnClass(InfluxDB.class)
4742
@EnableConfigurationProperties(InfluxDbProperties.class)
4843
public class InfluxDbAutoConfiguration {
4944

45+
@Bean
46+
@ConditionalOnMissingBean
47+
@ConditionalOnProperty("spring.influx.url")
48+
public InfluxDB influxDb(InfluxDbProperties properties, ObjectProvider<InfluxDbOkHttpClientBuilderProvider> builder,
49+
ObjectProvider<InfluxDbCustomizer> customizers) {
50+
InfluxDB influxDb = new InfluxDBImpl(properties.getUrl(), properties.getUser(), properties.getPassword(),
51+
determineBuilder(builder.getIfAvailable()));
52+
customizers.orderedStream().forEach((customizer) -> customizer.customize(influxDb));
53+
return influxDb;
54+
}
55+
5056
private static OkHttpClient.Builder determineBuilder(InfluxDbOkHttpClientBuilderProvider builder) {
5157
if (builder != null) {
5258
return builder.get();
5359
}
5460
return new OkHttpClient.Builder();
5561
}
5662

57-
@Configuration(proxyBeanMethods = false)
58-
@ConditionalOnClass(InfluxDB.class)
59-
static class Influx1xConfiguration {
60-
61-
@Bean
62-
@ConditionalOnMissingBean
63-
InfluxDB influxDb(InfluxDbProperties properties, ObjectProvider<InfluxDbOkHttpClientBuilderProvider> builder,
64-
ObjectProvider<InfluxDbCustomizer> customizers) {
65-
InfluxDB influxDb = new InfluxDBImpl(properties.getUrl(), properties.getUser(), properties.getPassword(),
66-
determineBuilder(builder.getIfAvailable()));
67-
customizers.orderedStream().forEach((customizer) -> customizer.customize(influxDb));
68-
return influxDb;
69-
}
70-
71-
}
72-
73-
@Configuration(proxyBeanMethods = false)
74-
@ConditionalOnClass(InfluxDBClient.class)
75-
static class Influx2xConfiguration {
76-
77-
@Bean
78-
@ConditionalOnMissingBean
79-
InfluxDBClient influxDbClient(InfluxDbProperties properties,
80-
ObjectProvider<InfluxDbOkHttpClientBuilderProvider> httpClientBuilder,
81-
ObjectProvider<InfluxDbClientOptionsBuilderCustomizer> customizers) {
82-
Builder builder = InfluxDBClientOptions.builder().url(properties.getUrl());
83-
if (StringUtils.hasText(properties.getUser()) && StringUtils.hasText(properties.getPassword())) {
84-
builder.authenticate(properties.getUser(), properties.getPassword().toCharArray());
85-
}
86-
builder.okHttpClient(determineBuilder(httpClientBuilder.getIfAvailable()));
87-
customizers.orderedStream().forEach((customizer) -> customizer.customize(builder));
88-
return InfluxDBClientFactory.create(builder.build());
89-
}
90-
91-
}
92-
9363
}

spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/influx/InfluxDbClientOptionsBuilderCustomizer.java

Lines changed: 0 additions & 39 deletions
This file was deleted.

spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/influx/InfluxDbAutoConfigurationTests.java

Lines changed: 0 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -17,20 +17,15 @@
1717
package org.springframework.boot.autoconfigure.influx;
1818

1919
import java.util.concurrent.TimeUnit;
20-
import java.util.function.Consumer;
2120

22-
import com.influxdb.client.InfluxDBClient;
23-
import com.influxdb.client.InfluxDBClientOptions;
2421
import okhttp3.OkHttpClient;
25-
import org.assertj.core.api.InstanceOfAssertFactories;
2622
import org.influxdb.InfluxDB;
2723
import org.junit.jupiter.api.Test;
2824
import retrofit2.Retrofit;
2925

3026
import org.springframework.boot.autoconfigure.AutoConfigurations;
3127
import org.springframework.boot.test.context.assertj.AssertableApplicationContext;
3228
import org.springframework.boot.test.context.runner.ApplicationContextRunner;
33-
import org.springframework.boot.test.context.runner.ContextConsumer;
3429
import org.springframework.context.annotation.Bean;
3530
import org.springframework.context.annotation.Configuration;
3631
import org.springframework.test.util.ReflectionTestUtils;
@@ -91,59 +86,13 @@ void influxDbWithCustomizer() {
9186
});
9287
}
9388

94-
@Test
95-
void influxDbClientRequiresUrl() {
96-
this.contextRunner.run((context) -> assertThat(context).doesNotHaveBean(InfluxDBClient.class));
97-
}
98-
99-
@Test
100-
void influxDbClientCanBeCustomized() {
101-
this.contextRunner
102-
.withPropertyValues("spring.influx.url=http://localhost", "spring.influx.user=user",
103-
"spring.influx.password=password")
104-
.run((context) -> assertThat(context).hasSingleBean(InfluxDBClient.class));
105-
}
106-
107-
@Test
108-
void influxDbClientCanBeCreatedWithoutCredentials() {
109-
this.contextRunner.withPropertyValues("spring.influx.url=http://localhost").run(assertInfluxDbClientOptions(
110-
(options) -> assertThat(options.getOkHttpClient().build().readTimeoutMillis()).isEqualTo(10000)));
111-
}
112-
113-
@Test
114-
void influxDbClientWithOkHttpClientBuilderProvider() {
115-
this.contextRunner.withUserConfiguration(CustomOkHttpClientBuilderProviderConfig.class)
116-
.withPropertyValues("spring.influx.url=http://localhost")
117-
.run(assertInfluxDbClientOptions(
118-
(options) -> assertThat(options.getOkHttpClient().build().readTimeoutMillis())
119-
.isEqualTo(40000)));
120-
}
121-
122-
@Test
123-
void influxDbClientWithCustomizer() {
124-
this.contextRunner
125-
.withBean(InfluxDbClientOptionsBuilderCustomizer.class, () -> (options) -> options.org("my_org"))
126-
.withPropertyValues("spring.influx.url=http://localhost")
127-
.run(assertInfluxDbClientOptions((options) -> assertThat(options.getOrg()).isEqualTo("my_org")));
128-
}
129-
13089
private int getReadTimeoutProperty(AssertableApplicationContext context) {
13190
InfluxDB influxDb = context.getBean(InfluxDB.class);
13291
Retrofit retrofit = (Retrofit) ReflectionTestUtils.getField(influxDb, "retrofit");
13392
OkHttpClient callFactory = (OkHttpClient) retrofit.callFactory();
13493
return callFactory.readTimeoutMillis();
13594
}
13695

137-
private ContextConsumer<AssertableApplicationContext> assertInfluxDbClientOptions(
138-
Consumer<InfluxDBClientOptions> options) {
139-
return (context) -> {
140-
assertThat(context).hasSingleBean(InfluxDBClient.class);
141-
assertThat(context).getBean(InfluxDBClient.class)
142-
.extracting("options", InstanceOfAssertFactories.type(InfluxDBClientOptions.class))
143-
.satisfies(options);
144-
};
145-
}
146-
14796
@Configuration(proxyBeanMethods = false)
14897
static class CustomOkHttpClientBuilderProviderConfig {
14998

spring-boot-project/spring-boot-dependencies/build.gradle

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -526,13 +526,6 @@ bom {
526526
]
527527
}
528528
}
529-
library("InfluxDB Client Java", "2.3.0") {
530-
group("com.influxdb") {
531-
modules = [
532-
"influxdb-client-java"
533-
]
534-
}
535-
}
536529
library("InfluxDB Java", "2.21") {
537530
group("org.influxdb") {
538531
modules = [

spring-boot-project/spring-boot-docs/src/docs/asciidoc/data/nosql.adoc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -634,7 +634,7 @@ https://www.influxdata.com/[InfluxDB] is an open-source time series database opt
634634

635635
[[data.nosql.influxdb.connecting]]
636636
==== Connecting to InfluxDB
637-
Spring Boot auto-configures a client instance, provided that either `influxdb-java` (Influx 1.x) or `influxdb-client-java` (Influx 2.x) is on the classpath and the URL of the database is set, as shown in the following example:
637+
Spring Boot auto-configures an `InfluxDB` instance, provided the `influxdb-java` client is on the classpath and the URL of the database is set, as shown in the following example:
638638

639639
[source,yaml,indent=0,subs="verbatim",configprops,configblocks]
640640
----
@@ -648,4 +648,4 @@ If the connection to InfluxDB requires a user and password, you can set the `spr
648648
InfluxDB relies on OkHttp.
649649
If you need to tune the http client `InfluxDB` uses behind the scenes, you can register an `InfluxDbOkHttpClientBuilderProvider` bean.
650650

651-
If you need more control over the configuration, consider registering an `InfluxDbCustomizer` (Influx 1.x), or an `InfluxDbClientOptionsBuilderCustomizer` (Influx 2.x) bean.
651+
If you need more control over the configuration, consider registering an `InfluxDbCustomizer` bean.

0 commit comments

Comments
 (0)