Merge pull request #5511 from htynkn/upgrade-elastic
* pr/5511: Polish contribution Upgrade elasticsearch to 2.2.0 Polish contribution Deprecate Undertow container's constructors that have a port parameter Remove unused unsatisfiedDependency.getInjectionPoint() call Polish contribution Allow Tomcat's minimum threads to be configured via the environment
This commit is contained in:
commit
63a3d003dd
|
|
@ -393,8 +393,7 @@ public class HealthIndicatorAutoConfigurationTests {
|
||||||
@Test
|
@Test
|
||||||
public void elasticSearchHealthIndicator() {
|
public void elasticSearchHealthIndicator() {
|
||||||
EnvironmentTestUtils.addEnvironment(this.context,
|
EnvironmentTestUtils.addEnvironment(this.context,
|
||||||
"spring.data.elasticsearch.properties.path.data:target/data",
|
"spring.data.elasticsearch.properties.path.home:target",
|
||||||
"spring.data.elasticsearch.properties.path.logs:target/logs",
|
|
||||||
"management.health.diskspace.enabled:false");
|
"management.health.diskspace.enabled:false");
|
||||||
this.context.register(ElasticsearchAutoConfiguration.class,
|
this.context.register(ElasticsearchAutoConfiguration.class,
|
||||||
ManagementServerProperties.class, HealthIndicatorAutoConfiguration.class);
|
ManagementServerProperties.class, HealthIndicatorAutoConfiguration.class);
|
||||||
|
|
@ -411,8 +410,7 @@ public class HealthIndicatorAutoConfigurationTests {
|
||||||
public void notElasticSearchHealthIndicator() {
|
public void notElasticSearchHealthIndicator() {
|
||||||
EnvironmentTestUtils.addEnvironment(this.context,
|
EnvironmentTestUtils.addEnvironment(this.context,
|
||||||
"management.health.elasticsearch.enabled:false",
|
"management.health.elasticsearch.enabled:false",
|
||||||
"spring.data.elasticsearch.properties.path.data:target/data",
|
"spring.data.elasticsearch.properties.path.home:target",
|
||||||
"spring.data.elasticsearch.properties.path.logs:target/logs",
|
|
||||||
"management.health.diskspace.enabled:false");
|
"management.health.diskspace.enabled:false");
|
||||||
this.context.register(ElasticsearchAutoConfiguration.class,
|
this.context.register(ElasticsearchAutoConfiguration.class,
|
||||||
ManagementServerProperties.class, HealthIndicatorAutoConfiguration.class);
|
ManagementServerProperties.class, HealthIndicatorAutoConfiguration.class);
|
||||||
|
|
|
||||||
|
|
@ -23,13 +23,13 @@ import org.elasticsearch.ElasticsearchException;
|
||||||
import org.elasticsearch.ElasticsearchTimeoutException;
|
import org.elasticsearch.ElasticsearchTimeoutException;
|
||||||
import org.elasticsearch.action.admin.cluster.health.ClusterHealthRequest;
|
import org.elasticsearch.action.admin.cluster.health.ClusterHealthRequest;
|
||||||
import org.elasticsearch.action.admin.cluster.health.ClusterHealthResponse;
|
import org.elasticsearch.action.admin.cluster.health.ClusterHealthResponse;
|
||||||
import org.elasticsearch.action.admin.cluster.health.ClusterHealthStatus;
|
|
||||||
import org.elasticsearch.action.support.PlainActionFuture;
|
import org.elasticsearch.action.support.PlainActionFuture;
|
||||||
import org.elasticsearch.client.AdminClient;
|
import org.elasticsearch.client.AdminClient;
|
||||||
import org.elasticsearch.client.Client;
|
import org.elasticsearch.client.Client;
|
||||||
import org.elasticsearch.client.ClusterAdminClient;
|
import org.elasticsearch.client.ClusterAdminClient;
|
||||||
import org.elasticsearch.cluster.ClusterState;
|
import org.elasticsearch.cluster.ClusterState;
|
||||||
import org.elasticsearch.cluster.block.ClusterBlocks;
|
import org.elasticsearch.cluster.block.ClusterBlocks;
|
||||||
|
import org.elasticsearch.cluster.health.ClusterHealthStatus;
|
||||||
import org.elasticsearch.cluster.node.DiscoveryNodes;
|
import org.elasticsearch.cluster.node.DiscoveryNodes;
|
||||||
import org.elasticsearch.cluster.routing.RoutingTable;
|
import org.elasticsearch.cluster.routing.RoutingTable;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
|
|
@ -176,9 +176,9 @@ public class ElasticsearchHealthIndicatorTests {
|
||||||
|
|
||||||
private StubClusterHealthResponse(ClusterHealthStatus status) {
|
private StubClusterHealthResponse(ClusterHealthStatus status) {
|
||||||
super("test-cluster", new String[0],
|
super("test-cluster", new String[0],
|
||||||
new ClusterState(null, 0, null, RoutingTable.builder().build(),
|
new ClusterState(null, 0, null, null, RoutingTable.builder().build(),
|
||||||
DiscoveryNodes.builder().build(),
|
DiscoveryNodes.builder().build(),
|
||||||
ClusterBlocks.builder().build(), null));
|
ClusterBlocks.builder().build(), null, false));
|
||||||
this.status = status;
|
this.status = status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,7 @@ import org.apache.commons.logging.LogFactory;
|
||||||
import org.elasticsearch.client.Client;
|
import org.elasticsearch.client.Client;
|
||||||
import org.elasticsearch.client.transport.TransportClient;
|
import org.elasticsearch.client.transport.TransportClient;
|
||||||
import org.elasticsearch.common.lease.Releasable;
|
import org.elasticsearch.common.lease.Releasable;
|
||||||
import org.elasticsearch.common.settings.ImmutableSettings;
|
import org.elasticsearch.common.settings.Settings;
|
||||||
import org.elasticsearch.node.Node;
|
import org.elasticsearch.node.Node;
|
||||||
import org.elasticsearch.node.NodeBuilder;
|
import org.elasticsearch.node.NodeBuilder;
|
||||||
|
|
||||||
|
|
@ -62,6 +62,7 @@ public class ElasticsearchAutoConfiguration implements DisposableBean {
|
||||||
Map<String, String> defaults = new LinkedHashMap<String, String>();
|
Map<String, String> defaults = new LinkedHashMap<String, String>();
|
||||||
defaults.put("http.enabled", String.valueOf(false));
|
defaults.put("http.enabled", String.valueOf(false));
|
||||||
defaults.put("node.local", String.valueOf(true));
|
defaults.put("node.local", String.valueOf(true));
|
||||||
|
defaults.put("path.home", System.getProperty("user.dir"));
|
||||||
DEFAULTS = Collections.unmodifiableMap(defaults);
|
DEFAULTS = Collections.unmodifiableMap(defaults);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -95,7 +96,7 @@ public class ElasticsearchAutoConfiguration implements DisposableBean {
|
||||||
}
|
}
|
||||||
|
|
||||||
private Client createNodeClient() throws Exception {
|
private Client createNodeClient() throws Exception {
|
||||||
ImmutableSettings.Builder settings = ImmutableSettings.settingsBuilder();
|
Settings.Builder settings = Settings.settingsBuilder();
|
||||||
for (Map.Entry<String, String> entry : DEFAULTS.entrySet()) {
|
for (Map.Entry<String, String> entry : DEFAULTS.entrySet()) {
|
||||||
if (!this.properties.getProperties().containsKey(entry.getKey())) {
|
if (!this.properties.getProperties().containsKey(entry.getKey())) {
|
||||||
settings.put(entry.getKey(), entry.getValue());
|
settings.put(entry.getKey(), entry.getValue());
|
||||||
|
|
|
||||||
|
|
@ -72,6 +72,7 @@ import org.springframework.util.StringUtils;
|
||||||
* @author Ivan Sopov
|
* @author Ivan Sopov
|
||||||
* @author Marcos Barbero
|
* @author Marcos Barbero
|
||||||
* @author Eddú Meléndez
|
* @author Eddú Meléndez
|
||||||
|
* @author Quinten De Swaef
|
||||||
*/
|
*/
|
||||||
@ConfigurationProperties(prefix = "server", ignoreUnknownFields = true)
|
@ConfigurationProperties(prefix = "server", ignoreUnknownFields = true)
|
||||||
public class ServerProperties
|
public class ServerProperties
|
||||||
|
|
@ -580,6 +581,11 @@ public class ServerProperties
|
||||||
*/
|
*/
|
||||||
private int maxThreads = 0; // Number of threads in protocol handler
|
private int maxThreads = 0; // Number of threads in protocol handler
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Minimum amount of worker threads.
|
||||||
|
*/
|
||||||
|
private int minSpareThreads = 0; // Minimum spare threads in protocol handler
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Maximum size in bytes of the HTTP message header.
|
* Maximum size in bytes of the HTTP message header.
|
||||||
*/
|
*/
|
||||||
|
|
@ -598,6 +604,14 @@ public class ServerProperties
|
||||||
this.maxThreads = maxThreads;
|
this.maxThreads = maxThreads;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getMinSpareThreads() {
|
||||||
|
return this.minSpareThreads;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMinSpareThreads(int minSpareThreads) {
|
||||||
|
this.minSpareThreads = minSpareThreads;
|
||||||
|
}
|
||||||
|
|
||||||
public int getMaxHttpHeaderSize() {
|
public int getMaxHttpHeaderSize() {
|
||||||
return this.maxHttpHeaderSize;
|
return this.maxHttpHeaderSize;
|
||||||
}
|
}
|
||||||
|
|
@ -684,6 +698,9 @@ public class ServerProperties
|
||||||
if (this.maxThreads > 0) {
|
if (this.maxThreads > 0) {
|
||||||
customizeMaxThreads(factory);
|
customizeMaxThreads(factory);
|
||||||
}
|
}
|
||||||
|
if (this.minSpareThreads > 0) {
|
||||||
|
customizeMinThreads(factory);
|
||||||
|
}
|
||||||
if (this.maxHttpHeaderSize > 0) {
|
if (this.maxHttpHeaderSize > 0) {
|
||||||
customizeMaxHttpHeaderSize(factory);
|
customizeMaxHttpHeaderSize(factory);
|
||||||
}
|
}
|
||||||
|
|
@ -747,6 +764,22 @@ public class ServerProperties
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("rawtypes")
|
||||||
|
private void customizeMinThreads(TomcatEmbeddedServletContainerFactory factory) {
|
||||||
|
factory.addConnectorCustomizers(new TomcatConnectorCustomizer() {
|
||||||
|
@Override
|
||||||
|
public void customize(Connector connector) {
|
||||||
|
|
||||||
|
ProtocolHandler handler = connector.getProtocolHandler();
|
||||||
|
if (handler instanceof AbstractProtocol) {
|
||||||
|
AbstractProtocol protocol = (AbstractProtocol) handler;
|
||||||
|
protocol.setMinSpareThreads(Tomcat.this.minSpareThreads);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
@SuppressWarnings("rawtypes")
|
@SuppressWarnings("rawtypes")
|
||||||
private void customizeMaxHttpHeaderSize(
|
private void customizeMaxHttpHeaderSize(
|
||||||
TomcatEmbeddedServletContainerFactory factory) {
|
TomcatEmbeddedServletContainerFactory factory) {
|
||||||
|
|
|
||||||
|
|
@ -57,8 +57,7 @@ public class ElasticsearchAutoConfigurationTests {
|
||||||
this.context = new AnnotationConfigApplicationContext();
|
this.context = new AnnotationConfigApplicationContext();
|
||||||
EnvironmentTestUtils.addEnvironment(this.context,
|
EnvironmentTestUtils.addEnvironment(this.context,
|
||||||
"spring.data.elasticsearch.properties.foo.bar:baz",
|
"spring.data.elasticsearch.properties.foo.bar:baz",
|
||||||
"spring.data.elasticsearch.properties.path.data:target/data",
|
"spring.data.elasticsearch.properties.path.home:target");
|
||||||
"spring.data.elasticsearch.properties.path.logs:target/logs");
|
|
||||||
this.context.register(PropertyPlaceholderAutoConfiguration.class,
|
this.context.register(PropertyPlaceholderAutoConfiguration.class,
|
||||||
ElasticsearchAutoConfiguration.class);
|
ElasticsearchAutoConfiguration.class);
|
||||||
this.context.refresh();
|
this.context.refresh();
|
||||||
|
|
@ -74,8 +73,7 @@ public class ElasticsearchAutoConfigurationTests {
|
||||||
this.context = new AnnotationConfigApplicationContext();
|
this.context = new AnnotationConfigApplicationContext();
|
||||||
EnvironmentTestUtils.addEnvironment(this.context,
|
EnvironmentTestUtils.addEnvironment(this.context,
|
||||||
"spring.data.elasticsearch.properties.foo.bar:baz",
|
"spring.data.elasticsearch.properties.foo.bar:baz",
|
||||||
"spring.data.elasticsearch.properties.path.data:target/data",
|
"spring.data.elasticsearch.properties.path.home:target",
|
||||||
"spring.data.elasticsearch.properties.path.logs:target/logs",
|
|
||||||
"spring.data.elasticsearch.properties.node.local:false",
|
"spring.data.elasticsearch.properties.node.local:false",
|
||||||
"spring.data.elasticsearch.properties.node.data:true",
|
"spring.data.elasticsearch.properties.node.data:true",
|
||||||
"spring.data.elasticsearch.properties.http.enabled:true");
|
"spring.data.elasticsearch.properties.http.enabled:true");
|
||||||
|
|
@ -109,8 +107,7 @@ public class ElasticsearchAutoConfigurationTests {
|
||||||
this.context = new AnnotationConfigApplicationContext();
|
this.context = new AnnotationConfigApplicationContext();
|
||||||
EnvironmentTestUtils.addEnvironment(this.context,
|
EnvironmentTestUtils.addEnvironment(this.context,
|
||||||
"spring.data.elasticsearch.cluster-nodes:localhost",
|
"spring.data.elasticsearch.cluster-nodes:localhost",
|
||||||
"spring.data.elasticsearch.properties.path.data:target/data",
|
"spring.data.elasticsearch.properties.path.home:target");
|
||||||
"spring.data.elasticsearch.properties.path.logs:target/logs");
|
|
||||||
this.context.register(PropertyPlaceholderAutoConfiguration.class,
|
this.context.register(PropertyPlaceholderAutoConfiguration.class,
|
||||||
ElasticsearchAutoConfiguration.class);
|
ElasticsearchAutoConfiguration.class);
|
||||||
this.thrown.expect(BeanCreationException.class);
|
this.thrown.expect(BeanCreationException.class);
|
||||||
|
|
|
||||||
|
|
@ -89,8 +89,7 @@ public class ElasticsearchRepositoriesAutoConfigurationTests {
|
||||||
|
|
||||||
private void addElasticsearchProperties(AnnotationConfigApplicationContext context) {
|
private void addElasticsearchProperties(AnnotationConfigApplicationContext context) {
|
||||||
EnvironmentTestUtils.addEnvironment(context,
|
EnvironmentTestUtils.addEnvironment(context,
|
||||||
"spring.data.elasticsearch.properties.path.data:target/data",
|
"spring.data.elasticsearch.properties.path.home:target");
|
||||||
"spring.data.elasticsearch.properties.path.logs:target/logs");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Configuration
|
@Configuration
|
||||||
|
|
|
||||||
|
|
@ -62,6 +62,7 @@ import static org.mockito.Mockito.verify;
|
||||||
* @author Andy Wilkinson
|
* @author Andy Wilkinson
|
||||||
* @author Phillip Webb
|
* @author Phillip Webb
|
||||||
* @author Eddú Meléndez
|
* @author Eddú Meléndez
|
||||||
|
* @author Quinten De Swaef
|
||||||
*/
|
*/
|
||||||
public class ServerPropertiesTests {
|
public class ServerPropertiesTests {
|
||||||
|
|
||||||
|
|
@ -258,6 +259,14 @@ public class ServerPropertiesTests {
|
||||||
assertThat(this.properties.getTomcat().getMaxHttpHeaderSize()).isEqualTo(9999);
|
assertThat(this.properties.getTomcat().getMaxHttpHeaderSize()).isEqualTo(9999);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testCustomizeTomcatMinSpareThreads() throws Exception {
|
||||||
|
Map<String, String> map = new HashMap<String, String>();
|
||||||
|
map.put("server.tomcat.min-spare-threads", "10");
|
||||||
|
bindProperties(map);
|
||||||
|
assertThat(this.properties.getTomcat().getMinSpareThreads()).isEqualTo(10);
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void customizeTomcatDisplayName() throws Exception {
|
public void customizeTomcatDisplayName() throws Exception {
|
||||||
Map<String, String> map = new HashMap<String, String>();
|
Map<String, String> map = new HashMap<String, String>();
|
||||||
|
|
|
||||||
|
|
@ -70,7 +70,7 @@
|
||||||
<embedded-mongo.version>1.50.2</embedded-mongo.version>
|
<embedded-mongo.version>1.50.2</embedded-mongo.version>
|
||||||
<flyway.version>3.2.1</flyway.version>
|
<flyway.version>3.2.1</flyway.version>
|
||||||
<freemarker.version>2.3.23</freemarker.version>
|
<freemarker.version>2.3.23</freemarker.version>
|
||||||
<elasticsearch.version>1.7.5</elasticsearch.version>
|
<elasticsearch.version>2.2.0</elasticsearch.version>
|
||||||
<gemfire.version>8.2.0</gemfire.version>
|
<gemfire.version>8.2.0</gemfire.version>
|
||||||
<glassfish-el.version>3.0.0</glassfish-el.version>
|
<glassfish-el.version>3.0.0</glassfish-el.version>
|
||||||
<gradle.version>1.12</gradle.version>
|
<gradle.version>1.12</gradle.version>
|
||||||
|
|
@ -105,6 +105,7 @@
|
||||||
<jetty.version>9.2.15.v20160210</jetty.version>
|
<jetty.version>9.2.15.v20160210</jetty.version>
|
||||||
<jetty-jsp.version>2.2.0.v201112011158</jetty-jsp.version>
|
<jetty-jsp.version>2.2.0.v201112011158</jetty-jsp.version>
|
||||||
<jmustache.version>1.12</jmustache.version>
|
<jmustache.version>1.12</jmustache.version>
|
||||||
|
<jna.version>4.2.2</jna.version>
|
||||||
<joda-time.version>2.9.2</joda-time.version>
|
<joda-time.version>2.9.2</joda-time.version>
|
||||||
<jolokia.version>1.3.3</jolokia.version>
|
<jolokia.version>1.3.3</jolokia.version>
|
||||||
<jooq.version>3.7.2</jooq.version>
|
<jooq.version>3.7.2</jooq.version>
|
||||||
|
|
@ -951,6 +952,11 @@
|
||||||
<artifactId>mysql-connector-java</artifactId>
|
<artifactId>mysql-connector-java</artifactId>
|
||||||
<version>${mysql.version}</version>
|
<version>${mysql.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>net.java.dev.jna</groupId>
|
||||||
|
<artifactId>jna</artifactId>
|
||||||
|
<version>${jna.version}</version>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>net.sf.ehcache</groupId>
|
<groupId>net.sf.ehcache</groupId>
|
||||||
<artifactId>ehcache</artifactId>
|
<artifactId>ehcache</artifactId>
|
||||||
|
|
|
||||||
|
|
@ -204,6 +204,7 @@ content into your application; rather pick only the properties that you need.
|
||||||
172\\.3[0-1]{1}\\.\\d{1,3}\\.\\d{1,3} # regular expression matching trusted IP addresses.
|
172\\.3[0-1]{1}\\.\\d{1,3}\\.\\d{1,3} # regular expression matching trusted IP addresses.
|
||||||
server.tomcat.max-http-header-size=0 # Maximum size in bytes of the HTTP message header.
|
server.tomcat.max-http-header-size=0 # Maximum size in bytes of the HTTP message header.
|
||||||
server.tomcat.max-threads=0 # Maximum amount of worker threads.
|
server.tomcat.max-threads=0 # Maximum amount of worker threads.
|
||||||
|
server.tomcat.min-spare-threads=0 # Minimum amount of worker threads.
|
||||||
server.tomcat.port-header=X-Forwarded-Port # Name of the HTTP header used to override the original port value.
|
server.tomcat.port-header=X-Forwarded-Port # Name of the HTTP header used to override the original port value.
|
||||||
server.tomcat.protocol-header= # Header that holds the incoming protocol, usually named "X-Forwarded-Proto".
|
server.tomcat.protocol-header= # Header that holds the incoming protocol, usually named "X-Forwarded-Proto".
|
||||||
server.tomcat.protocol-header-https-value=https # Value of the protocol header that indicates that the incoming request uses SSL.
|
server.tomcat.protocol-header-https-value=https # Value of the protocol header that indicates that the incoming request uses SSL.
|
||||||
|
|
|
||||||
|
|
@ -3214,11 +3214,24 @@ dependencies in a convenient way.
|
||||||
[[boot-features-connecting-to-elasticsearch]]
|
[[boot-features-connecting-to-elasticsearch]]
|
||||||
==== Connecting to Elasticsearch
|
==== Connecting to Elasticsearch
|
||||||
You can inject an auto-configured `ElasticsearchTemplate` or Elasticsearch `Client`
|
You can inject an auto-configured `ElasticsearchTemplate` or Elasticsearch `Client`
|
||||||
instance as you would any other Spring Bean. By default the instance will attempt to
|
instance as you would any other Spring Bean. By default the instance will embed a
|
||||||
connect to a local in-memory server (a `NodeClient` in Elasticsearch terms), but you can
|
local in-memory server (a `Node` in ElasticSearch terms) and use the current working
|
||||||
switch to a remote server (i.e. a `TransportClient`) by setting
|
directory as the home directory for the server. In this setup, the first thing to do
|
||||||
|
is to tell ElasticSearch were to store its files:
|
||||||
|
|
||||||
|
[source,properties,indent=0]
|
||||||
|
----
|
||||||
|
spring.data.elasticsearch.properties.path.home=/foo/bar
|
||||||
|
----
|
||||||
|
|
||||||
|
Alternatively, you can switch to a remote server (i.e. a `TransportClient`) by setting
|
||||||
`spring.data.elasticsearch.cluster-nodes` to a comma-separated '`host:port`' list.
|
`spring.data.elasticsearch.cluster-nodes` to a comma-separated '`host:port`' list.
|
||||||
|
|
||||||
|
[source,properties,indent=0]
|
||||||
|
----
|
||||||
|
spring.data.elasticsearch.cluster-nodes=localhost:9300
|
||||||
|
----
|
||||||
|
|
||||||
[source,java,indent=0]
|
[source,java,indent=0]
|
||||||
----
|
----
|
||||||
@Component
|
@Component
|
||||||
|
|
|
||||||
|
|
@ -26,6 +26,13 @@
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-starter-data-elasticsearch</artifactId>
|
<artifactId>spring-boot-starter-data-elasticsearch</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>net.java.dev.jna</groupId>
|
||||||
|
<artifactId>jna</artifactId>
|
||||||
|
<scope>runtime</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-starter-test</artifactId>
|
<artifactId>spring-boot-starter-test</artifactId>
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,5 @@
|
||||||
|
#
|
||||||
|
# Home directory of the embedded elastic instance. Default to the
|
||||||
|
# current working directory.
|
||||||
|
#
|
||||||
|
spring.data.elasticsearch.properties.path.home=target/elastic
|
||||||
|
|
@ -33,19 +33,13 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||||
* @author Artur Konczak
|
* @author Artur Konczak
|
||||||
*/
|
*/
|
||||||
public class SampleElasticsearchApplicationTests {
|
public class SampleElasticsearchApplicationTests {
|
||||||
|
|
||||||
private static final String[] PROPERTIES = {
|
|
||||||
"spring.data.elasticsearch.properties.path.data:target/data",
|
|
||||||
"spring.data.elasticsearch.properties.path.logs:target/logs" };
|
|
||||||
|
|
||||||
@Rule
|
@Rule
|
||||||
public OutputCapture outputCapture = new OutputCapture();
|
public OutputCapture outputCapture = new OutputCapture();
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testDefaultSettings() throws Exception {
|
public void testDefaultSettings() throws Exception {
|
||||||
try {
|
try {
|
||||||
new SpringApplicationBuilder(SampleElasticsearchApplication.class)
|
new SpringApplicationBuilder(SampleElasticsearchApplication.class).run();
|
||||||
.properties(PROPERTIES).run();
|
|
||||||
}
|
}
|
||||||
catch (IllegalStateException ex) {
|
catch (IllegalStateException ex) {
|
||||||
if (serverNotRunning(ex)) {
|
if (serverNotRunning(ex)) {
|
||||||
|
|
|
||||||
|
|
@ -61,6 +61,7 @@ import org.springframework.util.StringUtils;
|
||||||
* @author Ivan Sopov
|
* @author Ivan Sopov
|
||||||
* @author Andy Wilkinson
|
* @author Andy Wilkinson
|
||||||
* @author Eddú Meléndez
|
* @author Eddú Meléndez
|
||||||
|
* @author Christoph Dreis
|
||||||
* @since 1.2.0
|
* @since 1.2.0
|
||||||
* @see UndertowEmbeddedServletContainerFactory
|
* @see UndertowEmbeddedServletContainerFactory
|
||||||
*/
|
*/
|
||||||
|
|
@ -87,21 +88,105 @@ public class UndertowEmbeddedServletContainer implements EmbeddedServletContaine
|
||||||
|
|
||||||
private boolean started = false;
|
private boolean started = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new {@link UndertowEmbeddedServletContainer} instance.
|
||||||
|
* @param builder the builder
|
||||||
|
* @param manager the deployment manager
|
||||||
|
* @param contextPath root the context path
|
||||||
|
* @param port the port to listen on (not used)
|
||||||
|
* @param autoStart if the server should be started
|
||||||
|
* @param compression compression configuration
|
||||||
|
* @deprecated as of 1.4 in favor of
|
||||||
|
* {@link #UndertowEmbeddedServletContainer(Builder, DeploymentManager, String, boolean, Compression)}
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
public UndertowEmbeddedServletContainer(Builder builder, DeploymentManager manager,
|
public UndertowEmbeddedServletContainer(Builder builder, DeploymentManager manager,
|
||||||
String contextPath, int port, boolean autoStart, Compression compression) {
|
String contextPath, int port, boolean autoStart, Compression compression) {
|
||||||
this(builder, manager, contextPath, port, false, autoStart, compression);
|
this(builder, manager, contextPath, false, autoStart, compression);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new {@link UndertowEmbeddedServletContainer} instance.
|
||||||
|
* @param builder the builder
|
||||||
|
* @param manager the deployment manager
|
||||||
|
* @param contextPath root the context path
|
||||||
|
* @param port the port to listen on (not used)
|
||||||
|
* @param useForwardHeaders if x-forward headers should be used
|
||||||
|
* @param autoStart if the server should be started
|
||||||
|
* @param compression compression configuration
|
||||||
|
* @deprecated as of 1.4 in favor of
|
||||||
|
* {@link #UndertowEmbeddedServletContainer(Builder, DeploymentManager, String, boolean, boolean, Compression)}
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
public UndertowEmbeddedServletContainer(Builder builder, DeploymentManager manager,
|
public UndertowEmbeddedServletContainer(Builder builder, DeploymentManager manager,
|
||||||
String contextPath, int port, boolean useForwardHeaders, boolean autoStart,
|
String contextPath, int port, boolean useForwardHeaders, boolean autoStart,
|
||||||
Compression compression) {
|
Compression compression) {
|
||||||
this(builder, manager, contextPath, port, useForwardHeaders, autoStart,
|
this(builder, manager, contextPath, useForwardHeaders, autoStart, compression);
|
||||||
compression, null);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new {@link UndertowEmbeddedServletContainer} instance.
|
||||||
|
* @param builder the builder
|
||||||
|
* @param manager the deployment manager
|
||||||
|
* @param contextPath root the context path
|
||||||
|
* @param port the port to listen on (not used)
|
||||||
|
* @param useForwardHeaders if x-forward headers should be used
|
||||||
|
* @param autoStart if the server should be started
|
||||||
|
* @param compression compression configuration
|
||||||
|
* @param serverHeader string to be used in http header
|
||||||
|
* @deprecated as of 1.4 in favor of
|
||||||
|
* {@link #UndertowEmbeddedServletContainer(Builder, DeploymentManager, String, boolean, boolean, Compression, String)}
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
public UndertowEmbeddedServletContainer(Builder builder, DeploymentManager manager,
|
public UndertowEmbeddedServletContainer(Builder builder, DeploymentManager manager,
|
||||||
String contextPath, int port, boolean useForwardHeaders, boolean autoStart,
|
String contextPath, int port, boolean useForwardHeaders, boolean autoStart,
|
||||||
Compression compression, String serverHeader) {
|
Compression compression, String serverHeader) {
|
||||||
|
this(builder, manager, contextPath, useForwardHeaders, autoStart, compression,
|
||||||
|
serverHeader);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new {@link UndertowEmbeddedServletContainer} instance.
|
||||||
|
* @param builder the builder
|
||||||
|
* @param manager the deployment manager
|
||||||
|
* @param contextPath root the context path
|
||||||
|
* @param autoStart if the server should be started
|
||||||
|
* @param compression compression configuration
|
||||||
|
*/
|
||||||
|
public UndertowEmbeddedServletContainer(Builder builder, DeploymentManager manager,
|
||||||
|
String contextPath, boolean autoStart, Compression compression) {
|
||||||
|
this(builder, manager, contextPath, false, autoStart, compression);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new {@link UndertowEmbeddedServletContainer} instance.
|
||||||
|
* @param builder the builder
|
||||||
|
* @param manager the deployment manager
|
||||||
|
* @param contextPath root the context path
|
||||||
|
* @param useForwardHeaders if x-forward headers should be used
|
||||||
|
* @param autoStart if the server should be started
|
||||||
|
* @param compression compression configuration
|
||||||
|
*/
|
||||||
|
public UndertowEmbeddedServletContainer(Builder builder, DeploymentManager manager,
|
||||||
|
String contextPath, boolean useForwardHeaders, boolean autoStart,
|
||||||
|
Compression compression) {
|
||||||
|
this(builder, manager, contextPath, useForwardHeaders, autoStart, compression,
|
||||||
|
null);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new {@link UndertowEmbeddedServletContainer} instance.
|
||||||
|
* @param builder the builder
|
||||||
|
* @param manager the deployment manager
|
||||||
|
* @param contextPath root the context path
|
||||||
|
* @param useForwardHeaders if x-forward headers should be used
|
||||||
|
* @param autoStart if the server should be started
|
||||||
|
* @param compression compression configuration
|
||||||
|
* @param serverHeader string to be used in http header
|
||||||
|
*/
|
||||||
|
public UndertowEmbeddedServletContainer(Builder builder, DeploymentManager manager,
|
||||||
|
String contextPath, boolean useForwardHeaders, boolean autoStart,
|
||||||
|
Compression compression, String serverHeader) {
|
||||||
this.builder = builder;
|
this.builder = builder;
|
||||||
this.manager = manager;
|
this.manager = manager;
|
||||||
this.contextPath = contextPath;
|
this.contextPath = contextPath;
|
||||||
|
|
@ -231,10 +316,10 @@ public class UndertowEmbeddedServletContainer implements EmbeddedServletContaine
|
||||||
}
|
}
|
||||||
|
|
||||||
private Port getPortFromChannel(BoundChannel channel) {
|
private Port getPortFromChannel(BoundChannel channel) {
|
||||||
String protocol = ReflectionUtils.findField(channel.getClass(), "ssl") != null
|
|
||||||
? "https" : "http";
|
|
||||||
SocketAddress socketAddress = channel.getLocalAddress();
|
SocketAddress socketAddress = channel.getLocalAddress();
|
||||||
if (socketAddress instanceof InetSocketAddress) {
|
if (socketAddress instanceof InetSocketAddress) {
|
||||||
|
String protocol = ReflectionUtils.findField(channel.getClass(), "ssl") != null
|
||||||
|
? "https" : "http";
|
||||||
return new Port(((InetSocketAddress) socketAddress).getPort(), protocol);
|
return new Port(((InetSocketAddress) socketAddress).getPort(), protocol);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
|
|
|
||||||
|
|
@ -501,8 +501,7 @@ public class UndertowEmbeddedServletContainerFactory
|
||||||
protected UndertowEmbeddedServletContainer getUndertowEmbeddedServletContainer(
|
protected UndertowEmbeddedServletContainer getUndertowEmbeddedServletContainer(
|
||||||
Builder builder, DeploymentManager manager, int port) {
|
Builder builder, DeploymentManager manager, int port) {
|
||||||
return new UndertowEmbeddedServletContainer(builder, manager, getContextPath(),
|
return new UndertowEmbeddedServletContainer(builder, manager, getContextPath(),
|
||||||
port, isUseForwardHeaders(), port >= 0, getCompression(),
|
isUseForwardHeaders(), port >= 0, getCompression(), getServerHeader());
|
||||||
getServerHeader());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -64,7 +64,6 @@ class NoUniqueBeanDefinitionExceptionFailureAnalyzer
|
||||||
message.append(String.format("%s required a single bean, but %d were found:%n",
|
message.append(String.format("%s required a single bean, but %d were found:%n",
|
||||||
getConsumerDescription(unsatisfiedDependency), beanNames.length));
|
getConsumerDescription(unsatisfiedDependency), beanNames.length));
|
||||||
for (String beanName : beanNames) {
|
for (String beanName : beanNames) {
|
||||||
unsatisfiedDependency.getInjectionPoint();
|
|
||||||
try {
|
try {
|
||||||
BeanDefinition beanDefinition = this.beanFactory
|
BeanDefinition beanDefinition = this.beanFactory
|
||||||
.getMergedBeanDefinition(beanName);
|
.getMergedBeanDefinition(beanName);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue