Commit 1e44aba7 authored by Phillip Webb's avatar Phillip Webb

Fix compiler warnings and polish

Fix various compiler warnings and apply a little polish.
parent 47543863
...@@ -43,6 +43,8 @@ import org.springframework.context.annotation.Configuration; ...@@ -43,6 +43,8 @@ import org.springframework.context.annotation.Configuration;
* *
* @author Stephane Nicoll * @author Stephane Nicoll
* @since 2.1.0 * @since 2.1.0
* @deprecated since 2.2.0 as {@literal org.elasticsearch.client:transport} has been
* deprecated upstream
*/ */
@Configuration(proxyBeanMethods = false) @Configuration(proxyBeanMethods = false)
@ConditionalOnClass(Client.class) @ConditionalOnClass(Client.class)
...@@ -51,6 +53,7 @@ import org.springframework.context.annotation.Configuration; ...@@ -51,6 +53,7 @@ import org.springframework.context.annotation.Configuration;
@AutoConfigureBefore(HealthIndicatorAutoConfiguration.class) @AutoConfigureBefore(HealthIndicatorAutoConfiguration.class)
@AutoConfigureAfter(ElasticsearchAutoConfiguration.class) @AutoConfigureAfter(ElasticsearchAutoConfiguration.class)
@EnableConfigurationProperties(ElasticsearchHealthIndicatorProperties.class) @EnableConfigurationProperties(ElasticsearchHealthIndicatorProperties.class)
@Deprecated
public class ElasticSearchClientHealthIndicatorAutoConfiguration extends public class ElasticSearchClientHealthIndicatorAutoConfiguration extends
CompositeHealthIndicatorConfiguration<ElasticsearchHealthIndicator, Client> { CompositeHealthIndicatorConfiguration<ElasticsearchHealthIndicator, Client> {
......
...@@ -50,6 +50,7 @@ import org.springframework.context.annotation.Configuration; ...@@ -50,6 +50,7 @@ import org.springframework.context.annotation.Configuration;
@AutoConfigureBefore(HealthIndicatorAutoConfiguration.class) @AutoConfigureBefore(HealthIndicatorAutoConfiguration.class)
@AutoConfigureAfter({ JestAutoConfiguration.class, @AutoConfigureAfter({ JestAutoConfiguration.class,
ElasticSearchClientHealthIndicatorAutoConfiguration.class }) ElasticSearchClientHealthIndicatorAutoConfiguration.class })
@Deprecated
public class ElasticSearchJestHealthIndicatorAutoConfiguration extends public class ElasticSearchJestHealthIndicatorAutoConfiguration extends
CompositeHealthIndicatorConfiguration<ElasticsearchJestHealthIndicator, JestClient> { CompositeHealthIndicatorConfiguration<ElasticsearchJestHealthIndicator, JestClient> {
......
...@@ -50,6 +50,7 @@ import org.springframework.context.annotation.Configuration; ...@@ -50,6 +50,7 @@ import org.springframework.context.annotation.Configuration;
@AutoConfigureBefore(HealthIndicatorAutoConfiguration.class) @AutoConfigureBefore(HealthIndicatorAutoConfiguration.class)
@AutoConfigureAfter({ RestClientAutoConfiguration.class, @AutoConfigureAfter({ RestClientAutoConfiguration.class,
ElasticSearchClientHealthIndicatorAutoConfiguration.class }) ElasticSearchClientHealthIndicatorAutoConfiguration.class })
@SuppressWarnings("deprecation")
public class ElasticSearchRestHealthIndicatorAutoConfiguration extends public class ElasticSearchRestHealthIndicatorAutoConfiguration extends
CompositeHealthIndicatorConfiguration<ElasticsearchRestHealthIndicator, RestClient> { CompositeHealthIndicatorConfiguration<ElasticsearchRestHealthIndicator, RestClient> {
......
...@@ -22,6 +22,7 @@ import java.util.List; ...@@ -22,6 +22,7 @@ import java.util.List;
import org.springframework.boot.actuate.elasticsearch.ElasticsearchHealthIndicator; import org.springframework.boot.actuate.elasticsearch.ElasticsearchHealthIndicator;
import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.context.properties.DeprecatedConfigurationProperty;
/** /**
* External configuration properties for {@link ElasticsearchHealthIndicator}. * External configuration properties for {@link ElasticsearchHealthIndicator}.
...@@ -29,9 +30,12 @@ import org.springframework.boot.context.properties.ConfigurationProperties; ...@@ -29,9 +30,12 @@ import org.springframework.boot.context.properties.ConfigurationProperties;
* @author Binwei Yang * @author Binwei Yang
* @author Andy Wilkinson * @author Andy Wilkinson
* @since 2.0.0 * @since 2.0.0
* @deprecated since 2.2.0 as {@literal org.elasticsearch.client:transport} has been
* deprecated upstream
*/ */
@ConfigurationProperties(prefix = "management.health.elasticsearch", @ConfigurationProperties(prefix = "management.health.elasticsearch",
ignoreUnknownFields = false) ignoreUnknownFields = false)
@Deprecated
public class ElasticsearchHealthIndicatorProperties { public class ElasticsearchHealthIndicatorProperties {
/** /**
...@@ -44,6 +48,8 @@ public class ElasticsearchHealthIndicatorProperties { ...@@ -44,6 +48,8 @@ public class ElasticsearchHealthIndicatorProperties {
*/ */
private Duration responseTimeout = Duration.ofMillis(100); private Duration responseTimeout = Duration.ofMillis(100);
@DeprecatedConfigurationProperty(
reason = "Upstream elasticsearch transport is deprected")
public List<String> getIndices() { public List<String> getIndices() {
return this.indices; return this.indices;
} }
...@@ -52,6 +58,8 @@ public class ElasticsearchHealthIndicatorProperties { ...@@ -52,6 +58,8 @@ public class ElasticsearchHealthIndicatorProperties {
this.indices = indices; this.indices = indices;
} }
@DeprecatedConfigurationProperty(
reason = "Upstream elasticsearch transport is deprected")
public Duration getResponseTimeout() { public Duration getResponseTimeout() {
return this.responseTimeout; return this.responseTimeout;
} }
......
...@@ -36,6 +36,7 @@ import static org.mockito.Mockito.mock; ...@@ -36,6 +36,7 @@ import static org.mockito.Mockito.mock;
* *
* @author Phillip Webb * @author Phillip Webb
*/ */
@Deprecated
public class ElasticsearchHealthIndicatorAutoConfigurationTests { public class ElasticsearchHealthIndicatorAutoConfigurationTests {
private ApplicationContextRunner contextRunner = new ApplicationContextRunner() private ApplicationContextRunner contextRunner = new ApplicationContextRunner()
......
/* /*
* Copyright 2012-2018 the original author or authors. * Copyright 2012-2019 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
...@@ -25,7 +25,6 @@ import org.springframework.boot.actuate.health.ReactiveHealthEndpointWebExtensio ...@@ -25,7 +25,6 @@ import org.springframework.boot.actuate.health.ReactiveHealthEndpointWebExtensio
import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.cassandra.CassandraAutoConfiguration; import org.springframework.boot.autoconfigure.cassandra.CassandraAutoConfiguration;
import org.springframework.boot.autoconfigure.data.cassandra.CassandraDataAutoConfiguration; import org.springframework.boot.autoconfigure.data.cassandra.CassandraDataAutoConfiguration;
import org.springframework.boot.autoconfigure.data.elasticsearch.ElasticsearchAutoConfiguration;
import org.springframework.boot.autoconfigure.data.elasticsearch.ElasticsearchDataAutoConfiguration; import org.springframework.boot.autoconfigure.data.elasticsearch.ElasticsearchDataAutoConfiguration;
import org.springframework.boot.autoconfigure.data.mongo.MongoDataAutoConfiguration; import org.springframework.boot.autoconfigure.data.mongo.MongoDataAutoConfiguration;
import org.springframework.boot.autoconfigure.data.mongo.MongoReactiveDataAutoConfiguration; import org.springframework.boot.autoconfigure.data.mongo.MongoReactiveDataAutoConfiguration;
...@@ -35,7 +34,6 @@ import org.springframework.boot.autoconfigure.data.redis.RedisAutoConfiguration; ...@@ -35,7 +34,6 @@ import org.springframework.boot.autoconfigure.data.redis.RedisAutoConfiguration;
import org.springframework.boot.autoconfigure.data.redis.RedisRepositoriesAutoConfiguration; import org.springframework.boot.autoconfigure.data.redis.RedisRepositoriesAutoConfiguration;
import org.springframework.boot.autoconfigure.data.rest.RepositoryRestMvcAutoConfiguration; import org.springframework.boot.autoconfigure.data.rest.RepositoryRestMvcAutoConfiguration;
import org.springframework.boot.autoconfigure.data.solr.SolrRepositoriesAutoConfiguration; import org.springframework.boot.autoconfigure.data.solr.SolrRepositoriesAutoConfiguration;
import org.springframework.boot.autoconfigure.elasticsearch.jest.JestAutoConfiguration;
import org.springframework.boot.autoconfigure.flyway.FlywayAutoConfiguration; import org.springframework.boot.autoconfigure.flyway.FlywayAutoConfiguration;
import org.springframework.boot.autoconfigure.hazelcast.HazelcastAutoConfiguration; import org.springframework.boot.autoconfigure.hazelcast.HazelcastAutoConfiguration;
import org.springframework.boot.autoconfigure.liquibase.LiquibaseAutoConfiguration; import org.springframework.boot.autoconfigure.liquibase.LiquibaseAutoConfiguration;
...@@ -86,12 +84,14 @@ public class WebEndpointsAutoConfigurationIntegrationTests { ...@@ -86,12 +84,14 @@ public class WebEndpointsAutoConfigurationIntegrationTests {
MongoDataAutoConfiguration.class, MongoReactiveAutoConfiguration.class, MongoDataAutoConfiguration.class, MongoReactiveAutoConfiguration.class,
MongoReactiveDataAutoConfiguration.class, MongoReactiveDataAutoConfiguration.class,
RepositoryRestMvcAutoConfiguration.class, HazelcastAutoConfiguration.class, RepositoryRestMvcAutoConfiguration.class, HazelcastAutoConfiguration.class,
ElasticsearchAutoConfiguration.class, org.springframework.boot.autoconfigure.data.elasticsearch.ElasticsearchAutoConfiguration.class,
ElasticsearchDataAutoConfiguration.class, JestAutoConfiguration.class, ElasticsearchDataAutoConfiguration.class,
org.springframework.boot.autoconfigure.elasticsearch.jest.JestAutoConfiguration.class,
SolrRepositoriesAutoConfiguration.class, SolrAutoConfiguration.class, SolrRepositoriesAutoConfiguration.class, SolrAutoConfiguration.class,
RedisAutoConfiguration.class, RedisRepositoriesAutoConfiguration.class, RedisAutoConfiguration.class, RedisRepositoriesAutoConfiguration.class,
MetricsAutoConfiguration.class }) MetricsAutoConfiguration.class })
@SpringBootConfiguration @SpringBootConfiguration
@SuppressWarnings("deprecation")
public static class WebEndpointTestApplication { public static class WebEndpointTestApplication {
} }
......
...@@ -84,7 +84,6 @@ public class MeterRegistryConfigurerIntegrationTests { ...@@ -84,7 +84,6 @@ public class MeterRegistryConfigurerIntegrationTests {
Logger logger = ((LoggerContext) StaticLoggerBinder.getSingleton() Logger logger = ((LoggerContext) StaticLoggerBinder.getSingleton()
.getLoggerFactory()).getLogger("test-logger"); .getLoggerFactory()).getLogger("test-logger");
logger.error("Error."); logger.error("Error.");
Map<String, MeterRegistry> registriesByName = context Map<String, MeterRegistry> registriesByName = context
.getBeansOfType(MeterRegistry.class); .getBeansOfType(MeterRegistry.class);
assertThat(registriesByName).hasSize(1); assertThat(registriesByName).hasSize(1);
......
...@@ -35,7 +35,8 @@ import org.springframework.util.StringUtils; ...@@ -35,7 +35,8 @@ import org.springframework.util.StringUtils;
* @author Binwei Yang * @author Binwei Yang
* @author Andy Wilkinson * @author Andy Wilkinson
* @since 2.0.0 * @since 2.0.0
* @deprecated the transport client support is deprecated in favor of other clients * @deprecated since 2.2.0 as {@literal org.elasticsearch.client:transport} has been
* deprecated upstream
*/ */
@Deprecated @Deprecated
public class ElasticsearchHealthIndicator extends AbstractHealthIndicator { public class ElasticsearchHealthIndicator extends AbstractHealthIndicator {
......
...@@ -49,6 +49,7 @@ import static org.mockito.BDDMockito.given; ...@@ -49,6 +49,7 @@ import static org.mockito.BDDMockito.given;
* *
* @author Andy Wilkinson * @author Andy Wilkinson
*/ */
@Deprecated
public class ElasticsearchHealthIndicatorTests { public class ElasticsearchHealthIndicatorTests {
@Mock @Mock
......
...@@ -20,7 +20,6 @@ import java.util.Arrays; ...@@ -20,7 +20,6 @@ import java.util.Arrays;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import org.springframework.beans.factory.config.PropertyPlaceholderConfigurer;
import org.springframework.boot.actuate.endpoint.invoke.ParameterValueMapper; import org.springframework.boot.actuate.endpoint.invoke.ParameterValueMapper;
import org.springframework.boot.actuate.endpoint.invoke.convert.ConversionServiceParameterValueMapper; import org.springframework.boot.actuate.endpoint.invoke.convert.ConversionServiceParameterValueMapper;
import org.springframework.boot.actuate.endpoint.web.EndpointMediaTypes; import org.springframework.boot.actuate.endpoint.web.EndpointMediaTypes;
...@@ -28,6 +27,7 @@ import org.springframework.boot.web.embedded.tomcat.TomcatEmbeddedWebappClassLoa ...@@ -28,6 +27,7 @@ import org.springframework.boot.web.embedded.tomcat.TomcatEmbeddedWebappClassLoa
import org.springframework.context.ApplicationContext; import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.context.support.PropertySourcesPlaceholderConfigurer;
import org.springframework.core.convert.support.DefaultConversionService; import org.springframework.core.convert.support.DefaultConversionService;
import static org.mockito.Mockito.mock; import static org.mockito.Mockito.mock;
...@@ -73,8 +73,8 @@ class BaseConfiguration { ...@@ -73,8 +73,8 @@ class BaseConfiguration {
} }
@Bean @Bean
public PropertyPlaceholderConfigurer propertyPlaceholderConfigurer() { public PropertySourcesPlaceholderConfigurer propertySourcesPlaceholderConfigurer() {
return new PropertyPlaceholderConfigurer(); return new PropertySourcesPlaceholderConfigurer();
} }
} }
/* /*
* Copyright 2012-2018 the original author or authors. * Copyright 2012-2019 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
...@@ -22,6 +22,7 @@ import org.springframework.beans.BeansException; ...@@ -22,6 +22,7 @@ import org.springframework.beans.BeansException;
import org.springframework.beans.factory.BeanFactory; import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.BeanFactoryAware; import org.springframework.beans.factory.BeanFactoryAware;
import org.springframework.beans.factory.support.BeanDefinitionRegistry; import org.springframework.beans.factory.support.BeanDefinitionRegistry;
import org.springframework.beans.factory.support.BeanNameGenerator;
import org.springframework.boot.autoconfigure.AutoConfigurationPackages; import org.springframework.boot.autoconfigure.AutoConfigurationPackages;
import org.springframework.context.EnvironmentAware; import org.springframework.context.EnvironmentAware;
import org.springframework.context.ResourceLoaderAware; import org.springframework.context.ResourceLoaderAware;
...@@ -45,7 +46,7 @@ import org.springframework.data.util.Streamable; ...@@ -45,7 +46,7 @@ import org.springframework.data.util.Streamable;
* @author Oliver Gierke * @author Oliver Gierke
*/ */
public abstract class AbstractRepositoryConfigurationSourceSupport public abstract class AbstractRepositoryConfigurationSourceSupport
implements BeanFactoryAware, ImportBeanDefinitionRegistrar, ResourceLoaderAware, implements ImportBeanDefinitionRegistrar, BeanFactoryAware, ResourceLoaderAware,
EnvironmentAware { EnvironmentAware {
private ResourceLoader resourceLoader; private ResourceLoader resourceLoader;
...@@ -56,30 +57,20 @@ public abstract class AbstractRepositoryConfigurationSourceSupport ...@@ -56,30 +57,20 @@ public abstract class AbstractRepositoryConfigurationSourceSupport
@Override @Override
public void registerBeanDefinitions(AnnotationMetadata importingClassMetadata, public void registerBeanDefinitions(AnnotationMetadata importingClassMetadata,
BeanDefinitionRegistry registry) { BeanDefinitionRegistry registry, BeanNameGenerator importBeanNameGenerator) {
new RepositoryConfigurationDelegate(getConfigurationSource(registry), RepositoryConfigurationDelegate delegate = new RepositoryConfigurationDelegate(
this.resourceLoader, this.environment).registerRepositoriesIn(registry, getConfigurationSource(registry, importBeanNameGenerator),
getRepositoryConfigurationExtension()); this.resourceLoader, this.environment);
delegate.registerRepositoriesIn(registry, getRepositoryConfigurationExtension());
} }
private AnnotationRepositoryConfigurationSource getConfigurationSource( private AnnotationRepositoryConfigurationSource getConfigurationSource(
BeanDefinitionRegistry beanDefinitionRegistry) { BeanDefinitionRegistry registry, BeanNameGenerator importBeanNameGenerator) {
StandardAnnotationMetadata metadata = new StandardAnnotationMetadata( StandardAnnotationMetadata metadata = new StandardAnnotationMetadata(
getConfiguration(), true); getConfiguration(), true);
return new AnnotationRepositoryConfigurationSource(metadata, getAnnotation(), return new AutoConfiguredAnnotationRepositoryConfigurationSource(metadata,
this.resourceLoader, this.environment, beanDefinitionRegistry) { getAnnotation(), this.resourceLoader, this.environment, registry,
@Override importBeanNameGenerator) {
public Streamable<String> getBasePackages() {
return AbstractRepositoryConfigurationSourceSupport.this
.getBasePackages();
}
@Override
public BootstrapMode getBootstrapMode() {
return AbstractRepositoryConfigurationSourceSupport.this
.getBootstrapMode();
}
}; };
} }
...@@ -129,4 +120,29 @@ public abstract class AbstractRepositoryConfigurationSourceSupport ...@@ -129,4 +120,29 @@ public abstract class AbstractRepositoryConfigurationSourceSupport
this.environment = environment; this.environment = environment;
} }
/**
* An auto-configured {@link AnnotationRepositoryConfigurationSource}.
*/
private class AutoConfiguredAnnotationRepositoryConfigurationSource
extends AnnotationRepositoryConfigurationSource {
AutoConfiguredAnnotationRepositoryConfigurationSource(AnnotationMetadata metadata,
Class<? extends Annotation> annotation, ResourceLoader resourceLoader,
Environment environment, BeanDefinitionRegistry registry,
BeanNameGenerator generator) {
super(metadata, annotation, resourceLoader, environment, registry, generator);
}
@Override
public Streamable<String> getBasePackages() {
return AbstractRepositoryConfigurationSourceSupport.this.getBasePackages();
}
@Override
public BootstrapMode getBootstrapMode() {
return AbstractRepositoryConfigurationSourceSupport.this.getBootstrapMode();
}
}
} }
...@@ -42,7 +42,7 @@ import org.springframework.data.cassandra.repository.support.ReactiveCassandraRe ...@@ -42,7 +42,7 @@ import org.springframework.data.cassandra.repository.support.ReactiveCassandraRe
@ConditionalOnClass({ ReactiveSession.class, ReactiveCassandraRepository.class }) @ConditionalOnClass({ ReactiveSession.class, ReactiveCassandraRepository.class })
@ConditionalOnRepositoryType(store = "cassandra", type = RepositoryType.REACTIVE) @ConditionalOnRepositoryType(store = "cassandra", type = RepositoryType.REACTIVE)
@ConditionalOnMissingBean(ReactiveCassandraRepositoryFactoryBean.class) @ConditionalOnMissingBean(ReactiveCassandraRepositoryFactoryBean.class)
@Import(CassandraReactiveRepositoriesAutoConfigureRegistrar.class) @Import(CassandraReactiveRepositoriesRegistrar.class)
@AutoConfigureAfter(CassandraReactiveDataAutoConfiguration.class) @AutoConfigureAfter(CassandraReactiveDataAutoConfiguration.class)
public class CassandraReactiveRepositoriesAutoConfiguration { public class CassandraReactiveRepositoriesAutoConfiguration {
......
/* /*
* Copyright 2012-2017 the original author or authors. * Copyright 2012-2019 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
...@@ -31,7 +31,7 @@ import org.springframework.data.repository.config.RepositoryConfigurationExtensi ...@@ -31,7 +31,7 @@ import org.springframework.data.repository.config.RepositoryConfigurationExtensi
* @author Eddú Meléndez * @author Eddú Meléndez
* @since 2.0.0 * @since 2.0.0
*/ */
class CassandraReactiveRepositoriesAutoConfigureRegistrar class CassandraReactiveRepositoriesRegistrar
extends AbstractRepositoryConfigurationSourceSupport { extends AbstractRepositoryConfigurationSourceSupport {
@Override @Override
......
...@@ -41,7 +41,7 @@ import org.springframework.data.cassandra.repository.support.CassandraRepository ...@@ -41,7 +41,7 @@ import org.springframework.data.cassandra.repository.support.CassandraRepository
@ConditionalOnClass({ Session.class, CassandraRepository.class }) @ConditionalOnClass({ Session.class, CassandraRepository.class })
@ConditionalOnRepositoryType(store = "cassandra", type = RepositoryType.IMPERATIVE) @ConditionalOnRepositoryType(store = "cassandra", type = RepositoryType.IMPERATIVE)
@ConditionalOnMissingBean(CassandraRepositoryFactoryBean.class) @ConditionalOnMissingBean(CassandraRepositoryFactoryBean.class)
@Import(CassandraRepositoriesAutoConfigureRegistrar.class) @Import(CassandraRepositoriesRegistrar.class)
public class CassandraRepositoriesAutoConfiguration { public class CassandraRepositoriesAutoConfiguration {
} }
/* /*
* Copyright 2012-2017 the original author or authors. * Copyright 2012-2019 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
...@@ -31,7 +31,7 @@ import org.springframework.data.repository.config.RepositoryConfigurationExtensi ...@@ -31,7 +31,7 @@ import org.springframework.data.repository.config.RepositoryConfigurationExtensi
* @author Eddú Meléndez * @author Eddú Meléndez
* @since 1.3.0 * @since 1.3.0
*/ */
class CassandraRepositoriesAutoConfigureRegistrar class CassandraRepositoriesRegistrar
extends AbstractRepositoryConfigurationSourceSupport { extends AbstractRepositoryConfigurationSourceSupport {
@Override @Override
......
...@@ -46,6 +46,7 @@ import org.springframework.data.elasticsearch.repository.config.EnableElasticsea ...@@ -46,6 +46,7 @@ import org.springframework.data.elasticsearch.repository.config.EnableElasticsea
@Configuration(proxyBeanMethods = false) @Configuration(proxyBeanMethods = false)
@ConditionalOnClass({ Client.class, ElasticsearchTemplate.class }) @ConditionalOnClass({ Client.class, ElasticsearchTemplate.class })
@AutoConfigureAfter(ElasticsearchAutoConfiguration.class) @AutoConfigureAfter(ElasticsearchAutoConfiguration.class)
@SuppressWarnings("deprecation")
public class ElasticsearchDataAutoConfiguration { public class ElasticsearchDataAutoConfiguration {
@Bean @Bean
......
...@@ -54,7 +54,7 @@ public class JdbcRepositoriesAutoConfiguration { ...@@ -54,7 +54,7 @@ public class JdbcRepositoriesAutoConfiguration {
@Configuration(proxyBeanMethods = false) @Configuration(proxyBeanMethods = false)
@ConditionalOnMissingBean(JdbcRepositoryConfigExtension.class) @ConditionalOnMissingBean(JdbcRepositoryConfigExtension.class)
@Import(JdbcRepositoriesAutoConfigureRegistrar.class) @Import(JdbcRepositoriesRegistrar.class)
static class JdbcRepositoriesConfiguration { static class JdbcRepositoriesConfiguration {
} }
......
/* /*
* Copyright 2012-2018 the original author or authors. * Copyright 2012-2019 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
...@@ -30,7 +30,7 @@ import org.springframework.data.repository.config.RepositoryConfigurationExtensi ...@@ -30,7 +30,7 @@ import org.springframework.data.repository.config.RepositoryConfigurationExtensi
* *
* @author Andy Wilkinson * @author Andy Wilkinson
*/ */
class JdbcRepositoriesAutoConfigureRegistrar class JdbcRepositoriesRegistrar
extends AbstractRepositoryConfigurationSourceSupport { extends AbstractRepositoryConfigurationSourceSupport {
@Override @Override
......
...@@ -66,7 +66,7 @@ import org.springframework.data.jpa.repository.support.JpaRepositoryFactoryBean; ...@@ -66,7 +66,7 @@ import org.springframework.data.jpa.repository.support.JpaRepositoryFactoryBean;
JpaRepositoryConfigExtension.class }) JpaRepositoryConfigExtension.class })
@ConditionalOnProperty(prefix = "spring.data.jpa.repositories", name = "enabled", @ConditionalOnProperty(prefix = "spring.data.jpa.repositories", name = "enabled",
havingValue = "true", matchIfMissing = true) havingValue = "true", matchIfMissing = true)
@Import(JpaRepositoriesAutoConfigureRegistrar.class) @Import(JpaRepositoriesRegistrar.class)
@AutoConfigureAfter({ HibernateJpaAutoConfiguration.class, @AutoConfigureAfter({ HibernateJpaAutoConfiguration.class,
TaskExecutionAutoConfiguration.class }) TaskExecutionAutoConfiguration.class })
public class JpaRepositoriesAutoConfiguration { public class JpaRepositoriesAutoConfiguration {
......
/* /*
* Copyright 2012-2018 the original author or authors. * Copyright 2012-2019 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
...@@ -35,7 +35,7 @@ import org.springframework.util.StringUtils; ...@@ -35,7 +35,7 @@ import org.springframework.util.StringUtils;
* @author Phillip Webb * @author Phillip Webb
* @author Dave Syer * @author Dave Syer
*/ */
class JpaRepositoriesAutoConfigureRegistrar class JpaRepositoriesRegistrar
extends AbstractRepositoryConfigurationSourceSupport { extends AbstractRepositoryConfigurationSourceSupport {
private BootstrapMode bootstrapMode = null; private BootstrapMode bootstrapMode = null;
......
...@@ -53,7 +53,7 @@ import org.springframework.data.mongodb.repository.support.ReactiveMongoReposito ...@@ -53,7 +53,7 @@ import org.springframework.data.mongodb.repository.support.ReactiveMongoReposito
@ConditionalOnMissingBean({ ReactiveMongoRepositoryFactoryBean.class, @ConditionalOnMissingBean({ ReactiveMongoRepositoryFactoryBean.class,
ReactiveMongoRepositoryConfigurationExtension.class }) ReactiveMongoRepositoryConfigurationExtension.class })
@ConditionalOnRepositoryType(store = "mongodb", type = RepositoryType.REACTIVE) @ConditionalOnRepositoryType(store = "mongodb", type = RepositoryType.REACTIVE)
@Import(MongoReactiveRepositoriesAutoConfigureRegistrar.class) @Import(MongoReactiveRepositoriesRegistrar.class)
@AutoConfigureAfter(MongoReactiveDataAutoConfiguration.class) @AutoConfigureAfter(MongoReactiveDataAutoConfiguration.class)
public class MongoReactiveRepositoriesAutoConfiguration { public class MongoReactiveRepositoriesAutoConfiguration {
......
/* /*
* Copyright 2012-2017 the original author or authors. * Copyright 2012-2019 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
...@@ -31,7 +31,7 @@ import org.springframework.data.repository.config.RepositoryConfigurationExtensi ...@@ -31,7 +31,7 @@ import org.springframework.data.repository.config.RepositoryConfigurationExtensi
* @author Mark Paluch * @author Mark Paluch
* @since 2.0.0 * @since 2.0.0
*/ */
class MongoReactiveRepositoriesAutoConfigureRegistrar class MongoReactiveRepositoriesRegistrar
extends AbstractRepositoryConfigurationSourceSupport { extends AbstractRepositoryConfigurationSourceSupport {
@Override @Override
......
...@@ -57,7 +57,7 @@ import org.springframework.data.mongodb.repository.support.MongoRepositoryFactor ...@@ -57,7 +57,7 @@ import org.springframework.data.mongodb.repository.support.MongoRepositoryFactor
@ConditionalOnMissingBean({ MongoRepositoryFactoryBean.class, @ConditionalOnMissingBean({ MongoRepositoryFactoryBean.class,
MongoRepositoryConfigurationExtension.class }) MongoRepositoryConfigurationExtension.class })
@ConditionalOnRepositoryType(store = "mongodb", type = RepositoryType.IMPERATIVE) @ConditionalOnRepositoryType(store = "mongodb", type = RepositoryType.IMPERATIVE)
@Import(MongoRepositoriesAutoConfigureRegistrar.class) @Import(MongoRepositoriesRegistrar.class)
@AutoConfigureAfter(MongoDataAutoConfiguration.class) @AutoConfigureAfter(MongoDataAutoConfiguration.class)
public class MongoRepositoriesAutoConfiguration { public class MongoRepositoriesAutoConfiguration {
......
/* /*
* Copyright 2012-2017 the original author or authors. * Copyright 2012-2019 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
...@@ -30,7 +30,7 @@ import org.springframework.data.repository.config.RepositoryConfigurationExtensi ...@@ -30,7 +30,7 @@ import org.springframework.data.repository.config.RepositoryConfigurationExtensi
* *
* @author Dave Syer * @author Dave Syer
*/ */
class MongoRepositoriesAutoConfigureRegistrar class MongoRepositoriesRegistrar
extends AbstractRepositoryConfigurationSourceSupport { extends AbstractRepositoryConfigurationSourceSupport {
@Override @Override
......
...@@ -54,7 +54,7 @@ import org.springframework.data.neo4j.repository.support.Neo4jRepositoryFactoryB ...@@ -54,7 +54,7 @@ import org.springframework.data.neo4j.repository.support.Neo4jRepositoryFactoryB
Neo4jRepositoryConfigurationExtension.class }) Neo4jRepositoryConfigurationExtension.class })
@ConditionalOnProperty(prefix = "spring.data.neo4j.repositories", name = "enabled", @ConditionalOnProperty(prefix = "spring.data.neo4j.repositories", name = "enabled",
havingValue = "true", matchIfMissing = true) havingValue = "true", matchIfMissing = true)
@Import(Neo4jRepositoriesAutoConfigureRegistrar.class) @Import(Neo4jRepositoriesRegistrar.class)
@AutoConfigureAfter(Neo4jDataAutoConfiguration.class) @AutoConfigureAfter(Neo4jDataAutoConfiguration.class)
public class Neo4jRepositoriesAutoConfiguration { public class Neo4jRepositoriesAutoConfiguration {
......
/* /*
* Copyright 2012-2017 the original author or authors. * Copyright 2012-2019 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
...@@ -30,7 +30,7 @@ import org.springframework.data.repository.config.RepositoryConfigurationExtensi ...@@ -30,7 +30,7 @@ import org.springframework.data.repository.config.RepositoryConfigurationExtensi
* *
* @author Michael Hunger * @author Michael Hunger
*/ */
class Neo4jRepositoriesAutoConfigureRegistrar class Neo4jRepositoriesRegistrar
extends AbstractRepositoryConfigurationSourceSupport { extends AbstractRepositoryConfigurationSourceSupport {
@Override @Override
......
...@@ -43,7 +43,7 @@ import org.springframework.data.redis.repository.support.RedisRepositoryFactoryB ...@@ -43,7 +43,7 @@ import org.springframework.data.redis.repository.support.RedisRepositoryFactoryB
@ConditionalOnProperty(prefix = "spring.data.redis.repositories", name = "enabled", @ConditionalOnProperty(prefix = "spring.data.redis.repositories", name = "enabled",
havingValue = "true", matchIfMissing = true) havingValue = "true", matchIfMissing = true)
@ConditionalOnMissingBean(RedisRepositoryFactoryBean.class) @ConditionalOnMissingBean(RedisRepositoryFactoryBean.class)
@Import(RedisRepositoriesAutoConfigureRegistrar.class) @Import(RedisRepositoriesRegistrar.class)
@AutoConfigureAfter(RedisAutoConfiguration.class) @AutoConfigureAfter(RedisAutoConfiguration.class)
public class RedisRepositoriesAutoConfiguration { public class RedisRepositoriesAutoConfiguration {
......
/* /*
* Copyright 2012-2017 the original author or authors. * Copyright 2012-2019 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
...@@ -31,7 +31,7 @@ import org.springframework.data.repository.config.RepositoryConfigurationExtensi ...@@ -31,7 +31,7 @@ import org.springframework.data.repository.config.RepositoryConfigurationExtensi
* @author Eddú Meléndez * @author Eddú Meléndez
* @since 1.4.0 * @since 1.4.0
*/ */
class RedisRepositoriesAutoConfigureRegistrar class RedisRepositoriesRegistrar
extends AbstractRepositoryConfigurationSourceSupport { extends AbstractRepositoryConfigurationSourceSupport {
@Override @Override
......
...@@ -79,11 +79,6 @@ public class ServerProperties { ...@@ -79,11 +79,6 @@ public class ServerProperties {
@NestedConfigurationProperty @NestedConfigurationProperty
private final ErrorProperties error = new ErrorProperties(); private final ErrorProperties error = new ErrorProperties();
/**
* Whether X-Forwarded-* headers should be applied to the HttpRequest.
*/
private Boolean useForwardHeaders;
/** /**
* Strategy for handling X-Forwarded-* headers. * Strategy for handling X-Forwarded-* headers.
*/ */
...@@ -139,18 +134,15 @@ public class ServerProperties { ...@@ -139,18 +134,15 @@ public class ServerProperties {
this.address = address; this.address = address;
} }
@DeprecatedConfigurationProperty @DeprecatedConfigurationProperty(reason = "replaced to support additional strategies",
replacement = "server.forward-headers-strategy")
public Boolean isUseForwardHeaders() { public Boolean isUseForwardHeaders() {
return ForwardHeadersStrategy.NATIVE.equals(this.forwardHeadersStrategy); return ForwardHeadersStrategy.NATIVE.equals(this.forwardHeadersStrategy);
} }
public void setUseForwardHeaders(Boolean useForwardHeaders) { public void setUseForwardHeaders(Boolean useForwardHeaders) {
if (useForwardHeaders != null && useForwardHeaders) { this.forwardHeadersStrategy = Boolean.TRUE.equals(useForwardHeaders)
this.forwardHeadersStrategy = ForwardHeadersStrategy.NATIVE; ? ForwardHeadersStrategy.NATIVE : ForwardHeadersStrategy.NONE;
}
else {
this.forwardHeadersStrategy = ForwardHeadersStrategy.NONE;
}
} }
public String getServerHeader() { public String getServerHeader() {
...@@ -1358,6 +1350,9 @@ public class ServerProperties { ...@@ -1358,6 +1350,9 @@ public class ServerProperties {
} }
/**
* Strategies for supporting forward headers.
*/
public enum ForwardHeadersStrategy { public enum ForwardHeadersStrategy {
/** /**
......
...@@ -40,6 +40,7 @@ import static org.mockito.Mockito.mock; ...@@ -40,6 +40,7 @@ import static org.mockito.Mockito.mock;
* @author Phillip Webb * @author Phillip Webb
* @author Andy Wilkinson * @author Andy Wilkinson
*/ */
@Deprecated
public class ElasticsearchAutoConfigurationTests { public class ElasticsearchAutoConfigurationTests {
@ClassRule @ClassRule
......
/* /*
* Copyright 2012-2017 the original author or authors. * Copyright 2012-2019 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
...@@ -36,6 +36,7 @@ import static org.assertj.core.api.Assertions.assertThat; ...@@ -36,6 +36,7 @@ import static org.assertj.core.api.Assertions.assertThat;
* @author Phillip Webb * @author Phillip Webb
* @author Artur Konczak * @author Artur Konczak
*/ */
@SuppressWarnings("deprecation")
public class ElasticsearchDataAutoConfigurationTests { public class ElasticsearchDataAutoConfigurationTests {
@ClassRule @ClassRule
......
...@@ -48,6 +48,7 @@ import static org.mockito.Mockito.mock; ...@@ -48,6 +48,7 @@ import static org.mockito.Mockito.mock;
* @author Stephane Nicoll * @author Stephane Nicoll
* @author Andy Wilkinson * @author Andy Wilkinson
*/ */
@Deprecated
public class JestAutoConfigurationTests { public class JestAutoConfigurationTests {
@ClassRule @ClassRule
......
...@@ -72,8 +72,8 @@ public class RestClientAutoConfigurationTests { ...@@ -72,8 +72,8 @@ public class RestClientAutoConfigurationTests {
.run((context) -> { .run((context) -> {
assertThat(context).hasSingleBean(RestClient.class); assertThat(context).hasSingleBean(RestClient.class);
RestClient restClient = context.getBean(RestClient.class); RestClient restClient = context.getBean(RestClient.class);
assertThat(restClient) assertThat(restClient).hasFieldOrPropertyWithValue("pathPrefix",
.hasFieldOrPropertyWithValue("maxRetryTimeoutMillis", 42L); "/test");
}); });
} }
...@@ -146,7 +146,7 @@ public class RestClientAutoConfigurationTests { ...@@ -146,7 +146,7 @@ public class RestClientAutoConfigurationTests {
@Bean @Bean
public RestClientBuilderCustomizer myCustomizer() { public RestClientBuilderCustomizer myCustomizer() {
return (builder) -> builder.setMaxRetryTimeoutMillis(42); return (builder) -> builder.setPathPrefix("/test");
} }
} }
......
...@@ -47,7 +47,7 @@ public class MongoClientFactoryTests { ...@@ -47,7 +47,7 @@ public class MongoClientFactoryTests {
MongoProperties properties = new MongoProperties(); MongoProperties properties = new MongoProperties();
properties.setPort(12345); properties.setPort(12345);
MongoClient client = createMongoClient(properties); MongoClient client = createMongoClient(properties);
List<ServerAddress> allAddresses = client.getAllAddress(); List<ServerAddress> allAddresses = getAllAddresses(client);
assertThat(allAddresses).hasSize(1); assertThat(allAddresses).hasSize(1);
assertServerAddress(allAddresses.get(0), "localhost", 12345); assertServerAddress(allAddresses.get(0), "localhost", 12345);
} }
...@@ -57,7 +57,7 @@ public class MongoClientFactoryTests { ...@@ -57,7 +57,7 @@ public class MongoClientFactoryTests {
MongoProperties properties = new MongoProperties(); MongoProperties properties = new MongoProperties();
properties.setHost("mongo.example.com"); properties.setHost("mongo.example.com");
MongoClient client = createMongoClient(properties); MongoClient client = createMongoClient(properties);
List<ServerAddress> allAddresses = client.getAllAddress(); List<ServerAddress> allAddresses = getAllAddresses(client);
assertThat(allAddresses).hasSize(1); assertThat(allAddresses).hasSize(1);
assertServerAddress(allAddresses.get(0), "mongo.example.com", 27017); assertServerAddress(allAddresses.get(0), "mongo.example.com", 27017);
} }
...@@ -68,8 +68,7 @@ public class MongoClientFactoryTests { ...@@ -68,8 +68,7 @@ public class MongoClientFactoryTests {
properties.setUsername("user"); properties.setUsername("user");
properties.setPassword("secret".toCharArray()); properties.setPassword("secret".toCharArray());
MongoClient client = createMongoClient(properties); MongoClient client = createMongoClient(properties);
assertMongoCredential(client.getCredentialsList().get(0), "user", "secret", assertMongoCredential(getCredentials(client).get(0), "user", "secret", "test");
"test");
} }
@Test @Test
...@@ -79,8 +78,7 @@ public class MongoClientFactoryTests { ...@@ -79,8 +78,7 @@ public class MongoClientFactoryTests {
properties.setUsername("user"); properties.setUsername("user");
properties.setPassword("secret".toCharArray()); properties.setPassword("secret".toCharArray());
MongoClient client = createMongoClient(properties); MongoClient client = createMongoClient(properties);
assertMongoCredential(client.getCredentialsList().get(0), "user", "secret", assertMongoCredential(getCredentials(client).get(0), "user", "secret", "foo");
"foo");
} }
@Test @Test
...@@ -90,8 +88,7 @@ public class MongoClientFactoryTests { ...@@ -90,8 +88,7 @@ public class MongoClientFactoryTests {
properties.setUsername("user"); properties.setUsername("user");
properties.setPassword("secret".toCharArray()); properties.setPassword("secret".toCharArray());
MongoClient client = createMongoClient(properties); MongoClient client = createMongoClient(properties);
assertMongoCredential(client.getCredentialsList().get(0), "user", "secret", assertMongoCredential(getCredentials(client).get(0), "user", "secret", "foo");
"foo");
} }
@Test @Test
...@@ -100,11 +97,11 @@ public class MongoClientFactoryTests { ...@@ -100,11 +97,11 @@ public class MongoClientFactoryTests {
properties.setUri("mongodb://user:secret@mongo1.example.com:12345," properties.setUri("mongodb://user:secret@mongo1.example.com:12345,"
+ "mongo2.example.com:23456/test"); + "mongo2.example.com:23456/test");
MongoClient client = createMongoClient(properties); MongoClient client = createMongoClient(properties);
List<ServerAddress> allAddresses = client.getAllAddress(); List<ServerAddress> allAddresses = getAllAddresses(client);
assertThat(allAddresses).hasSize(2); assertThat(allAddresses).hasSize(2);
assertServerAddress(allAddresses.get(0), "mongo1.example.com", 12345); assertServerAddress(allAddresses.get(0), "mongo1.example.com", 12345);
assertServerAddress(allAddresses.get(1), "mongo2.example.com", 23456); assertServerAddress(allAddresses.get(1), "mongo2.example.com", 23456);
List<MongoCredential> credentialsList = client.getCredentialsList(); List<MongoCredential> credentialsList = getCredentials(client);
assertThat(credentialsList).hasSize(1); assertThat(credentialsList).hasSize(1);
assertMongoCredential(credentialsList.get(0), "user", "secret", "test"); assertMongoCredential(credentialsList.get(0), "user", "secret", "test");
} }
...@@ -115,7 +112,7 @@ public class MongoClientFactoryTests { ...@@ -115,7 +112,7 @@ public class MongoClientFactoryTests {
properties.setUri("mongodb://mongo.example.com:1234/mydb"); properties.setUri("mongodb://mongo.example.com:1234/mydb");
this.environment.setProperty("local.mongo.port", "4000"); this.environment.setProperty("local.mongo.port", "4000");
MongoClient client = createMongoClient(properties, this.environment); MongoClient client = createMongoClient(properties, this.environment);
List<ServerAddress> allAddresses = client.getAllAddress(); List<ServerAddress> allAddresses = getAllAddresses(client);
assertThat(allAddresses).hasSize(1); assertThat(allAddresses).hasSize(1);
assertServerAddress(allAddresses.get(0), "localhost", 4000); assertServerAddress(allAddresses.get(0), "localhost", 4000);
} }
...@@ -129,6 +126,20 @@ public class MongoClientFactoryTests { ...@@ -129,6 +126,20 @@ public class MongoClientFactoryTests {
return new MongoClientFactory(properties, environment).createMongoClient(null); return new MongoClientFactory(properties, environment).createMongoClient(null);
} }
@SuppressWarnings("deprecation")
private List<ServerAddress> getAllAddresses(MongoClient client) {
// At some point we'll probably need to use reflection to find the address but for
// now, we can use the deprecated getAllAddress method.
return client.getAllAddress();
}
@SuppressWarnings("deprecation")
private List<MongoCredential> getCredentials(MongoClient client) {
// At some point we'll probably need to use reflection to find the credentials but
// for now, we can use the deprecated getCredentialsList method.
return client.getCredentialsList();
}
private void assertServerAddress(ServerAddress serverAddress, String expectedHost, private void assertServerAddress(ServerAddress serverAddress, String expectedHost,
int expectedPort) { int expectedPort) {
assertThat(serverAddress.getHost()).isEqualTo(expectedHost); assertThat(serverAddress.getHost()).isEqualTo(expectedHost);
......
...@@ -118,7 +118,7 @@ public class MongoPropertiesTests { ...@@ -118,7 +118,7 @@ public class MongoPropertiesTests {
properties.setUri("mongodb://mongo1.example.com:12345"); properties.setUri("mongodb://mongo1.example.com:12345");
MongoClient client = new MongoClientFactory(properties, null) MongoClient client = new MongoClientFactory(properties, null)
.createMongoClient(null); .createMongoClient(null);
List<ServerAddress> allAddresses = client.getAllAddress(); List<ServerAddress> allAddresses = getAllAddresses(client);
assertThat(allAddresses).hasSize(1); assertThat(allAddresses).hasSize(1);
assertServerAddress(allAddresses.get(0), "mongo1.example.com", 12345); assertServerAddress(allAddresses.get(0), "mongo1.example.com", 12345);
} }
...@@ -130,7 +130,7 @@ public class MongoPropertiesTests { ...@@ -130,7 +130,7 @@ public class MongoPropertiesTests {
properties.setPort(27017); properties.setPort(27017);
MongoClient client = new MongoClientFactory(properties, null) MongoClient client = new MongoClientFactory(properties, null)
.createMongoClient(null); .createMongoClient(null);
List<ServerAddress> allAddresses = client.getAllAddress(); List<ServerAddress> allAddresses = getAllAddresses(client);
assertThat(allAddresses).hasSize(1); assertThat(allAddresses).hasSize(1);
assertServerAddress(allAddresses.get(0), "localhost", 27017); assertServerAddress(allAddresses.get(0), "localhost", 27017);
} }
...@@ -141,7 +141,7 @@ public class MongoPropertiesTests { ...@@ -141,7 +141,7 @@ public class MongoPropertiesTests {
properties.setUri("mongodb://mongo1.example.com:12345"); properties.setUri("mongodb://mongo1.example.com:12345");
MongoClient client = new MongoClientFactory(properties, null) MongoClient client = new MongoClientFactory(properties, null)
.createMongoClient(null); .createMongoClient(null);
List<ServerAddress> allAddresses = client.getAllAddress(); List<ServerAddress> allAddresses = getAllAddresses(client);
assertThat(allAddresses).hasSize(1); assertThat(allAddresses).hasSize(1);
assertServerAddress(allAddresses.get(0), "mongo1.example.com", 12345); assertServerAddress(allAddresses.get(0), "mongo1.example.com", 12345);
} }
...@@ -151,11 +151,18 @@ public class MongoPropertiesTests { ...@@ -151,11 +151,18 @@ public class MongoPropertiesTests {
MongoProperties properties = new MongoProperties(); MongoProperties properties = new MongoProperties();
MongoClient client = new MongoClientFactory(properties, null) MongoClient client = new MongoClientFactory(properties, null)
.createMongoClient(null); .createMongoClient(null);
List<ServerAddress> allAddresses = client.getAllAddress(); List<ServerAddress> allAddresses = getAllAddresses(client);
assertThat(allAddresses).hasSize(1); assertThat(allAddresses).hasSize(1);
assertServerAddress(allAddresses.get(0), "localhost", 27017); assertServerAddress(allAddresses.get(0), "localhost", 27017);
} }
@SuppressWarnings("deprecation")
private List<ServerAddress> getAllAddresses(MongoClient client) {
// At some point we'll probably need to use reflection to find the address but for
// now, we can use the deprecated getAllAddress method.
return client.getAllAddress();
}
@Test @Test
public void canBindAutoIndexCreation() { public void canBindAutoIndexCreation() {
AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(); AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();
......
...@@ -107,7 +107,7 @@ public class EmbeddedMongoAutoConfigurationTests { ...@@ -107,7 +107,7 @@ public class EmbeddedMongoAutoConfigurationTests {
MongoClient client = this.context.getBean(MongoClient.class); MongoClient client = this.context.getBean(MongoClient.class);
Integer mongoPort = Integer Integer mongoPort = Integer
.valueOf(this.context.getEnvironment().getProperty("local.mongo.port")); .valueOf(this.context.getEnvironment().getProperty("local.mongo.port"));
assertThat(client.getAddress().getPort()).isEqualTo(mongoPort); assertThat(getPort(client)).isEqualTo(mongoPort);
} }
@Test @Test
...@@ -117,7 +117,7 @@ public class EmbeddedMongoAutoConfigurationTests { ...@@ -117,7 +117,7 @@ public class EmbeddedMongoAutoConfigurationTests {
MongoClient client = this.context.getBean(MongoClient.class); MongoClient client = this.context.getBean(MongoClient.class);
Integer mongoPort = Integer Integer mongoPort = Integer
.valueOf(this.context.getEnvironment().getProperty("local.mongo.port")); .valueOf(this.context.getEnvironment().getProperty("local.mongo.port"));
assertThat(client.getAddress().getPort()).isEqualTo(mongoPort); assertThat(getPort(client)).isEqualTo(mongoPort);
} }
@Test @Test
...@@ -126,7 +126,7 @@ public class EmbeddedMongoAutoConfigurationTests { ...@@ -126,7 +126,7 @@ public class EmbeddedMongoAutoConfigurationTests {
MongoClient client = this.context.getBean(MongoClient.class); MongoClient client = this.context.getBean(MongoClient.class);
Integer mongoPort = Integer Integer mongoPort = Integer
.valueOf(this.context.getEnvironment().getProperty("local.mongo.port")); .valueOf(this.context.getEnvironment().getProperty("local.mongo.port"));
assertThat(client.getAddress().getPort()).isEqualTo(mongoPort); assertThat(getPort(client)).isEqualTo(mongoPort);
} }
@Test @Test
...@@ -237,6 +237,13 @@ public class EmbeddedMongoAutoConfigurationTests { ...@@ -237,6 +237,13 @@ public class EmbeddedMongoAutoConfigurationTests {
return File.separatorChar == '\\'; return File.separatorChar == '\\';
} }
@SuppressWarnings("deprecation")
private int getPort(MongoClient client) {
// At some point we'll probably need to use reflection to find the address but for
// now, we can use the deprecated getAddress method.
return client.getAddress().getPort();
}
@Configuration(proxyBeanMethods = false) @Configuration(proxyBeanMethods = false)
static class MongoClientConfiguration { static class MongoClientConfiguration {
......
...@@ -49,6 +49,8 @@ public class JpaPropertiesTests { ...@@ -49,6 +49,8 @@ public class JpaPropertiesTests {
.withUserConfiguration(TestConfiguration.class); .withUserConfiguration(TestConfiguration.class);
@Test @Test
@Deprecated
@SuppressWarnings("deprecation")
public void determineDatabaseNoCheckIfDatabaseIsSet() { public void determineDatabaseNoCheckIfDatabaseIsSet() {
this.contextRunner.withPropertyValues("spring.jpa.database=postgresql") this.contextRunner.withPropertyValues("spring.jpa.database=postgresql")
.run(assertJpaProperties((properties) -> { .run(assertJpaProperties((properties) -> {
...@@ -65,6 +67,8 @@ public class JpaPropertiesTests { ...@@ -65,6 +67,8 @@ public class JpaPropertiesTests {
} }
@Test @Test
@Deprecated
@SuppressWarnings("deprecation")
public void determineDatabaseWithKnownUrl() { public void determineDatabaseWithKnownUrl() {
this.contextRunner.run(assertJpaProperties((properties) -> { this.contextRunner.run(assertJpaProperties((properties) -> {
Database database = properties Database database = properties
...@@ -74,6 +78,8 @@ public class JpaPropertiesTests { ...@@ -74,6 +78,8 @@ public class JpaPropertiesTests {
} }
@Test @Test
@Deprecated
@SuppressWarnings("deprecation")
public void determineDatabaseWithKnownUrlAndUserConfig() { public void determineDatabaseWithKnownUrlAndUserConfig() {
this.contextRunner.withPropertyValues("spring.jpa.database=mysql") this.contextRunner.withPropertyValues("spring.jpa.database=mysql")
.run(assertJpaProperties((properties) -> { .run(assertJpaProperties((properties) -> {
...@@ -84,6 +90,8 @@ public class JpaPropertiesTests { ...@@ -84,6 +90,8 @@ public class JpaPropertiesTests {
} }
@Test @Test
@Deprecated
@SuppressWarnings("deprecation")
public void determineDatabaseWithUnknownUrl() { public void determineDatabaseWithUnknownUrl() {
this.contextRunner.run(assertJpaProperties((properties) -> { this.contextRunner.run(assertJpaProperties((properties) -> {
Database database = properties Database database = properties
......
...@@ -303,7 +303,7 @@ public class ReactiveWebServerFactoryAutoConfigurationTests { ...@@ -303,7 +303,7 @@ public class ReactiveWebServerFactoryAutoConfigurationTests {
static class TomcatProtocolHandlerCustomizerConfiguration { static class TomcatProtocolHandlerCustomizerConfiguration {
@Bean @Bean
public TomcatProtocolHandlerCustomizer protocolHandlerCustomizer() { public TomcatProtocolHandlerCustomizer<?> protocolHandlerCustomizer() {
return (protocolHandler) -> { return (protocolHandler) -> {
}; };
} }
......
...@@ -417,7 +417,7 @@ public class ServletWebServerFactoryAutoConfigurationTests { ...@@ -417,7 +417,7 @@ public class ServletWebServerFactoryAutoConfigurationTests {
static class TomcatProtocolHandlerCustomizerConfiguration { static class TomcatProtocolHandlerCustomizerConfiguration {
@Bean @Bean
public TomcatProtocolHandlerCustomizer protocolHandlerCustomizer() { public TomcatProtocolHandlerCustomizer<?> protocolHandlerCustomizer() {
return (protocolHandler) -> { return (protocolHandler) -> {
}; };
} }
......
...@@ -117,6 +117,9 @@ public class JsonTestersAutoConfiguration { ...@@ -117,6 +117,9 @@ public class JsonTestersAutoConfiguration {
/** /**
* {@link FactoryBean} used to create JSON Tester instances. * {@link FactoryBean} used to create JSON Tester instances.
*
* @param <T> the object type
* @param <M> the marshaller type
*/ */
static class JsonTesterFactoryBean<T, M> implements FactoryBean<T> { static class JsonTesterFactoryBean<T, M> implements FactoryBean<T> {
......
...@@ -108,7 +108,6 @@ class ImportsContextCustomizer implements ContextCustomizer { ...@@ -108,7 +108,6 @@ class ImportsContextCustomizer implements ContextCustomizer {
throw new IllegalStateException("Could not locate BeanDefinitionRegistry"); throw new IllegalStateException("Could not locate BeanDefinitionRegistry");
} }
@SuppressWarnings("unchecked")
private BeanDefinition registerBean(BeanDefinitionRegistry registry, private BeanDefinition registerBean(BeanDefinitionRegistry registry,
AnnotatedBeanDefinitionReader reader, String beanName, Class<?> type) { AnnotatedBeanDefinitionReader reader, String beanName, Class<?> type) {
reader.registerBean(type, beanName); reader.registerBean(type, beanName);
......
/* /*
* Copyright 2012-2018 the original author or authors. * Copyright 2012-2019 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
...@@ -54,7 +54,8 @@ public interface ApplicationContextAssertProvider<C extends ApplicationContext> ...@@ -54,7 +54,8 @@ public interface ApplicationContextAssertProvider<C extends ApplicationContext>
/** /**
* Return an assert for AspectJ. * Return an assert for AspectJ.
* @return an AspectJ assert * @return an AspectJ assert
* @deprecated use standard AssertJ {@code assertThat(context)...} calls instead. * @deprecated to prevent accidental use. Prefer standard AssertJ
* {@code assertThat(context)...} calls instead.
*/ */
@Deprecated @Deprecated
@Override @Override
......
/* /*
* Copyright 2012-2018 the original author or authors. * Copyright 2012-2019 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
...@@ -55,8 +55,8 @@ public final class JsonContent<T> implements AssertProvider<JsonContentAssert> { ...@@ -55,8 +55,8 @@ public final class JsonContent<T> implements AssertProvider<JsonContentAssert> {
/** /**
* Use AssertJ's {@link org.assertj.core.api.Assertions#assertThat assertThat} * Use AssertJ's {@link org.assertj.core.api.Assertions#assertThat assertThat}
* instead. * instead.
* @deprecated in favor of AssertJ's {@link org.assertj.core.api.Assertions#assertThat * @deprecated to prevent accidental use. Prefer standard AssertJ
* assertThat} * {@code assertThat(context)...} calls instead.
*/ */
@Override @Override
@Deprecated @Deprecated
......
...@@ -29,6 +29,8 @@ import org.springframework.context.annotation.Configuration; ...@@ -29,6 +29,8 @@ import org.springframework.context.annotation.Configuration;
import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.context.junit4.SpringRunner; import org.springframework.test.context.junit4.SpringRunner;
import static org.assertj.core.api.Assertions.assertThat;
/** /**
* Integration tests for {@link TestRestTemplateContextCustomizer} to ensure * Integration tests for {@link TestRestTemplateContextCustomizer} to ensure
* early-initialization of factory beans doesn't occur. * early-initialization of factory beans doesn't occur.
...@@ -47,6 +49,7 @@ public class TestRestTemplateContextCustomizerWithFactoryBeanTests { ...@@ -47,6 +49,7 @@ public class TestRestTemplateContextCustomizerWithFactoryBeanTests {
@Test @Test
public void test() { public void test() {
assertThat(this.restTemplate).isNotNull();
} }
@Configuration @Configuration
......
...@@ -21,9 +21,13 @@ import org.springframework.context.ApplicationContext; ...@@ -21,9 +21,13 @@ import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
/** /**
* A simple factory bean with no generics. Used to test early initialization doesn't
* occur.
*
* @author Madhura Bhave * @author Madhura Bhave
*/ */
@Component @Component
@SuppressWarnings("rawtypes")
public class SimpleFactoryBean implements FactoryBean { public class SimpleFactoryBean implements FactoryBean {
private static boolean isInitializedEarly = false; private static boolean isInitializedEarly = false;
...@@ -40,10 +44,12 @@ public class SimpleFactoryBean implements FactoryBean { ...@@ -40,10 +44,12 @@ public class SimpleFactoryBean implements FactoryBean {
} }
} }
@Override
public Object getObject() { public Object getObject() {
return new Object(); return new Object();
} }
@Override
public Class<?> getObjectType() { public Class<?> getObjectType() {
return Object.class; return Object.class;
} }
......
...@@ -24,7 +24,6 @@ import javax.lang.model.element.VariableElement; ...@@ -24,7 +24,6 @@ import javax.lang.model.element.VariableElement;
import org.junit.Test; import org.junit.Test;
import org.springframework.boot.configurationsample.simple.DeprecatedProperties;
import org.springframework.boot.configurationsample.simple.DeprecatedSingleProperty; import org.springframework.boot.configurationsample.simple.DeprecatedSingleProperty;
import org.springframework.boot.configurationsample.simple.SimpleCollectionProperties; import org.springframework.boot.configurationsample.simple.SimpleCollectionProperties;
import org.springframework.boot.configurationsample.simple.SimpleProperties; import org.springframework.boot.configurationsample.simple.SimpleProperties;
...@@ -196,14 +195,15 @@ public class JavaBeanPropertyDescriptorTests extends PropertyDescriptorTests { ...@@ -196,14 +195,15 @@ public class JavaBeanPropertyDescriptorTests extends PropertyDescriptorTests {
@Test @Test
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
public void javaBeanDeprecatedPropertyOnClass() throws IOException { public void javaBeanDeprecatedPropertyOnClass() throws IOException {
process(DeprecatedProperties.class, (roundEnv, metadataEnv) -> { process(org.springframework.boot.configurationsample.simple.DeprecatedProperties.class,
TypeElement ownerElement = roundEnv (roundEnv, metadataEnv) -> {
.getRootElement(DeprecatedProperties.class); TypeElement ownerElement = roundEnv.getRootElement(
JavaBeanPropertyDescriptor property = createPropertyDescriptor(ownerElement, org.springframework.boot.configurationsample.simple.DeprecatedProperties.class);
"name"); JavaBeanPropertyDescriptor property = createPropertyDescriptor(
assertItemMetadata(metadataEnv, property).isProperty() ownerElement, "name");
.isDeprecatedWithNoInformation(); assertItemMetadata(metadataEnv, property).isProperty()
}); .isDeprecatedWithNoInformation();
});
} }
@Test @Test
......
...@@ -25,7 +25,6 @@ import javax.lang.model.element.VariableElement; ...@@ -25,7 +25,6 @@ import javax.lang.model.element.VariableElement;
import org.junit.Test; import org.junit.Test;
import org.springframework.boot.configurationsample.lombok.LombokDefaultValueProperties; import org.springframework.boot.configurationsample.lombok.LombokDefaultValueProperties;
import org.springframework.boot.configurationsample.lombok.LombokDeprecatedProperties;
import org.springframework.boot.configurationsample.lombok.LombokDeprecatedSingleProperty; import org.springframework.boot.configurationsample.lombok.LombokDeprecatedSingleProperty;
import org.springframework.boot.configurationsample.lombok.LombokExplicitProperties; import org.springframework.boot.configurationsample.lombok.LombokExplicitProperties;
import org.springframework.boot.configurationsample.lombok.LombokInnerClassProperties; import org.springframework.boot.configurationsample.lombok.LombokInnerClassProperties;
...@@ -229,14 +228,15 @@ public class LombokPropertyDescriptorTests extends PropertyDescriptorTests { ...@@ -229,14 +228,15 @@ public class LombokPropertyDescriptorTests extends PropertyDescriptorTests {
@Test @Test
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
public void lombokDeprecatedPropertyOnClass() throws IOException { public void lombokDeprecatedPropertyOnClass() throws IOException {
process(LombokDeprecatedProperties.class, (roundEnv, metadataEnv) -> { process(org.springframework.boot.configurationsample.lombok.LombokDeprecatedProperties.class,
TypeElement ownerElement = roundEnv (roundEnv, metadataEnv) -> {
.getRootElement(LombokDeprecatedProperties.class); TypeElement ownerElement = roundEnv.getRootElement(
LombokPropertyDescriptor property = createPropertyDescriptor(ownerElement, org.springframework.boot.configurationsample.lombok.LombokDeprecatedProperties.class);
"name"); LombokPropertyDescriptor property = createPropertyDescriptor(
assertItemMetadata(metadataEnv, property).isProperty() ownerElement, "name");
.isDeprecatedWithNoInformation(); assertItemMetadata(metadataEnv, property).isProperty()
}); .isDeprecatedWithNoInformation();
});
} }
@Test @Test
......
...@@ -23,6 +23,7 @@ import java.util.Map; ...@@ -23,6 +23,7 @@ import java.util.Map;
* A pojo with a complex generic signature. * A pojo with a complex generic signature.
* *
* @author Stephane Nicoll * @author Stephane Nicoll
* @param <T> the generic type
*/ */
public class UpperBoundGenericPojo<T extends Enum<T>> { public class UpperBoundGenericPojo<T extends Enum<T>> {
......
...@@ -26,6 +26,7 @@ import org.springframework.boot.configurationsample.DefaultValue; ...@@ -26,6 +26,7 @@ import org.springframework.boot.configurationsample.DefaultValue;
* *
* @author Stephane Nicoll * @author Stephane Nicoll
*/ */
@SuppressWarnings("unused")
public class ImmutableCollectionProperties { public class ImmutableCollectionProperties {
private final List<String> names; private final List<String> names;
......
...@@ -27,6 +27,7 @@ import org.springframework.boot.configurationsample.ConfigurationProperties; ...@@ -27,6 +27,7 @@ import org.springframework.boot.configurationsample.ConfigurationProperties;
*/ */
@Data @Data
@ConfigurationProperties("default") @ConfigurationProperties("default")
@SuppressWarnings("unused")
public class LombokDefaultValueProperties { public class LombokDefaultValueProperties {
private String description = "my description"; private String description = "my description";
......
...@@ -30,6 +30,7 @@ import org.springframework.boot.configurationsample.ConfigurationProperties; ...@@ -30,6 +30,7 @@ import org.springframework.boot.configurationsample.ConfigurationProperties;
@Setter @Setter
@ConfigurationProperties(prefix = "deprecated") @ConfigurationProperties(prefix = "deprecated")
@Deprecated @Deprecated
@SuppressWarnings("unused")
public class LombokDeprecatedProperties { public class LombokDeprecatedProperties {
private String name; private String name;
......
...@@ -27,6 +27,7 @@ import org.springframework.boot.configurationsample.ConfigurationProperties; ...@@ -27,6 +27,7 @@ import org.springframework.boot.configurationsample.ConfigurationProperties;
*/ */
@Data @Data
@ConfigurationProperties("singledeprecated") @ConfigurationProperties("singledeprecated")
@SuppressWarnings("unused")
public class LombokDeprecatedSingleProperty { public class LombokDeprecatedSingleProperty {
@Deprecated @Deprecated
......
...@@ -55,7 +55,7 @@ public class ConfigurationPropertiesBindingPostProcessor implements BeanPostProc ...@@ -55,7 +55,7 @@ public class ConfigurationPropertiesBindingPostProcessor implements BeanPostProc
/** /**
* The bean name of the configuration properties validator. * The bean name of the configuration properties validator.
* @deprecated see * @deprecated since 2.2.0 in favor of
* {@link ConfigurationPropertiesBindingPostProcessorRegistrar#VALIDATOR_BEAN_NAME} * {@link ConfigurationPropertiesBindingPostProcessorRegistrar#VALIDATOR_BEAN_NAME}
*/ */
@Deprecated @Deprecated
......
...@@ -29,7 +29,7 @@ import org.springframework.messaging.rsocket.RSocketStrategies; ...@@ -29,7 +29,7 @@ import org.springframework.messaging.rsocket.RSocketStrategies;
public interface RSocketStrategiesCustomizer { public interface RSocketStrategiesCustomizer {
/** /**
* Callback to customize a {@link RSocketStrategies.Builder} instance. * Callback to customize a {@link RSocketStrategies#builder()} instance.
* @param strategies rSocket codec strategies to customize * @param strategies rSocket codec strategies to customize
*/ */
void customize(RSocketStrategies.Builder strategies); void customize(RSocketStrategies.Builder strategies);
......
...@@ -72,6 +72,7 @@ public interface ConfigurableTomcatWebServerFactory extends ConfigurableWebServe ...@@ -72,6 +72,7 @@ public interface ConfigurableTomcatWebServerFactory extends ConfigurableWebServe
* Add {@link TomcatProtocolHandlerCustomizer}s that should be added to the Tomcat * Add {@link TomcatProtocolHandlerCustomizer}s that should be added to the Tomcat
* {@link Connector}. * {@link Connector}.
* @param tomcatProtocolHandlerCustomizers the customizers to add * @param tomcatProtocolHandlerCustomizers the customizers to add
* @since 2.2.0
*/ */
void addProtocolHandlerCustomizers( void addProtocolHandlerCustomizers(
TomcatProtocolHandlerCustomizer<?>... tomcatProtocolHandlerCustomizers); TomcatProtocolHandlerCustomizer<?>... tomcatProtocolHandlerCustomizers);
......
...@@ -292,6 +292,7 @@ public class TomcatReactiveWebServerFactory extends AbstractReactiveWebServerFac ...@@ -292,6 +292,7 @@ public class TomcatReactiveWebServerFactory extends AbstractReactiveWebServerFac
* Set {@link TomcatProtocolHandlerCustomizer}s that should be applied to the Tomcat * Set {@link TomcatProtocolHandlerCustomizer}s that should be applied to the Tomcat
* {@link Connector}. Calling this method will replace any existing customizers. * {@link Connector}. Calling this method will replace any existing customizers.
* @param tomcatProtocolHandlerCustomizers the customizers to set * @param tomcatProtocolHandlerCustomizers the customizers to set
* @since 2.2.0
*/ */
public void setTomcatProtocolHandlerCustomizers( public void setTomcatProtocolHandlerCustomizers(
Collection<? extends TomcatProtocolHandlerCustomizer<?>> tomcatProtocolHandlerCustomizers) { Collection<? extends TomcatProtocolHandlerCustomizer<?>> tomcatProtocolHandlerCustomizers) {
...@@ -305,6 +306,7 @@ public class TomcatReactiveWebServerFactory extends AbstractReactiveWebServerFac ...@@ -305,6 +306,7 @@ public class TomcatReactiveWebServerFactory extends AbstractReactiveWebServerFac
* Add {@link TomcatProtocolHandlerCustomizer}s that should be added to the Tomcat * Add {@link TomcatProtocolHandlerCustomizer}s that should be added to the Tomcat
* {@link Connector}. * {@link Connector}.
* @param tomcatProtocolHandlerCustomizers the customizers to add * @param tomcatProtocolHandlerCustomizers the customizers to add
* @since 2.2.0
*/ */
@Override @Override
public void addProtocolHandlerCustomizers( public void addProtocolHandlerCustomizers(
...@@ -319,6 +321,7 @@ public class TomcatReactiveWebServerFactory extends AbstractReactiveWebServerFac ...@@ -319,6 +321,7 @@ public class TomcatReactiveWebServerFactory extends AbstractReactiveWebServerFac
* Returns a mutable collection of the {@link TomcatProtocolHandlerCustomizer}s that * Returns a mutable collection of the {@link TomcatProtocolHandlerCustomizer}s that
* will be applied to the Tomcat {@link Connector}. * will be applied to the Tomcat {@link Connector}.
* @return the customizers that will be applied * @return the customizers that will be applied
* @since 2.2.0
*/ */
public Collection<TomcatProtocolHandlerCustomizer<?>> getTomcatProtocolHandlerCustomizers() { public Collection<TomcatProtocolHandlerCustomizer<?>> getTomcatProtocolHandlerCustomizers() {
return this.tomcatProtocolHandlerCustomizers; return this.tomcatProtocolHandlerCustomizers;
......
...@@ -636,6 +636,7 @@ public class TomcatServletWebServerFactory extends AbstractServletWebServerFacto ...@@ -636,6 +636,7 @@ public class TomcatServletWebServerFactory extends AbstractServletWebServerFacto
* Set {@link TomcatProtocolHandlerCustomizer}s that should be applied to the Tomcat * Set {@link TomcatProtocolHandlerCustomizer}s that should be applied to the Tomcat
* {@link Connector}. Calling this method will replace any existing customizers. * {@link Connector}. Calling this method will replace any existing customizers.
* @param tomcatProtocolHandlerCustomizer the customizers to set * @param tomcatProtocolHandlerCustomizer the customizers to set
* @since 2.2.0
*/ */
public void setTomcatProtocolHandlerCustomizers( public void setTomcatProtocolHandlerCustomizers(
Collection<? extends TomcatProtocolHandlerCustomizer<?>> tomcatProtocolHandlerCustomizer) { Collection<? extends TomcatProtocolHandlerCustomizer<?>> tomcatProtocolHandlerCustomizer) {
...@@ -649,6 +650,7 @@ public class TomcatServletWebServerFactory extends AbstractServletWebServerFacto ...@@ -649,6 +650,7 @@ public class TomcatServletWebServerFactory extends AbstractServletWebServerFacto
* Add {@link TomcatProtocolHandlerCustomizer}s that should be added to the Tomcat * Add {@link TomcatProtocolHandlerCustomizer}s that should be added to the Tomcat
* {@link Connector}. * {@link Connector}.
* @param tomcatProtocolHandlerCustomizers the customizers to add * @param tomcatProtocolHandlerCustomizers the customizers to add
* @since 2.2.0
*/ */
@Override @Override
public void addProtocolHandlerCustomizers( public void addProtocolHandlerCustomizers(
...@@ -663,6 +665,7 @@ public class TomcatServletWebServerFactory extends AbstractServletWebServerFacto ...@@ -663,6 +665,7 @@ public class TomcatServletWebServerFactory extends AbstractServletWebServerFacto
* Returns a mutable collection of the {@link TomcatProtocolHandlerCustomizer}s that * Returns a mutable collection of the {@link TomcatProtocolHandlerCustomizer}s that
* will be applied to the Tomcat {@link Connector}. * will be applied to the Tomcat {@link Connector}.
* @return the customizers that will be applied * @return the customizers that will be applied
* @since 2.2.0
*/ */
public Collection<TomcatProtocolHandlerCustomizer<?>> getTomcatProtocolHandlerCustomizers() { public Collection<TomcatProtocolHandlerCustomizer<?>> getTomcatProtocolHandlerCustomizers() {
return this.tomcatProtocolHandlerCustomizers; return this.tomcatProtocolHandlerCustomizers;
......
...@@ -58,14 +58,14 @@ public class CompressionConnectorCustomizerTests { ...@@ -58,14 +58,14 @@ public class CompressionConnectorCustomizerTests {
Connector connector = new Connector("org.apache.coyote.http11.Http11NioProtocol"); Connector connector = new Connector("org.apache.coyote.http11.Http11NioProtocol");
connector.addUpgradeProtocol(new Http2Protocol()); connector.addUpgradeProtocol(new Http2Protocol());
compressionConnectorCustomizer.customize(connector); compressionConnectorCustomizer.customize(connector);
AbstractHttp11Protocol abstractHttp11Protocol = (AbstractHttp11Protocol) connector AbstractHttp11Protocol<?> abstractHttp11Protocol = (AbstractHttp11Protocol<?>) connector
.getProtocolHandler(); .getProtocolHandler();
verifyHttp1(abstractHttp11Protocol); verifyHttp1(abstractHttp11Protocol);
Http2Protocol http2Protocol = (Http2Protocol) connector.findUpgradeProtocols()[0]; Http2Protocol http2Protocol = (Http2Protocol) connector.findUpgradeProtocols()[0];
verifyHttp2Upgrade(http2Protocol); verifyHttp2Upgrade(http2Protocol);
} }
private void verifyHttp1(AbstractHttp11Protocol protocol) { private void verifyHttp1(AbstractHttp11Protocol<?> protocol) {
compressionOn(protocol.getCompression()); compressionOn(protocol.getCompression());
minSize(protocol.getCompressionMinSize()); minSize(protocol.getCompressionMinSize());
mimeType(protocol.getCompressibleMimeTypes()); mimeType(protocol.getCompressibleMimeTypes());
......
...@@ -159,10 +159,11 @@ public class TomcatReactiveWebServerFactoryTests ...@@ -159,10 +159,11 @@ public class TomcatReactiveWebServerFactoryTests
} }
@Test @Test
@SuppressWarnings({ "unchecked", "rawtypes" })
public void tomcatProtocolHandlerCustomizersShouldBeInvoked() { public void tomcatProtocolHandlerCustomizersShouldBeInvoked() {
TomcatReactiveWebServerFactory factory = getFactory(); TomcatReactiveWebServerFactory factory = getFactory();
HttpHandler handler = mock(HttpHandler.class); HttpHandler handler = mock(HttpHandler.class);
TomcatProtocolHandlerCustomizer<AbstractHttp11Protocol>[] customizers = new TomcatProtocolHandlerCustomizer[4]; TomcatProtocolHandlerCustomizer<AbstractHttp11Protocol<?>>[] customizers = new TomcatProtocolHandlerCustomizer[4];
Arrays.setAll(customizers, (i) -> mock(TomcatProtocolHandlerCustomizer.class)); Arrays.setAll(customizers, (i) -> mock(TomcatProtocolHandlerCustomizer.class));
factory.setTomcatProtocolHandlerCustomizers( factory.setTomcatProtocolHandlerCustomizers(
Arrays.asList(customizers[0], customizers[1])); Arrays.asList(customizers[0], customizers[1]));
......
...@@ -201,9 +201,10 @@ public class TomcatServletWebServerFactoryTests ...@@ -201,9 +201,10 @@ public class TomcatServletWebServerFactoryTests
} }
@Test @Test
@SuppressWarnings({ "unchecked", "rawtypes" })
public void tomcatProtocolHandlerCustomizersShouldBeInvoked() { public void tomcatProtocolHandlerCustomizersShouldBeInvoked() {
TomcatServletWebServerFactory factory = getFactory(); TomcatServletWebServerFactory factory = getFactory();
TomcatProtocolHandlerCustomizer<AbstractHttp11Protocol>[] customizers = new TomcatProtocolHandlerCustomizer[4]; TomcatProtocolHandlerCustomizer<AbstractHttp11Protocol<?>>[] customizers = new TomcatProtocolHandlerCustomizer[4];
Arrays.setAll(customizers, (i) -> mock(TomcatProtocolHandlerCustomizer.class)); Arrays.setAll(customizers, (i) -> mock(TomcatProtocolHandlerCustomizer.class));
factory.setTomcatProtocolHandlerCustomizers( factory.setTomcatProtocolHandlerCustomizers(
Arrays.asList(customizers[0], customizers[1])); Arrays.asList(customizers[0], customizers[1]));
...@@ -218,13 +219,13 @@ public class TomcatServletWebServerFactoryTests ...@@ -218,13 +219,13 @@ public class TomcatServletWebServerFactoryTests
@Test @Test
public void tomcatProtocolHandlerCanBeCustomized() { public void tomcatProtocolHandlerCanBeCustomized() {
TomcatServletWebServerFactory factory = getFactory(); TomcatServletWebServerFactory factory = getFactory();
TomcatProtocolHandlerCustomizer<AbstractHttp11Protocol> customizer = ( TomcatProtocolHandlerCustomizer<AbstractHttp11Protocol<?>> customizer = (
protocolHandler) -> protocolHandler.setProcessorCache(250); protocolHandler) -> protocolHandler.setProcessorCache(250);
factory.addProtocolHandlerCustomizers(customizer); factory.addProtocolHandlerCustomizers(customizer);
Tomcat tomcat = getTomcat(factory); Tomcat tomcat = getTomcat(factory);
Connector connector = ((TomcatWebServer) this.webServer).getServiceConnectors() Connector connector = ((TomcatWebServer) this.webServer).getServiceConnectors()
.get(tomcat.getService())[0]; .get(tomcat.getService())[0];
AbstractHttp11Protocol protocolHandler = (AbstractHttp11Protocol) connector AbstractHttp11Protocol<?> protocolHandler = (AbstractHttp11Protocol<?>) connector
.getProtocolHandler(); .getProtocolHandler();
assertThat(protocolHandler.getProcessorCache()).isEqualTo(250); assertThat(protocolHandler.getProcessorCache()).isEqualTo(250);
} }
......
...@@ -66,8 +66,6 @@ public class DevToolsWithLazyInitializationIntegrationTests { ...@@ -66,8 +66,6 @@ public class DevToolsWithLazyInitializationIntegrationTests {
private final ApplicationLauncher applicationLauncher; private final ApplicationLauncher applicationLauncher;
private String[] args;
@Rule @Rule
public JvmLauncher javaLauncher = new JvmLauncher(); public JvmLauncher javaLauncher = new JvmLauncher();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment