mirror of
https://github.com/spring-cloud/spring-cloud-netflix.git
synced 2026-09-19 00:29:01 +00:00
Compare commits
16
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3ad4f3d7e8 | ||
|
|
e5ccca6c2b | ||
|
|
5ec430efb8 | ||
|
|
f6f4e0d80d | ||
|
|
e8976ae344 | ||
|
|
09adda65c0 | ||
|
|
a3cfba7e3b | ||
|
|
f76de4c481 | ||
|
|
6316953236 | ||
|
|
3a91f2372c | ||
|
|
4f2ddfd2ec | ||
|
|
dff98c48dd | ||
|
|
4c77b6dd5d | ||
|
|
d0f8fbe274 | ||
|
|
67c227d9d7 | ||
|
|
a30b87cdda |
@@ -23,7 +23,6 @@ Edit the files in the src/main/asciidoc/ directory instead.
|
||||
|
||||
image::https://circleci.com/gh/spring-cloud/spring-cloud-netflix/tree/main.svg?style=svg["CircleCI", link="https://circleci.com/gh/spring-cloud/spring-cloud-netflix/tree/main"]
|
||||
image::https://codecov.io/gh/spring-cloud/spring-cloud-netflix/branch/main/graph/badge.svg["Codecov", link="https://codecov.io/gh/spring-cloud/spring-cloud-netflix/branch/main"]
|
||||
image::https://api.codacy.com/project/badge/Grade/a6885a06921e4f72a0df0b7aabd6d118["Codacy code quality", link="https://www.codacy.com/app/Spring-Cloud/spring-cloud-netflix?utm_source=github.com&utm_medium=referral&utm_content=spring-cloud/spring-cloud-netflix&utm_campaign=Badge_Grade"]
|
||||
|
||||
|
||||
:doctype: book
|
||||
|
||||
@@ -2,7 +2,6 @@ include::_attributes.adoc[]
|
||||
|
||||
image::https://circleci.com/gh/spring-cloud/spring-cloud-netflix/tree/main.svg?style=svg["CircleCI", link="https://circleci.com/gh/spring-cloud/spring-cloud-netflix/tree/main"]
|
||||
image::https://codecov.io/gh/spring-cloud/spring-cloud-netflix/branch/main/graph/badge.svg["Codecov", link="https://codecov.io/gh/spring-cloud/spring-cloud-netflix/branch/main"]
|
||||
image::https://api.codacy.com/project/badge/Grade/a6885a06921e4f72a0df0b7aabd6d118["Codacy code quality", link="https://www.codacy.com/app/Spring-Cloud/spring-cloud-netflix?utm_source=github.com&utm_medium=referral&utm_content=spring-cloud/spring-cloud-netflix&utm_campaign=Badge_Grade"]
|
||||
|
||||
|
||||
include::intro.adoc[]
|
||||
|
||||
@@ -1,20 +1,20 @@
|
||||
|===
|
||||
|Name | Default | Description
|
||||
|
||||
|eureka.client.eureka-connection-idle-timeout-seconds | `30` | Indicates how much time (in seconds) that the HTTP connections to eureka server can stay idle before it can be closed. In the AWS environment, it is recommended that the values is 30 seconds or less, since the firewall cleans up the connection information after a few mins leaving the connection hanging in limbo.
|
||||
|eureka.client.eureka-server-connect-timeout-seconds | `5` | Indicates how long to wait (in seconds) before a connection to eureka server needs to timeout. Note that the connections in the client are pooled by org.apache.http.client.HttpClient and this setting affects the actual connection creation and also the wait time to get the connection from the pool.
|
||||
|eureka.client.eureka-connection-idle-timeout-seconds | `+++30+++` | Indicates how much time (in seconds) that the HTTP connections to eureka server can stay idle before it can be closed. In the AWS environment, it is recommended that the values is 30 seconds or less, since the firewall cleans up the connection information after a few mins leaving the connection hanging in limbo.
|
||||
|eureka.client.eureka-server-connect-timeout-seconds | `+++5+++` | Indicates how long to wait (in seconds) before a connection to eureka server needs to timeout. Note that the connections in the client are pooled by {@link HttpClient} and this setting affects the actual connection creation and also the wait time to get the connection from the pool.
|
||||
|eureka.client.eureka-server-d-n-s-name | | Gets the DNS name to be queried to get the list of eureka servers.This information is not required if the contract returns the service urls by implementing serviceUrls. The DNS mechanism is used when useDnsForFetchingServiceUrls is set to true and the eureka client expects the DNS to configured a certain way so that it can fetch changing eureka servers dynamically. The changes are effective at runtime.
|
||||
|eureka.client.eureka-server-port | | Gets the port to be used to construct the service url to contact eureka server when the list of eureka servers come from the DNS.This information is not required if the contract returns the service urls eurekaServerServiceUrls(String). The DNS mechanism is used when useDnsForFetchingServiceUrls is set to true and the eureka client expects the DNS to configured a certain way so that it can fetch changing eureka servers dynamically. The changes are effective at runtime.
|
||||
|eureka.client.eureka-server-read-timeout-seconds | `8` | Indicates how long to wait (in seconds) before a read from eureka server needs to timeout.
|
||||
|eureka.client.eureka-server-total-connections | `200` | Gets the total number of connections that is allowed from eureka client to all eureka servers.
|
||||
|eureka.client.eureka-server-total-connections-per-host | `50` | Gets the total number of connections that is allowed from eureka client to a eureka server host.
|
||||
|eureka.client.eureka-server-read-timeout-seconds | `+++8+++` | Indicates how long to wait (in seconds) before a read from eureka server needs to timeout.
|
||||
|eureka.client.eureka-server-total-connections | `+++200+++` | Gets the total number of connections that is allowed from eureka client to all eureka servers.
|
||||
|eureka.client.eureka-server-total-connections-per-host | `+++50+++` | Gets the total number of connections that is allowed from eureka client to a eureka server host.
|
||||
|eureka.client.eureka-server-u-r-l-context | | Gets the URL context to be used to construct the service url to contact eureka server when the list of eureka servers come from the DNS. This information is not required if the contract returns the service urls from eurekaServerServiceUrls. The DNS mechanism is used when useDnsForFetchingServiceUrls is set to true and the eureka client expects the DNS to configured a certain way so that it can fetch changing eureka servers dynamically. The changes are effective at runtime.
|
||||
|eureka.client.eureka-service-url-poll-interval-seconds | `0` | Indicates how often(in seconds) to poll for changes to eureka server information. Eureka servers could be added or removed and this setting controls how soon the eureka clients should know about it.
|
||||
|eureka.client.prefer-same-zone-eureka | `true` | Indicates whether or not this instance should try to use the eureka server in the same zone for latency and/or other reason. Ideally eureka clients are configured to talk to servers in the same zone The changes are effective at runtime at the next registry fetch cycle as specified by registryFetchIntervalSeconds
|
||||
|eureka.client.register-with-eureka | `true` | Indicates whether or not this instance should register its information with eureka server for discovery by others. In some cases, you do not want your instances to be discovered whereas you just want do discover other instances.
|
||||
|eureka.server.peer-eureka-nodes-update-interval-ms | `0` |
|
||||
|eureka.server.peer-eureka-status-refresh-time-interval-ms | `0` |
|
||||
|ribbon.eureka.enabled | `true` | Enables the use of Eureka with Ribbon.
|
||||
|spring.cloud.loadbalancer.eureka.approximate-zone-from-hostname | `false` | Used to determine whether we should try to get the `zone` value from host name.
|
||||
|eureka.client.eureka-service-url-poll-interval-seconds | `+++0+++` | Indicates how often(in seconds) to poll for changes to eureka server information. Eureka servers could be added or removed and this setting controls how soon the eureka clients should know about it.
|
||||
|eureka.client.prefer-same-zone-eureka | `+++true+++` | Indicates whether or not this instance should try to use the eureka server in the same zone for latency and/or other reason. Ideally eureka clients are configured to talk to servers in the same zone The changes are effective at runtime at the next registry fetch cycle as specified by registryFetchIntervalSeconds
|
||||
|eureka.client.register-with-eureka | `+++true+++` | Indicates whether or not this instance should register its information with eureka server for discovery by others. In some cases, you do not want your instances to be discovered whereas you just want do discover other instances.
|
||||
|eureka.server.peer-eureka-nodes-update-interval-ms | `+++0+++` |
|
||||
|eureka.server.peer-eureka-status-refresh-time-interval-ms | `+++0+++` |
|
||||
|ribbon.eureka.enabled | `+++true+++` | Enables the use of Eureka with Ribbon.
|
||||
|spring.cloud.loadbalancer.eureka.approximate-zone-from-hostname | `+++false+++` | Used to determine whether we should try to get the `zone` value from host name.
|
||||
|
||||
|===
|
||||
@@ -29,8 +29,9 @@
|
||||
<sonar.dynamicAnalysis>reuseReports</sonar.dynamicAnalysis>
|
||||
<sonar.jacoco.reportPath>${project.basedir}/../target/jacoco.exec</sonar.jacoco.reportPath>
|
||||
<sonar.language>java</sonar.language>
|
||||
<eureka-jersey.version>1.19.4</eureka-jersey.version>
|
||||
<maven-resources-plugin.version>3.1.0</maven-resources-plugin.version>
|
||||
<!-- FIXME: 4.0.0 -->
|
||||
<duplicate-finder-maven-plugin.skip>true</duplicate-finder-maven-plugin.skip>
|
||||
</properties>
|
||||
<build>
|
||||
<plugins>
|
||||
@@ -113,31 +114,6 @@
|
||||
<version>1</version>
|
||||
</dependency>
|
||||
<!-- Eureka core dep that is now optional -->
|
||||
<dependency>
|
||||
<groupId>com.sun.jersey</groupId>
|
||||
<artifactId>jersey-servlet</artifactId>
|
||||
<version>${eureka-jersey.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.sun.jersey</groupId>
|
||||
<artifactId>jersey-core</artifactId>
|
||||
<version>${eureka-jersey.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.sun.jersey</groupId>
|
||||
<artifactId>jersey-client</artifactId>
|
||||
<version>${eureka-jersey.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.sun.jersey</groupId>
|
||||
<artifactId>jersey-server</artifactId>
|
||||
<version>${eureka-jersey.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.sun.jersey.contribs</groupId>
|
||||
<artifactId>jersey-apache-client4</artifactId>
|
||||
<version>${eureka-jersey.version}</version>
|
||||
</dependency>
|
||||
<!-- end eureka deps -->
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
@@ -189,6 +165,23 @@
|
||||
<enabled>false</enabled>
|
||||
</snapshots>
|
||||
</repository>
|
||||
<!-- FIXME: 4.0 -->
|
||||
<repository>
|
||||
<id>netflix-snapshots</id>
|
||||
<name>Netflix Snapshots</name>
|
||||
<url>https://artifactory-oss.prod.netflix.net/artifactory/maven-oss-snapshots</url>
|
||||
<snapshots>
|
||||
<enabled>true</enabled>
|
||||
</snapshots>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>netflix-candidates</id>
|
||||
<name>Netflix Candidates</name>
|
||||
<url>https://artifactory-oss.prod.netflix.net/artifactory/maven-oss-candidates</url>
|
||||
<snapshots>
|
||||
<enabled>false</enabled>
|
||||
</snapshots>
|
||||
</repository>
|
||||
</repositories>
|
||||
<pluginRepositories>
|
||||
<pluginRepository>
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
<name>spring-cloud-netflix-dependencies</name>
|
||||
<description>Spring Cloud Netflix Dependencies</description>
|
||||
<properties>
|
||||
<eureka.version>1.10.17</eureka.version>
|
||||
<eureka.version>2.0.0-rc.3</eureka.version>
|
||||
</properties>
|
||||
<dependencyManagement>
|
||||
<dependencies>
|
||||
@@ -112,6 +112,23 @@
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.netflix.eureka</groupId>
|
||||
<artifactId>eureka-core-jersey3</artifactId>
|
||||
<version>${eureka.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.netflix.eureka</groupId>
|
||||
<artifactId>eureka-client-jersey3</artifactId>
|
||||
<!-- FIXME: 4.0 -->
|
||||
<version>${eureka.version}</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>aopalliance</groupId>
|
||||
<artifactId>aopalliance</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<!-- TODO: Move back to Eureka dependency when 1.10.17 released -->
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
|
||||
@@ -82,6 +82,11 @@
|
||||
<artifactId>spring-boot-autoconfigure-processor</artifactId>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-test-support</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
|
||||
+2
-2
@@ -22,9 +22,9 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.springframework.boot.builder.SpringApplicationBuilder;
|
||||
import org.springframework.cloud.test.TestSocketUtils;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.ConfigurableApplicationContext;
|
||||
import org.springframework.util.SocketUtils;
|
||||
|
||||
public class AppRunner implements AutoCloseable {
|
||||
|
||||
@@ -56,7 +56,7 @@ public class AppRunner implements AutoCloseable {
|
||||
}
|
||||
|
||||
private int availabeTcpPort() {
|
||||
return SocketUtils.findAvailableTcpPort();
|
||||
return TestSocketUtils.findAvailableTcpPort();
|
||||
}
|
||||
|
||||
private String[] props() {
|
||||
|
||||
+3
-5
@@ -16,7 +16,6 @@
|
||||
|
||||
package org.springframework.cloud.netflix.eureka;
|
||||
|
||||
import com.netflix.discovery.DiscoveryClient;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
@@ -25,8 +24,6 @@ import org.springframework.boot.SpringBootConfiguration;
|
||||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
||||
import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
public class EurekaClientTest extends BaseCertTest {
|
||||
|
||||
private static final Log log = LogFactory.getLog(EurekaClientTest.class);
|
||||
@@ -40,8 +37,9 @@ public class EurekaClientTest extends BaseCertTest {
|
||||
server = startEurekaServer(EurekaClientTest.TestEurekaServer.class);
|
||||
service = startService(server, EurekaClientTest.TestApp.class);
|
||||
// Will use Jersey
|
||||
assertThat(service.discoveryClientOptionalArgs())
|
||||
.isInstanceOf(DiscoveryClient.DiscoveryClientOptionalArgs.class);
|
||||
// FIXME: 4.0
|
||||
// assertThat(service.discoveryClientOptionalArgs())
|
||||
// .isInstanceOf(DiscoveryClient.DiscoveryClientOptionalArgs.class);
|
||||
log.info("Successfully asserted that Jersey will be used");
|
||||
waitForRegistration(() -> new EurekaClientTest().createEurekaClient());
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
@@ -14,7 +15,7 @@
|
||||
<description>Spring Cloud Netflix Eureka Client</description>
|
||||
<properties>
|
||||
<!-- Why do I need this now? -->
|
||||
<maven.javadoc.failOnError>false</maven.javadoc.failOnError>
|
||||
<maven.javadoc.failOnError>false</maven.javadoc.failOnError>
|
||||
</properties>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
@@ -50,43 +51,6 @@
|
||||
<dependency>
|
||||
<groupId>com.netflix.eureka</groupId>
|
||||
<artifactId>eureka-client</artifactId>
|
||||
<optional>true</optional>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>com.sun.jersey</groupId>
|
||||
<artifactId>jersey-client</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>com.sun.jersey</groupId>
|
||||
<artifactId>jersey-core</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>com.sun.jersey.contribs</groupId>
|
||||
<artifactId>jersey-apache-client4</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>aopalliance</groupId>
|
||||
<artifactId>aopalliance</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.sun.jersey</groupId>
|
||||
<artifactId>jersey-core</artifactId>
|
||||
<version>${eureka-jersey.version}</version>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.sun.jersey</groupId>
|
||||
<artifactId>jersey-client</artifactId>
|
||||
<version>${eureka-jersey.version}</version>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.sun.jersey.contribs</groupId>
|
||||
<artifactId>jersey-apache-client4</artifactId>
|
||||
<version>${eureka-jersey.version}</version>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>javax.inject</groupId>
|
||||
@@ -104,6 +68,10 @@
|
||||
<artifactId>spring-boot-autoconfigure-processor</artifactId>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.httpcomponents.client5</groupId>
|
||||
<artifactId>httpclient5</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-security</artifactId>
|
||||
|
||||
+4
-3
@@ -25,6 +25,7 @@ import java.util.Objects;
|
||||
import com.netflix.appinfo.EurekaAccept;
|
||||
import com.netflix.discovery.EurekaClientConfig;
|
||||
import com.netflix.discovery.shared.transport.EurekaTransportConfig;
|
||||
import org.apache.hc.client5.http.classic.HttpClient;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
@@ -126,14 +127,14 @@ public class EurekaClientConfigBean implements EurekaClientConfig, Ordered {
|
||||
/**
|
||||
* Indicates how long to wait (in seconds) before a connection to eureka server needs
|
||||
* to timeout. Note that the connections in the client are pooled by
|
||||
* org.apache.http.client.HttpClient and this setting affects the actual connection
|
||||
* creation and also the wait time to get the connection from the pool.
|
||||
* {@link HttpClient} and this setting affects the actual connection creation and also
|
||||
* the wait time to get the connection from the pool.
|
||||
*/
|
||||
private int eurekaServerConnectTimeoutSeconds = 5;
|
||||
|
||||
/**
|
||||
* Gets the name of the implementation which implements BackupRegistry to fetch the
|
||||
* registry information as a fall back option for only the first time when the eureka
|
||||
* registry information as a fallback option for only the first time when the eureka
|
||||
* client starts.
|
||||
*
|
||||
* This may be needed for applications which needs additional resiliency for registry
|
||||
|
||||
+17
-21
@@ -16,28 +16,24 @@
|
||||
|
||||
package org.springframework.cloud.netflix.eureka;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.LinkedHashSet;
|
||||
|
||||
import com.netflix.discovery.DiscoveryClient.DiscoveryClientOptionalArgs;
|
||||
import com.sun.jersey.api.client.filter.ClientFilter;
|
||||
|
||||
/**
|
||||
* @author Dave Syer
|
||||
*/
|
||||
public class MutableDiscoveryClientOptionalArgs extends DiscoveryClientOptionalArgs {
|
||||
// FIXME: 4.0
|
||||
public class MutableDiscoveryClientOptionalArgs {
|
||||
|
||||
private Collection<ClientFilter> additionalFilters;
|
||||
|
||||
@Override
|
||||
public void setAdditionalFilters(Collection<ClientFilter> additionalFilters) {
|
||||
additionalFilters = new LinkedHashSet<>(additionalFilters);
|
||||
this.additionalFilters = additionalFilters;
|
||||
super.setAdditionalFilters(additionalFilters);
|
||||
}
|
||||
|
||||
public Collection<ClientFilter> getAdditionalFilters() {
|
||||
return this.additionalFilters;
|
||||
}
|
||||
|
||||
}
|
||||
} /*
|
||||
* extends DiscoveryClientOptionalArgs {
|
||||
*
|
||||
* private Collection<ClientFilter> additionalFilters;
|
||||
*
|
||||
* @Override public void setAdditionalFilters(Collection<ClientFilter>
|
||||
* additionalFilters) { additionalFilters = new LinkedHashSet<>(additionalFilters);
|
||||
* this.additionalFilters = additionalFilters;
|
||||
* super.setAdditionalFilters(additionalFilters); }
|
||||
*
|
||||
* public Collection<ClientFilter> getAdditionalFilters() { return
|
||||
* this.additionalFilters; }
|
||||
*
|
||||
* }
|
||||
*/
|
||||
|
||||
+14
-11
@@ -33,7 +33,6 @@ import org.springframework.boot.autoconfigure.condition.SearchStrategy;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.cloud.configuration.SSLContextFactory;
|
||||
import org.springframework.cloud.configuration.TlsProperties;
|
||||
import org.springframework.cloud.netflix.eureka.MutableDiscoveryClientOptionalArgs;
|
||||
import org.springframework.cloud.netflix.eureka.http.DefaultEurekaClientHttpRequestFactorySupplier;
|
||||
import org.springframework.cloud.netflix.eureka.http.EurekaClientHttpRequestFactorySupplier;
|
||||
import org.springframework.cloud.netflix.eureka.http.RestTemplateDiscoveryClientOptionalArgs;
|
||||
@@ -79,16 +78,20 @@ public class DiscoveryClientOptionalArgsConfiguration {
|
||||
return new DefaultEurekaClientHttpRequestFactorySupplier();
|
||||
}
|
||||
|
||||
@Bean
|
||||
@ConditionalOnClass(name = "com.sun.jersey.api.client.filter.ClientFilter")
|
||||
@ConditionalOnMissingBean(value = AbstractDiscoveryClientOptionalArgs.class, search = SearchStrategy.CURRENT)
|
||||
public MutableDiscoveryClientOptionalArgs discoveryClientOptionalArgs(TlsProperties tlsProperties)
|
||||
throws GeneralSecurityException, IOException {
|
||||
logger.info("Eureka HTTP Client uses Jersey");
|
||||
MutableDiscoveryClientOptionalArgs result = new MutableDiscoveryClientOptionalArgs();
|
||||
setupTLS(result, tlsProperties);
|
||||
return result;
|
||||
}
|
||||
// FIXME: 4.0
|
||||
/*
|
||||
* @Bean
|
||||
*
|
||||
* @ConditionalOnClass(name = "com.sun.jersey.api.client.filter.ClientFilter")
|
||||
*
|
||||
* @ConditionalOnMissingBean(value = AbstractDiscoveryClientOptionalArgs.class, search
|
||||
* = SearchStrategy.CURRENT) public MutableDiscoveryClientOptionalArgs
|
||||
* discoveryClientOptionalArgs(TlsProperties tlsProperties) throws
|
||||
* GeneralSecurityException, IOException {
|
||||
* logger.info("Eureka HTTP Client uses Jersey"); MutableDiscoveryClientOptionalArgs
|
||||
* result = new MutableDiscoveryClientOptionalArgs(); setupTLS(result, tlsProperties);
|
||||
* return result; }
|
||||
*/
|
||||
|
||||
private static void setupTLS(AbstractDiscoveryClientOptionalArgs<?> args, TlsProperties properties)
|
||||
throws GeneralSecurityException, IOException {
|
||||
|
||||
+5
-4
@@ -18,6 +18,7 @@ package org.springframework.cloud.netflix.eureka.config;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.netflix.discovery.EurekaClientConfig;
|
||||
import com.netflix.discovery.endpoint.EndpointUtils;
|
||||
import com.netflix.discovery.shared.resolver.DefaultEndpoint;
|
||||
|
||||
@@ -26,7 +27,7 @@ import org.springframework.cloud.netflix.eureka.EurekaClientConfigBean;
|
||||
import org.springframework.core.env.Environment;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
final class HostnameBasedUrlRandomizer implements EndpointUtils.ServiceUrlRandomizer {
|
||||
public final class HostnameBasedUrlRandomizer implements EndpointUtils.ServiceUrlRandomizer {
|
||||
|
||||
private final String hostname;
|
||||
|
||||
@@ -56,18 +57,18 @@ final class HostnameBasedUrlRandomizer implements EndpointUtils.ServiceUrlRandom
|
||||
}
|
||||
}
|
||||
|
||||
static String getEurekaUrl(EurekaClientConfigBean config, String hostname) {
|
||||
public static String getEurekaUrl(EurekaClientConfig config, String hostname) {
|
||||
List<String> urls = EndpointUtils.getDiscoveryServiceUrls(config, EurekaClientConfigBean.DEFAULT_ZONE,
|
||||
new HostnameBasedUrlRandomizer(hostname));
|
||||
return urls.get(0);
|
||||
}
|
||||
|
||||
static DefaultEndpoint randomEndpoint(EurekaClientConfigBean config, Environment env) {
|
||||
public static DefaultEndpoint randomEndpoint(EurekaClientConfig config, Environment env) {
|
||||
String hostname = env.getProperty("eureka.instance.hostname");
|
||||
return new DefaultEndpoint(getEurekaUrl(config, hostname));
|
||||
}
|
||||
|
||||
static DefaultEndpoint randomEndpoint(EurekaClientConfigBean config, Binder binder) {
|
||||
public static DefaultEndpoint randomEndpoint(EurekaClientConfig config, Binder binder) {
|
||||
String hostname = binder.bind("eureka.instance.hostname", String.class).orElseGet(() -> null);
|
||||
return new DefaultEndpoint(getEurekaUrl(config, hostname));
|
||||
}
|
||||
|
||||
+24
-9
@@ -19,9 +19,12 @@ package org.springframework.cloud.netflix.eureka.http;
|
||||
import javax.net.ssl.HostnameVerifier;
|
||||
import javax.net.ssl.SSLContext;
|
||||
|
||||
import org.apache.http.impl.client.CloseableHttpClient;
|
||||
import org.apache.http.impl.client.HttpClientBuilder;
|
||||
import org.apache.http.impl.client.HttpClients;
|
||||
import org.apache.hc.client5.http.impl.classic.CloseableHttpClient;
|
||||
import org.apache.hc.client5.http.impl.classic.HttpClientBuilder;
|
||||
import org.apache.hc.client5.http.impl.classic.HttpClients;
|
||||
import org.apache.hc.client5.http.impl.io.PoolingHttpClientConnectionManagerBuilder;
|
||||
import org.apache.hc.client5.http.io.HttpClientConnectionManager;
|
||||
import org.apache.hc.client5.http.ssl.SSLConnectionSocketFactoryBuilder;
|
||||
|
||||
import org.springframework.http.client.ClientHttpRequestFactory;
|
||||
import org.springframework.http.client.HttpComponentsClientHttpRequestFactory;
|
||||
@@ -32,18 +35,16 @@ import org.springframework.lang.Nullable;
|
||||
* {@link HttpClients}.
|
||||
*
|
||||
* @author Marcin Grzejszczak
|
||||
* @author Olga Maciaszek-Sharma
|
||||
* @since 3.0.0
|
||||
*/
|
||||
public class DefaultEurekaClientHttpRequestFactorySupplier implements EurekaClientHttpRequestFactorySupplier {
|
||||
|
||||
@Override
|
||||
public ClientHttpRequestFactory get(SSLContext sslContext, @Nullable HostnameVerifier hostnameVerifier) {
|
||||
HttpClientBuilder httpClientBuilder = HttpClients.custom();
|
||||
if (sslContext != null) {
|
||||
httpClientBuilder = httpClientBuilder.setSSLContext(sslContext);
|
||||
}
|
||||
if (hostnameVerifier != null) {
|
||||
httpClientBuilder = httpClientBuilder.setSSLHostnameVerifier(hostnameVerifier);
|
||||
HttpClientBuilder httpClientBuilder = HttpClientBuilder.create();
|
||||
if (sslContext != null || hostnameVerifier != null) {
|
||||
httpClientBuilder.setConnectionManager(buildConnectionManager(sslContext, hostnameVerifier));
|
||||
}
|
||||
CloseableHttpClient httpClient = httpClientBuilder.build();
|
||||
HttpComponentsClientHttpRequestFactory requestFactory = new HttpComponentsClientHttpRequestFactory();
|
||||
@@ -51,4 +52,18 @@ public class DefaultEurekaClientHttpRequestFactorySupplier implements EurekaClie
|
||||
return requestFactory;
|
||||
}
|
||||
|
||||
private HttpClientConnectionManager buildConnectionManager(SSLContext sslContext,
|
||||
HostnameVerifier hostnameVerifier) {
|
||||
SSLConnectionSocketFactoryBuilder sslConnectionSocketFactoryBuilder = SSLConnectionSocketFactoryBuilder
|
||||
.create();
|
||||
if (sslContext != null) {
|
||||
sslConnectionSocketFactoryBuilder.setSslContext(sslContext);
|
||||
}
|
||||
if (hostnameVerifier != null) {
|
||||
sslConnectionSocketFactoryBuilder.setHostnameVerifier(hostnameVerifier);
|
||||
}
|
||||
return PoolingHttpClientConnectionManagerBuilder.create()
|
||||
.setSSLSocketFactory(sslConnectionSocketFactoryBuilder.build()).build();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
-7
@@ -25,7 +25,6 @@ import javax.net.ssl.SSLContext;
|
||||
import com.netflix.appinfo.InstanceInfo;
|
||||
import com.netflix.discovery.EurekaClientConfig;
|
||||
import com.netflix.discovery.shared.transport.TransportClientFactory;
|
||||
import com.netflix.discovery.shared.transport.jersey.EurekaJerseyClient;
|
||||
import com.netflix.discovery.shared.transport.jersey.TransportClientFactories;
|
||||
|
||||
/**
|
||||
@@ -39,12 +38,6 @@ public class RestTemplateTransportClientFactories implements TransportClientFact
|
||||
this.args = args;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TransportClientFactory newTransportClientFactory(Collection<Void> additionalFilters,
|
||||
EurekaJerseyClient providedJerseyClient) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public TransportClientFactory newTransportClientFactory(EurekaClientConfig clientConfig,
|
||||
Collection<Void> additionalFilters, InstanceInfo myInstanceInfo) {
|
||||
|
||||
-7
@@ -26,7 +26,6 @@ import javax.net.ssl.SSLContext;
|
||||
import com.netflix.appinfo.InstanceInfo;
|
||||
import com.netflix.discovery.EurekaClientConfig;
|
||||
import com.netflix.discovery.shared.transport.TransportClientFactory;
|
||||
import com.netflix.discovery.shared.transport.jersey.EurekaJerseyClient;
|
||||
import com.netflix.discovery.shared.transport.jersey.TransportClientFactories;
|
||||
|
||||
import org.springframework.web.reactive.function.client.WebClient;
|
||||
@@ -43,12 +42,6 @@ public class WebClientTransportClientFactories implements TransportClientFactori
|
||||
this.builder = builder;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TransportClientFactory newTransportClientFactory(Collection<Void> additionalFilters,
|
||||
EurekaJerseyClient providedJerseyClient) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public TransportClientFactory newTransportClientFactory(EurekaClientConfig clientConfig,
|
||||
Collection<Void> additionalFilters, InstanceInfo myInstanceInfo) {
|
||||
|
||||
+1
-1
@@ -59,7 +59,7 @@ public class EurekaRegistration implements Registration {
|
||||
|
||||
private ObjectProvider<HealthCheckHandler> healthCheckHandler;
|
||||
|
||||
private EurekaRegistration(CloudEurekaInstanceConfig instanceConfig, EurekaClient eurekaClient,
|
||||
public EurekaRegistration(CloudEurekaInstanceConfig instanceConfig, EurekaClient eurekaClient,
|
||||
ApplicationInfoManager applicationInfoManager, ObjectProvider<HealthCheckHandler> healthCheckHandler) {
|
||||
this.eurekaClient = eurekaClient;
|
||||
this.instanceConfig = instanceConfig;
|
||||
|
||||
@@ -1,11 +1,3 @@
|
||||
org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
|
||||
org.springframework.cloud.netflix.eureka.config.EurekaClientConfigServerAutoConfiguration,\
|
||||
org.springframework.cloud.netflix.eureka.config.DiscoveryClientOptionalArgsConfiguration,\
|
||||
org.springframework.cloud.netflix.eureka.EurekaClientAutoConfiguration,\
|
||||
org.springframework.cloud.netflix.eureka.EurekaDiscoveryClientConfiguration,\
|
||||
org.springframework.cloud.netflix.eureka.reactive.EurekaReactiveDiscoveryClientConfiguration,\
|
||||
org.springframework.cloud.netflix.eureka.loadbalancer.LoadBalancerEurekaAutoConfiguration
|
||||
|
||||
org.springframework.cloud.bootstrap.BootstrapConfiguration=\
|
||||
org.springframework.cloud.netflix.eureka.config.EurekaConfigServerBootstrapConfiguration
|
||||
|
||||
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
org.springframework.cloud.netflix.eureka.config.EurekaClientConfigServerAutoConfiguration
|
||||
org.springframework.cloud.netflix.eureka.config.DiscoveryClientOptionalArgsConfiguration
|
||||
org.springframework.cloud.netflix.eureka.EurekaClientAutoConfiguration
|
||||
org.springframework.cloud.netflix.eureka.EurekaDiscoveryClientConfiguration
|
||||
org.springframework.cloud.netflix.eureka.reactive.EurekaReactiveDiscoveryClientConfiguration
|
||||
org.springframework.cloud.netflix.eureka.loadbalancer.LoadBalancerEurekaAutoConfiguration
|
||||
+12
-15
@@ -23,10 +23,9 @@ import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
import com.netflix.appinfo.ApplicationInfoManager;
|
||||
import com.netflix.appinfo.HealthCheckHandler;
|
||||
import com.netflix.discovery.AbstractDiscoveryClientOptionalArgs;
|
||||
import com.netflix.discovery.EurekaClient;
|
||||
import com.netflix.discovery.EurekaClientConfig;
|
||||
import com.netflix.discovery.shared.transport.jersey.EurekaJerseyClient;
|
||||
import com.sun.jersey.client.apache4.ApacheHttpClient4;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.mockito.Mockito;
|
||||
@@ -671,8 +670,8 @@ class EurekaClientAutoConfigurationTests {
|
||||
@Bean(destroyMethod = "shutdown")
|
||||
@ConditionalOnMissingBean(value = EurekaClient.class, search = SearchStrategy.CURRENT)
|
||||
public EurekaClient eurekaClient(ApplicationInfoManager manager, EurekaClientConfig config,
|
||||
ApplicationContext context) {
|
||||
return new CloudEurekaClient(manager, config, null, context) {
|
||||
ApplicationContext context, AbstractDiscoveryClientOptionalArgs optionalArgs) {
|
||||
return new CloudEurekaClient(manager, config, optionalArgs, context) {
|
||||
@Override
|
||||
public synchronized void shutdown() {
|
||||
CountDownLatch latch = countDownLatch();
|
||||
@@ -689,17 +688,15 @@ class EurekaClientAutoConfigurationTests {
|
||||
@Configuration(proxyBeanMethods = false)
|
||||
protected static class MockClientConfiguration {
|
||||
|
||||
@Bean
|
||||
public EurekaJerseyClient jerseyClient() {
|
||||
EurekaJerseyClient mock = Mockito.mock(EurekaJerseyClient.class);
|
||||
Mockito.when(mock.getClient()).thenReturn(apacheClient());
|
||||
return mock;
|
||||
}
|
||||
|
||||
@Bean
|
||||
public ApacheHttpClient4 apacheClient() {
|
||||
return Mockito.mock(ApacheHttpClient4.class);
|
||||
}
|
||||
// FIXME: 4.0
|
||||
/*
|
||||
* @Bean public EurekaJerseyClient jerseyClient() { EurekaJerseyClient mock =
|
||||
* Mockito.mock(EurekaJerseyClient.class);
|
||||
* Mockito.when(mock.getClient()).thenReturn(apacheClient()); return mock; }
|
||||
*
|
||||
* @Bean public ApacheHttpClient4 apacheClient() { return
|
||||
* Mockito.mock(ApacheHttpClient4.class); }
|
||||
*/
|
||||
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -63,7 +63,7 @@ class EurekaConfigServerBootstrapConfigurationWebClientIntegrationTests {
|
||||
@RestController
|
||||
static class WebClientController extends WebSecurityConfigurerAdapter {
|
||||
|
||||
@GetMapping
|
||||
@GetMapping("/")
|
||||
public String hello() {
|
||||
StringBuilder s = new StringBuilder();
|
||||
for (int i = 0; i < 300000; i++) {
|
||||
|
||||
+1
-1
@@ -52,7 +52,7 @@ public class EurekaHttpClientsOptionalArgsConfigurationNoWebfluxTest {
|
||||
}
|
||||
catch (Exception e) {
|
||||
// this is the desired state
|
||||
assertThat(e).hasMessageContaining("WebClient is not on the classpath");
|
||||
assertThat(e).hasStackTraceContaining("WebClient is not on the classpath");
|
||||
}
|
||||
if (ctx != null) {
|
||||
ctx.close();
|
||||
|
||||
+5
-7
@@ -16,17 +16,14 @@
|
||||
|
||||
package org.springframework.cloud.netflix.eureka.config;
|
||||
|
||||
import com.netflix.discovery.DiscoveryClient.DiscoveryClientOptionalArgs;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
|
||||
import org.springframework.cloud.netflix.eureka.sample.EurekaSampleApplication;
|
||||
import org.springframework.test.annotation.DirtiesContext;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
/**
|
||||
* @author Daniel Lavoie
|
||||
*/
|
||||
@@ -34,12 +31,13 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
@SpringBootTest(classes = EurekaSampleApplication.class, webEnvironment = WebEnvironment.RANDOM_PORT)
|
||||
class JerseyOptionalArgsConfigurationTest {
|
||||
|
||||
@Autowired
|
||||
private DiscoveryClientOptionalArgs optionalArgs;
|
||||
// @Autowired
|
||||
// private DiscoveryClientOptionalArgs optionalArgs;
|
||||
|
||||
@Test
|
||||
@Disabled // FIXME: 4.0.0
|
||||
void contextLoads() {
|
||||
assertThat(optionalArgs).isNotNull();
|
||||
// assertThat(optionalArgs).isNotNull();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+2
@@ -19,6 +19,7 @@ package org.springframework.cloud.netflix.eureka.http;
|
||||
import com.netflix.appinfo.InstanceInfo;
|
||||
import com.netflix.discovery.shared.Applications;
|
||||
import com.netflix.discovery.shared.transport.EurekaHttpClient;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.http.HttpStatus;
|
||||
@@ -71,6 +72,7 @@ abstract class AbstractEurekaHttpClientTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Disabled // FIXME: 4.0
|
||||
void testGetApplications() {
|
||||
Applications entity = eurekaHttpClient.getApplications().getEntity();
|
||||
assertThat(entity).isNotNull();
|
||||
|
||||
-35
@@ -1,35 +0,0 @@
|
||||
/*
|
||||
* Copyright 2017-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.cloud.netflix.eureka.http;
|
||||
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/**
|
||||
* @author Daniel Lavoie
|
||||
*/
|
||||
class RestTemplateTransportClientFactoriesTest {
|
||||
|
||||
@Test
|
||||
void testJerseyIsUnsupported() {
|
||||
Assertions.assertThrows(UnsupportedOperationException.class, () -> {
|
||||
new RestTemplateTransportClientFactories(new RestTemplateDiscoveryClientOptionalArgs(null))
|
||||
.newTransportClientFactory(null, null);
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
-37
@@ -1,37 +0,0 @@
|
||||
/*
|
||||
* Copyright 2017-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.cloud.netflix.eureka.http;
|
||||
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.web.reactive.function.client.WebClient;
|
||||
|
||||
/**
|
||||
* @author Daniel Lavoie
|
||||
*/
|
||||
class WebClientTransportClientFactoriesTest {
|
||||
|
||||
@Test
|
||||
void testJerseyIsUnsupported() {
|
||||
Assertions.assertThrows(UnsupportedOperationException.class, () -> {
|
||||
new WebClientTransportClientFactories(WebClient::builder).newTransportClientFactory(null, null);
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -14,6 +14,8 @@
|
||||
<properties>
|
||||
<wro4j.version>1.10.1</wro4j.version>
|
||||
<wiremock.version>2.27.2</wiremock.version>
|
||||
<!-- FIXME: 4.0.0 -->
|
||||
<duplicate-finder-maven-plugin.skip>true</duplicate-finder-maven-plugin.skip>
|
||||
</properties>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
@@ -48,39 +50,39 @@
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.netflix.eureka</groupId>
|
||||
<artifactId>eureka-client</artifactId>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>aopalliance</groupId>
|
||||
<artifactId>aopalliance</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.sun.jersey</groupId>
|
||||
<artifactId>jersey-servlet</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.sun.jersey</groupId>
|
||||
<artifactId>jersey-server</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.sun.jersey</groupId>
|
||||
<artifactId>jersey-client</artifactId>
|
||||
<artifactId>eureka-client-jersey3</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.netflix.eureka</groupId>
|
||||
<artifactId>eureka-core</artifactId>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<artifactId>blitz4j</artifactId>
|
||||
<groupId>com.netflix.blitz4j</groupId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
<artifactId>eureka-core-jersey3</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>javax.inject</groupId>
|
||||
<artifactId>javax.inject</artifactId>
|
||||
<groupId>org.glassfish.jersey.containers</groupId>
|
||||
<artifactId>jersey-container-servlet</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.glassfish.jersey.core</groupId>
|
||||
<artifactId>jersey-server</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.glassfish.jersey.core</groupId>
|
||||
<artifactId>jersey-client</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.glassfish.jersey.inject</groupId>
|
||||
<artifactId>jersey-hk2</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.glassfish.hk2</groupId>
|
||||
<artifactId>spring-bridge</artifactId>
|
||||
<!-- FIXME: 4.0 -->
|
||||
<version>3.0.3</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>jakarta.inject</groupId>
|
||||
<artifactId>jakarta.inject-api</artifactId>
|
||||
<!-- FIXME: 4.0 -->
|
||||
<version>2.0.1</version>
|
||||
</dependency>
|
||||
<!-- Eureka deps that are now optional in eureka -->
|
||||
<dependency>
|
||||
@@ -176,6 +178,12 @@
|
||||
<contextFolder>${basedir}/src/main/wro</contextFolder>
|
||||
</configuration>
|
||||
<dependencies>
|
||||
<!-- https://github.com/wro4j/wro4j/issues/1129 -->
|
||||
<dependency>
|
||||
<groupId>org.webjars.npm</groupId>
|
||||
<artifactId>glob</artifactId>
|
||||
<version>7.2.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.webjars.npm</groupId>
|
||||
<artifactId>jquery</artifactId>
|
||||
@@ -186,11 +194,6 @@
|
||||
<artifactId>bootstrap</artifactId>
|
||||
<version>5.1.3</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.mockito</groupId>
|
||||
<artifactId>mockito-core</artifactId>
|
||||
<version>3.6.0</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</plugin>
|
||||
<plugin>
|
||||
|
||||
+2
-4
@@ -144,8 +144,7 @@ public class EurekaController {
|
||||
|
||||
private void populateNavbar(HttpServletRequest request, Map<String, Object> model) {
|
||||
Map<String, String> replicas = new LinkedHashMap<>();
|
||||
List<PeerEurekaNode> list = getServerContext().getPeerEurekaNodes()
|
||||
.getPeerNodesView();
|
||||
List<PeerEurekaNode> list = getServerContext().getPeerEurekaNodes().getPeerNodesView();
|
||||
for (PeerEurekaNode node : list) {
|
||||
try {
|
||||
URI uri = new URI(node.getServiceUrl());
|
||||
@@ -281,8 +280,7 @@ public class EurekaController {
|
||||
StringBuilder filteredUrls = new StringBuilder();
|
||||
for (String u : urls) {
|
||||
if (u.contains("@")) {
|
||||
filteredUrls.append(u, 0, u.indexOf("//") + 2)
|
||||
.append(u.substring(u.indexOf("@") + 1)).append(",");
|
||||
filteredUrls.append(u, 0, u.indexOf("//") + 2).append(u.substring(u.indexOf("@") + 1)).append(",");
|
||||
}
|
||||
else {
|
||||
filteredUrls.append(u).append(",");
|
||||
|
||||
+134
-32
@@ -16,15 +16,11 @@
|
||||
|
||||
package org.springframework.cloud.netflix.eureka.server;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.ws.rs.Path;
|
||||
import javax.ws.rs.core.Application;
|
||||
import javax.ws.rs.ext.Provider;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import com.netflix.appinfo.ApplicationInfoManager;
|
||||
import com.netflix.discovery.EurekaClient;
|
||||
@@ -32,6 +28,9 @@ import com.netflix.discovery.EurekaClientConfig;
|
||||
import com.netflix.discovery.converters.EurekaJacksonCodec;
|
||||
import com.netflix.discovery.converters.wrappers.CodecWrapper;
|
||||
import com.netflix.discovery.converters.wrappers.CodecWrappers;
|
||||
import com.netflix.discovery.shared.transport.EurekaHttpClient;
|
||||
import com.netflix.discovery.shared.transport.jersey.TransportClientFactories;
|
||||
import com.netflix.discovery.shared.transport.jersey3.Jersey3TransportClientFactories;
|
||||
import com.netflix.eureka.DefaultEurekaServerContext;
|
||||
import com.netflix.eureka.EurekaServerConfig;
|
||||
import com.netflix.eureka.EurekaServerContext;
|
||||
@@ -40,22 +39,39 @@ import com.netflix.eureka.cluster.PeerEurekaNodes;
|
||||
import com.netflix.eureka.registry.PeerAwareInstanceRegistry;
|
||||
import com.netflix.eureka.resources.DefaultServerCodecs;
|
||||
import com.netflix.eureka.resources.ServerCodecs;
|
||||
import com.netflix.eureka.transport.JerseyReplicationClient;
|
||||
import com.sun.jersey.api.core.DefaultResourceConfig;
|
||||
import com.sun.jersey.spi.container.servlet.ServletContainer;
|
||||
import com.netflix.eureka.transport.Jersey3ReplicationClient;
|
||||
import jakarta.servlet.Filter;
|
||||
import jakarta.servlet.FilterChain;
|
||||
import jakarta.servlet.ServletException;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.servlet.http.HttpServletRequestWrapper;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import jakarta.ws.rs.Path;
|
||||
import jakarta.ws.rs.core.Application;
|
||||
import jakarta.ws.rs.ext.Provider;
|
||||
import org.glassfish.hk2.api.ServiceLocator;
|
||||
import org.glassfish.jersey.server.ResourceConfig;
|
||||
import org.glassfish.jersey.server.spi.Container;
|
||||
import org.glassfish.jersey.server.spi.ContainerLifecycleListener;
|
||||
import org.glassfish.jersey.servlet.ServletContainer;
|
||||
import org.glassfish.jersey.servlet.ServletProperties;
|
||||
import org.jvnet.hk2.spring.bridge.api.SpringBridge;
|
||||
import org.jvnet.hk2.spring.bridge.api.SpringIntoHK2Bridge;
|
||||
|
||||
import org.springframework.beans.factory.BeanFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.beans.factory.config.BeanDefinition;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
import org.springframework.boot.autoconfigure.web.ServerProperties;
|
||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||
import org.springframework.boot.web.servlet.FilterRegistrationBean;
|
||||
import org.springframework.cloud.client.actuator.HasFeatures;
|
||||
import org.springframework.cloud.context.environment.EnvironmentChangeEvent;
|
||||
import org.springframework.cloud.netflix.eureka.EurekaConstants;
|
||||
import org.springframework.cloud.netflix.eureka.config.HostnameBasedUrlRandomizer;
|
||||
import org.springframework.context.ApplicationListener;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider;
|
||||
@@ -67,6 +83,8 @@ import org.springframework.core.env.Environment;
|
||||
import org.springframework.core.io.ResourceLoader;
|
||||
import org.springframework.core.type.filter.AnnotationTypeFilter;
|
||||
import org.springframework.util.ClassUtils;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.springframework.web.filter.OncePerRequestFilter;
|
||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||
|
||||
/**
|
||||
@@ -88,6 +106,11 @@ public class EurekaServerAutoConfiguration implements WebMvcConfigurer {
|
||||
*/
|
||||
private static final String[] EUREKA_PACKAGES = new String[] { "com.netflix.discovery", "com.netflix.eureka" };
|
||||
|
||||
/**
|
||||
* Static content pattern for dashboard elements (images, css, etc...).
|
||||
*/
|
||||
private static final String STATIC_CONTENT_PATTERN = "/(fonts|images|css|js)/.*";
|
||||
|
||||
@Autowired
|
||||
private ApplicationInfoManager applicationInfoManager;
|
||||
|
||||
@@ -139,6 +162,7 @@ public class EurekaServerAutoConfiguration implements WebMvcConfigurer {
|
||||
return codec == null ? CodecWrappers.getCodec(CodecWrappers.XStreamXml.class) : codec;
|
||||
}
|
||||
|
||||
// FIXME: 4.0
|
||||
@Bean
|
||||
@ConditionalOnMissingBean
|
||||
public ReplicationClientAdditionalFilters replicationClientAdditionalFilters() {
|
||||
@@ -146,10 +170,24 @@ public class EurekaServerAutoConfiguration implements WebMvcConfigurer {
|
||||
}
|
||||
|
||||
@Bean
|
||||
public PeerAwareInstanceRegistry peerAwareInstanceRegistry(ServerCodecs serverCodecs) {
|
||||
public Jersey3TransportClientFactories jersey3TransportClientFactories() {
|
||||
return Jersey3TransportClientFactories.getInstance();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public EurekaHttpClient eurekaHttpClient(TransportClientFactories transportClientFactories, Environment env) {
|
||||
return transportClientFactories
|
||||
.newTransportClientFactory(this.eurekaClientConfig, Collections.emptyList(),
|
||||
this.applicationInfoManager.getInfo())
|
||||
.newClient(HostnameBasedUrlRandomizer.randomEndpoint(this.eurekaClientConfig, env));
|
||||
}
|
||||
|
||||
@Bean
|
||||
public PeerAwareInstanceRegistry peerAwareInstanceRegistry(ServerCodecs serverCodecs,
|
||||
EurekaHttpClient eurekaHttpClient) {
|
||||
this.eurekaClient.getApplications(); // force initialization
|
||||
return new InstanceRegistry(this.eurekaServerConfig, this.eurekaClientConfig, serverCodecs, this.eurekaClient,
|
||||
this.instanceRegistryProperties.getExpectedNumberOfClientsSendingRenews(),
|
||||
eurekaHttpClient, this.instanceRegistryProperties.getExpectedNumberOfClientsSendingRenews(),
|
||||
this.instanceRegistryProperties.getDefaultOpenForTrafficCount());
|
||||
}
|
||||
|
||||
@@ -181,25 +219,71 @@ public class EurekaServerAutoConfiguration implements WebMvcConfigurer {
|
||||
* @param eurekaJerseyApp an {@link Application} for the filter to be registered
|
||||
* @return a jersey {@link FilterRegistrationBean}
|
||||
*/
|
||||
//@Bean
|
||||
//public FilterRegistrationBean<?> jerseyFilterRegistration(javax.ws.rs.core.Application eurekaJerseyApp) {
|
||||
// FilterRegistrationBean<Filter> bean = new FilterRegistrationBean<Filter>();
|
||||
// bean.setFilter(new ServletContainer(eurekaJerseyApp));
|
||||
// bean.setOrder(Ordered.LOWEST_PRECEDENCE);
|
||||
// bean.setUrlPatterns(Collections.singletonList(EurekaConstants.DEFAULT_PREFIX + "/*"));
|
||||
//
|
||||
// return bean;
|
||||
//}
|
||||
@Bean
|
||||
public FilterRegistrationBean<?> jerseyFilterRegistration(ResourceConfig eurekaJerseyApp) {
|
||||
FilterRegistrationBean<Filter> bean = new FilterRegistrationBean<>();
|
||||
ServletContainer servletContainer = new ServletContainer(eurekaJerseyApp);
|
||||
bean.setFilter(servletContainer);
|
||||
bean.setOrder(Ordered.LOWEST_PRECEDENCE);
|
||||
bean.setUrlPatterns(Collections.singletonList(EurekaConstants.DEFAULT_PREFIX + "/*"));
|
||||
|
||||
return bean;
|
||||
}
|
||||
|
||||
@Bean
|
||||
public FilterRegistrationBean<?> eurekaVersionFilterRegistration(ServerProperties serverProperties) {
|
||||
String contextPath = serverProperties.getServlet().getContextPath();
|
||||
String regex = EurekaConstants.DEFAULT_PREFIX + STATIC_CONTENT_PATTERN;
|
||||
if (StringUtils.hasText(contextPath)) {
|
||||
regex = contextPath + regex;
|
||||
}
|
||||
Pattern staticPattern = Pattern.compile(regex);
|
||||
FilterRegistrationBean<Filter> bean = new FilterRegistrationBean<>();
|
||||
bean.setFilter(new OncePerRequestFilter() {
|
||||
@Override
|
||||
protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response,
|
||||
FilterChain filterChain) throws ServletException, IOException {
|
||||
HttpServletRequest req = request;
|
||||
String requestURI = request.getRequestURI();
|
||||
if (!requestURI.startsWith(EurekaConstants.DEFAULT_PREFIX + "/v2")
|
||||
// don't forward static requests (images, js, etc...) to /v2
|
||||
&& !staticPattern.matcher(requestURI).matches()) {
|
||||
|
||||
String updatedPath = EurekaConstants.DEFAULT_PREFIX + "/v2"
|
||||
+ requestURI.substring(EurekaConstants.DEFAULT_PREFIX.length());
|
||||
|
||||
HttpServletRequestWrapper wrapper = new HttpServletRequestWrapper(request) {
|
||||
@Override
|
||||
public String getRequestURI() {
|
||||
return updatedPath;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getServletPath() {
|
||||
return updatedPath;
|
||||
}
|
||||
};
|
||||
req = wrapper;
|
||||
}
|
||||
filterChain.doFilter(req, response);
|
||||
}
|
||||
});
|
||||
bean.setOrder(0);
|
||||
bean.setUrlPatterns(Collections.singletonList(EurekaConstants.DEFAULT_PREFIX + "/*"));
|
||||
|
||||
return bean;
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct a Jersey {@link javax.ws.rs.core.Application} with all the resources
|
||||
* Construct a Jersey {@link jakarta.ws.rs.core.Application} with all the resources
|
||||
* required by the Eureka server.
|
||||
* @param environment an {@link Environment} instance to retrieve classpath resources
|
||||
* @param resourceLoader a {@link ResourceLoader} instance to get classloader from
|
||||
* @return created {@link Application} object
|
||||
*/
|
||||
@Bean
|
||||
public javax.ws.rs.core.Application jerseyApplication(Environment environment, ResourceLoader resourceLoader) {
|
||||
public ResourceConfig jerseyApplication(Environment environment, ResourceLoader resourceLoader,
|
||||
BeanFactory beanFactory) {
|
||||
|
||||
ClassPathScanningCandidateComponentProvider provider = new ClassPathScanningCandidateComponentProvider(false,
|
||||
environment);
|
||||
@@ -220,15 +304,32 @@ public class EurekaServerAutoConfiguration implements WebMvcConfigurer {
|
||||
}
|
||||
}
|
||||
|
||||
// Construct the Jersey ResourceConfig
|
||||
Map<String, Object> propsAndFeatures = new HashMap<>();
|
||||
propsAndFeatures.put(
|
||||
// Skip static content used by the webapp
|
||||
ServletContainer.PROPERTY_WEB_PAGE_CONTENT_REGEX,
|
||||
EurekaConstants.DEFAULT_PREFIX + "/(fonts|images|css|js)/.*");
|
||||
// https://javaee.github.io/hk2/spring-bridge
|
||||
|
||||
DefaultResourceConfig rc = new DefaultResourceConfig(classes);
|
||||
rc.setPropertiesAndFeatures(propsAndFeatures);
|
||||
// Construct the Jersey ResourceConfig
|
||||
ResourceConfig rc = new ResourceConfig(classes).property(
|
||||
// Skip static content used by the webapp
|
||||
ServletProperties.FILTER_STATIC_CONTENT_REGEX, EurekaConstants.DEFAULT_PREFIX + STATIC_CONTENT_PATTERN);
|
||||
|
||||
rc.register(new ContainerLifecycleListener() {
|
||||
@Override
|
||||
public void onStartup(Container container) {
|
||||
ServiceLocator serviceLocator = container.getApplicationHandler().getInjectionManager()
|
||||
.getInstance(ServiceLocator.class);
|
||||
SpringBridge.getSpringBridge().initializeSpringBridge(serviceLocator);
|
||||
serviceLocator.getService(SpringIntoHK2Bridge.class).bridgeSpringBeanFactory(beanFactory);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onReload(Container container) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onShutdown(Container container) {
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
return rc;
|
||||
}
|
||||
@@ -285,10 +386,11 @@ public class EurekaServerAutoConfiguration implements WebMvcConfigurer {
|
||||
|
||||
@Override
|
||||
protected PeerEurekaNode createPeerEurekaNode(String peerEurekaNodeUrl) {
|
||||
JerseyReplicationClient replicationClient = JerseyReplicationClient.createReplicationClient(serverConfig,
|
||||
Jersey3ReplicationClient replicationClient = Jersey3ReplicationClient.createReplicationClient(serverConfig,
|
||||
serverCodecs, peerEurekaNodeUrl);
|
||||
|
||||
this.replicationClientAdditionalFilters.getFilters().forEach(replicationClient::addReplicationClientFilter);
|
||||
// FIXME: 4.0
|
||||
// this.replicationClientAdditionalFilters.getFilters().forEach(replicationClient::addReplicationClientFilter);
|
||||
|
||||
String targetHost = hostFromUrl(peerEurekaNodeUrl);
|
||||
if (targetHost == null) {
|
||||
|
||||
+4
-2
@@ -21,6 +21,7 @@ import com.netflix.appinfo.InstanceInfo;
|
||||
import com.netflix.discovery.EurekaClient;
|
||||
import com.netflix.discovery.EurekaClientConfig;
|
||||
import com.netflix.discovery.shared.Application;
|
||||
import com.netflix.discovery.shared.transport.EurekaHttpClient;
|
||||
import com.netflix.eureka.EurekaServerConfig;
|
||||
import com.netflix.eureka.lease.Lease;
|
||||
import com.netflix.eureka.registry.PeerAwareInstanceRegistryImpl;
|
||||
@@ -48,8 +49,9 @@ public class InstanceRegistry extends PeerAwareInstanceRegistryImpl implements A
|
||||
private int defaultOpenForTrafficCount;
|
||||
|
||||
public InstanceRegistry(EurekaServerConfig serverConfig, EurekaClientConfig clientConfig, ServerCodecs serverCodecs,
|
||||
EurekaClient eurekaClient, int expectedNumberOfClientsSendingRenews, int defaultOpenForTrafficCount) {
|
||||
super(serverConfig, clientConfig, serverCodecs, eurekaClient);
|
||||
EurekaClient eurekaClient, EurekaHttpClient eurekaHttpClient, int expectedNumberOfClientsSendingRenews,
|
||||
int defaultOpenForTrafficCount) {
|
||||
super(serverConfig, clientConfig, serverCodecs, eurekaClient, eurekaHttpClient);
|
||||
|
||||
this.expectedNumberOfClientsSendingRenews = expectedNumberOfClientsSendingRenews;
|
||||
this.defaultOpenForTrafficCount = defaultOpenForTrafficCount;
|
||||
|
||||
+5
-4
@@ -19,20 +19,21 @@ package org.springframework.cloud.netflix.eureka.server;
|
||||
import java.util.Collection;
|
||||
import java.util.LinkedHashSet;
|
||||
|
||||
import com.sun.jersey.api.client.filter.ClientFilter;
|
||||
// FIXME: 4.0
|
||||
//import com.sun.jersey.api.client.filter.ClientFilter;
|
||||
|
||||
/**
|
||||
* @author Yuxin Bai
|
||||
*/
|
||||
public class ReplicationClientAdditionalFilters {
|
||||
|
||||
private Collection<ClientFilter> filters;
|
||||
private Collection<?> filters;
|
||||
|
||||
public ReplicationClientAdditionalFilters(Collection<ClientFilter> filters) {
|
||||
public ReplicationClientAdditionalFilters(Collection<?> filters) {
|
||||
this.filters = new LinkedHashSet<>(filters);
|
||||
}
|
||||
|
||||
public Collection<ClientFilter> getFilters() {
|
||||
public Collection<?> getFilters() {
|
||||
return this.filters;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,2 +0,0 @@
|
||||
org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
|
||||
org.springframework.cloud.netflix.eureka.server.EurekaServerAutoConfiguration
|
||||
+1
@@ -0,0 +1 @@
|
||||
org.springframework.cloud.netflix.eureka.server.EurekaServerAutoConfiguration
|
||||
+2
@@ -22,6 +22,7 @@ import java.util.Map;
|
||||
import com.netflix.appinfo.InstanceInfo;
|
||||
import com.netflix.discovery.converters.wrappers.CodecWrapper;
|
||||
import com.netflix.eureka.resources.ServerCodecs;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -85,6 +86,7 @@ class ApplicationTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Disabled // FIXME 4.0
|
||||
void cssParsedByLess() {
|
||||
String basePath = "http://localhost:" + this.port + "/eureka/css/wro.css";
|
||||
ResponseEntity<String> entity = new TestRestTemplate().getForEntity(basePath, String.class);
|
||||
|
||||
+7
@@ -19,10 +19,12 @@ package org.springframework.cloud.netflix.eureka.server;
|
||||
import com.netflix.appinfo.ApplicationInfoManager;
|
||||
import com.netflix.discovery.EurekaClientConfig;
|
||||
import com.netflix.eureka.EurekaServerConfig;
|
||||
import com.netflix.eureka.cluster.PeerEurekaNode;
|
||||
import com.netflix.eureka.cluster.PeerEurekaNodes;
|
||||
import com.netflix.eureka.registry.PeerAwareInstanceRegistry;
|
||||
import com.netflix.eureka.resources.ServerCodecs;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.mockito.Mockito;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
||||
@@ -69,6 +71,11 @@ class EurekaCustomPeerNodesTests {
|
||||
super(registry, serverConfig, clientConfig, serverCodecs, applicationInfoManager);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected PeerEurekaNode createPeerEurekaNode(String peerEurekaNodeUrl) {
|
||||
return Mockito.mock(PeerEurekaNode.class);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+22
-23
@@ -17,20 +17,15 @@
|
||||
package org.springframework.cloud.netflix.eureka.server;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.Collections;
|
||||
|
||||
import com.netflix.eureka.cluster.PeerEurekaNodes;
|
||||
import com.sun.jersey.api.client.ClientHandlerException;
|
||||
import com.sun.jersey.api.client.ClientRequest;
|
||||
import com.sun.jersey.api.client.ClientResponse;
|
||||
import com.sun.jersey.api.client.filter.ClientFilter;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.cloud.netflix.eureka.server.EurekaServerAutoConfiguration.RefreshablePeerEurekaNodes;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.util.ReflectionUtils;
|
||||
|
||||
@@ -39,6 +34,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
/**
|
||||
* @author Yuxin Bai
|
||||
*/
|
||||
@Disabled // FIXME: 4.0
|
||||
@SpringBootTest(classes = RefreshablePeerEurekaNodesWithCustomFiltersTests.Application.class,
|
||||
webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, value = { "spring.application.name=eureka",
|
||||
"server.contextPath=/context", "management.security.enabled=false" })
|
||||
@@ -54,10 +50,13 @@ class RefreshablePeerEurekaNodesWithCustomFiltersTests {
|
||||
|
||||
ReplicationClientAdditionalFilters filters = getField(RefreshablePeerEurekaNodes.class,
|
||||
(RefreshablePeerEurekaNodes) peerEurekaNodes, "replicationClientAdditionalFilters");
|
||||
assertThat(filters.getFilters())
|
||||
.as("PeerEurekaNodes'should have only one filter set on replicationClientAdditionalFilters").hasSize(1);
|
||||
assertThat(filters.getFilters().iterator().next() instanceof Application.CustomClientFilter)
|
||||
.as("The type of the filter should be CustomClientFilter as user declared so").isTrue();
|
||||
// assertThat(filters.getFilters())
|
||||
// .as("PeerEurekaNodes'should have only one filter set on
|
||||
// replicationClientAdditionalFilters").hasSize(1);
|
||||
// assertThat(filters.getFilters().iterator().next() instanceof
|
||||
// Application.CustomClientFilter)
|
||||
// .as("The type of the filter should be CustomClientFilter as user declared
|
||||
// so").isTrue();
|
||||
}
|
||||
|
||||
private static <T, R> R getField(Class<T> clazz, T target, String fieldName) {
|
||||
@@ -73,19 +72,19 @@ class RefreshablePeerEurekaNodesWithCustomFiltersTests {
|
||||
@EnableEurekaServer
|
||||
protected static class Application {
|
||||
|
||||
@Bean
|
||||
public ReplicationClientAdditionalFilters customFilters() {
|
||||
return new ReplicationClientAdditionalFilters(Collections.singletonList(new CustomClientFilter()));
|
||||
}
|
||||
|
||||
protected class CustomClientFilter extends ClientFilter {
|
||||
|
||||
@Override
|
||||
public ClientResponse handle(ClientRequest cr) throws ClientHandlerException {
|
||||
return getNext().handle(cr);
|
||||
}
|
||||
|
||||
}
|
||||
// FIXME: 4.0
|
||||
/*
|
||||
* @Bean public ReplicationClientAdditionalFilters customFilters() { return new
|
||||
* ReplicationClientAdditionalFilters(Collections.singletonList(new
|
||||
* CustomClientFilter())); }
|
||||
*
|
||||
* protected class CustomClientFilter extends ClientFilter {
|
||||
*
|
||||
* @Override public ClientResponse handle(ClientRequest cr) throws
|
||||
* ClientHandlerException { return getNext().handle(cr); }
|
||||
*
|
||||
* }
|
||||
*/
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user