Compare commits

...
Author SHA1 Message Date
Olga Maciaszek-Sharma 19ff14cafd Merge remote-tracking branch 'origin/main' into add-hc-requestconfig-customizer 2025-01-16 14:55:26 +01:00
Olga Maciaszek-Sharma bd38ceb02e Try fixing flaky test.
Signed-off-by: Olga Maciaszek-Sharma <olga.maciaszek-sharma@broadcom.com>
2025-01-16 14:54:20 +01:00
Olga Maciaszek-Sharma b44c088251 Add example snippet to doc. Add author tag to javadoc.
Signed-off-by: Olga Maciaszek-Sharma <olga.maciaszek-sharma@broadcom.com>
2025-01-16 14:47:19 +01:00
Olga Maciaszek-SharmaandMax Brauer 14366cc478 Update docs/modules/ROOT/pages/spring-cloud-netflix.adoc
Co-authored-by: Max Brauer <mamachanko@users.noreply.github.com>
Signed-off-by: Olga Maciaszek-Sharma <olga.maciaszek-sharma@broadcom.com>
2025-01-16 14:47:02 +01:00
Olga Maciaszek-Sharma c77feb065b Add docs and javadocs.
Signed-off-by: Olga Maciaszek-Sharma <olga.maciaszek-sharma@broadcom.com>
2025-01-16 14:46:50 +01:00
Olga Maciaszek-Sharma a13db33b28 Move away from ObjectProvider. Add test.
Signed-off-by: Olga Maciaszek-Sharma <olga.maciaszek-sharma@broadcom.com>
2025-01-16 14:46:39 +01:00
Olga Maciaszek-Sharma f6c6720c5a Use customiserw while creating EurekaClientHttpRequestFactorySupplier beans. Add tests.
Signed-off-by: Olga Maciaszek-Sharma <olga.maciaszek-sharma@broadcom.com>
2025-01-16 14:46:20 +01:00
Olga Maciaszek-Sharma 8e3a33de29 Add possibility to customise HC5 RequestConfig.
Signed-off-by: Olga Maciaszek-Sharma <olga.maciaszek-sharma@broadcom.com>
2025-01-16 14:45:59 +01:00
Ryan Baxter 21cac3fa40 Merge branch '4.1.x' 2024-12-17 10:38:28 -05:00
Ryan Baxter c9cff6faf0 Add the ability to disable configuration properties in docs pom 2024-12-17 10:33:08 -05:00
spring-builds 96be7ab777 Bumping versions 2024-12-12 11:56:03 +00:00
spring-builds 623500f6d5 Bumping versions 2024-12-12 05:33:54 +00:00
Olga Maciaszek-Sharma 609b85e6ab Merge remote-tracking branch 'origin/4.1.x'
# Conflicts:
#	docs/pom.xml
#	pom.xml
#	spring-cloud-netflix-dependencies/pom.xml
#	spring-cloud-netflix-eureka-client-tls-tests/pom.xml
#	spring-cloud-netflix-eureka-client/pom.xml
#	spring-cloud-netflix-eureka-server/pom.xml
#	spring-cloud-netflix-eureka-server/src/test/java/org/springframework/cloud/netflix/eureka/server/EurekaInstanceMonitorTests.java
#	spring-cloud-netflix-eureka-server/src/test/java/org/springframework/cloud/netflix/eureka/server/EurekaInstanceMonitorWithCustomTagsProviderTests.java
#	spring-cloud-starter-netflix-eureka-client/pom.xml
#	spring-cloud-starter-netflix-eureka-server/pom.xml
2024-12-11 14:22:56 +01:00
Olga Maciaszek-Sharma 883ec871ab Adjust awaitility config. 2024-12-11 14:19:27 +01:00
Olga Maciaszek-Sharma 3861aeda64 Merge remote-tracking branch 'origin/main' 2024-12-11 14:15:56 +01:00
Olga Maciaszek-Sharma ba8b74c7f6 Adjust awaitility config. 2024-12-11 14:15:44 +01:00
dependabot[bot] 76e6104b4b Bump @antora/collector-extension from 1.0.0-beta.5 to 1.0.1 in /docs (#4385)
---
updated-dependencies:
- dependency-name: "@antora/collector-extension"
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-12-11 14:04:31 +01:00
dependabot[bot] 806dc0b809 Bump @antora/collector-extension from 1.0.0-rc.1 to 1.0.1 in /docs (#4383)
---
updated-dependencies:
- dependency-name: "@antora/collector-extension"
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-12-11 13:23:43 +01:00
dependabot[bot] 00fa8e0f52 Bump antora from 3.2.0-alpha.6 to 3.2.0-alpha.8 in /docs (#4388)
Bumps [antora](https://gitlab.com/antora/antora) from 3.2.0-alpha.6 to 3.2.0-alpha.8.
- [Changelog](https://gitlab.com/antora/antora/blob/main/CHANGELOG.adoc)
- [Commits](https://gitlab.com/antora/antora/compare/v3.2.0-alpha.6...v3.2.0-alpha.8)

---
updated-dependencies:
- dependency-name: antora
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-12-11 13:23:20 +01:00
dependabot[bot] f8e7c12328 Bump antora from 3.2.0-alpha.6 to 3.2.0-alpha.8 in /docs (#4390)
Bumps [antora](https://gitlab.com/antora/antora) from 3.2.0-alpha.6 to 3.2.0-alpha.8.
- [Changelog](https://gitlab.com/antora/antora/blob/main/CHANGELOG.adoc)
- [Commits](https://gitlab.com/antora/antora/compare/v3.2.0-alpha.6...v3.2.0-alpha.8)

---
updated-dependencies:
- dependency-name: antora
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-12-11 11:57:59 +01:00
spring-builds b06b50d055 Bumping versions 2024-12-06 16:13:28 +00:00
Olga Maciaszek-Sharma 18b0f85013 Change timeouts. 2024-12-06 16:59:47 +01:00
Olga Maciaszek-Sharma 0298ab0d86 Increase test timeout. 2024-12-06 12:47:41 +01:00
spring-builds 9113ddb5df Bumping dependency versions after release 2024-12-03 01:15:14 +00:00
spring-builds a3888075da Bumping versions to 4.2.1-SNAPSHOT after release 2024-12-03 01:14:27 +00:00
spring-builds da56d7d5e6 Going back to snapshots 2024-12-03 01:14:26 +00:00
Olga Maciaszek-Sharma e4ab5faafd Revert "Update pom.xml"
This reverts commit 1dd38faa4a.
2024-11-27 18:01:22 +01:00
Olga Maciaszek-Sharma 5af3121835 Merge remote-tracking branch 'origin/4.1.x' into 4.1.x 2024-11-27 18:01:01 +01:00
spring-builds 950553d9a1 Going back to snapshots 2024-11-27 01:44:48 +00:00
spring-builds 6267dfc577 Update SNAPSHOT to 4.1.4 2024-11-27 01:44:00 +00:00
spring-builds fe44b40dc4 Bumping dependency versions after release 2024-11-26 16:43:23 +00:00
spring-builds d005cab913 Bumping versions to 4.1.5-SNAPSHOT after release 2024-11-26 16:42:34 +00:00
spring-builds 9cf585c119 Going back to snapshots 2024-11-26 16:42:33 +00:00
spring-builds 6f38cfe510 Update SNAPSHOT to 4.1.4 2024-11-26 16:41:50 +00:00
Oleg Zhurakousky 1dd38faa4a Update pom.xml 2024-11-26 17:07:48 +01:00
spring-builds 4236eb2af3 Bumping versions 2024-11-25 16:10:35 +00:00
Olga Maciaszek-Sharma 96c7ec7072 Increase timeout. 2024-11-25 16:59:21 +01:00
Olga Maciaszek-Sharma b9740eb452 Fix test. 2024-11-25 16:19:32 +01:00
Olga Maciaszek-Sharma a96375bd12 Remove comment. 2024-11-25 14:46:25 +01:00
Olga Maciaszek-Sharma 6f35b0e9f5 Aggregate instance info with Executor. Fixes gh-4374. 2024-11-25 14:41:10 +01:00
Olga Maciaszek-Sharma c25dc8fd77 Temporarily disable test. 2024-11-25 13:38:21 +01:00
Olga Maciaszek-Sharma 3c093dcc04 Change timeouts in flaky tests. 2024-11-25 12:47:34 +01:00
Olga Maciaszek-Sharma 803abe6e6f Merge remote-tracking branch 'origin/4.1.x' into 4.1.x 2024-10-09 18:11:43 +02:00
Olga Maciaszek-Sharma fb7abbdead Fix test setup. 2024-10-04 17:27:30 +02:00
23 changed files with 183 additions and 70 deletions
+1 -1
View File
@@ -6,7 +6,7 @@ nav:
ext:
collector:
run:
command: ./mvnw --no-transfer-progress -B process-resources -Pdocs -pl docs -Dantora-maven-plugin.phase=none -Dgenerate-docs.phase=none -Dgenerate-readme.phase=none -Dgenerate-cloud-resources.phase=none -Dmaven-dependency-plugin-for-docs.phase=none -Dmaven-dependency-plugin-for-docs-classes.phase=none -DskipTests
command: ./mvnw --no-transfer-progress -B process-resources -Pdocs -pl docs -Dantora-maven-plugin.phase=none -Dgenerate-docs.phase=none -Dgenerate-readme.phase=none -Dgenerate-cloud-resources.phase=none -Dmaven-dependency-plugin-for-docs.phase=none -Dmaven-dependency-plugin-for-docs-classes.phase=none -DskipTests -DdisableConfigurationProperties
local: true
scan:
dir: ./target/classes/antora-resources/
@@ -116,6 +116,21 @@ eureka:
socket-timeout: 10000
----
You can also customise the `RequestConfig` for the underlying Apache HttpClient 5 by creating a bean of type `EurekaClientHttpRequestFactorySupplier.RequestConfigCustomizer`:
[source,java,indent=0]
----
@Configuration
public class RestClientConfiguration {
@Bean
EurekaClientHttpRequestFactorySupplier.RequestConfigCustomizer requestConfigCustomizer() {
return builder -> builder.setProtocolUpgradeEnabled(false);
}
}
----
=== Status Page and Health Indicator
The status page and health indicators for a Eureka instance default to `/info` and `/health` respectively, which are the default locations of useful endpoints in a Spring Boot Actuator application.
+2 -2
View File
@@ -1,8 +1,8 @@
{
"dependencies": {
"antora": "3.2.0-alpha.6",
"antora": "3.2.0-alpha.8",
"@antora/atlas-extension": "1.0.0-alpha.2",
"@antora/collector-extension": "1.0.0-rc.1",
"@antora/collector-extension": "1.0.1",
"@asciidoctor/tabs": "1.0.0-beta.6",
"@springio/antora-extensions": "1.14.2",
"@springio/asciidoctor-extensions": "1.0.0-alpha.14"
+19 -11
View File
@@ -8,7 +8,7 @@
<parent>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-netflix</artifactId>
<version>4.2.0</version>
<version>4.2.1-SNAPSHOT</version>
<relativePath>..</relativePath>
</parent>
<packaging>jar</packaging>
@@ -21,20 +21,28 @@
<!-- Don't upload docs jar to central / repo.spring.io -->
<maven-deploy-plugin-default.phase>none</maven-deploy-plugin-default.phase>
</properties>
<!-- <dependencies>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-server</artifactId>
</dependency>
</dependencies> -->
<build>
<sourceDirectory>src/main/asciidoc</sourceDirectory>
</build>
<profiles>
<profile>
<id>enable-configuration-properties</id>
<activation>
<property>
<name>!disableConfigurationProperties</name>
</property>
</activation>
<dependencies>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-server</artifactId>
</dependency>
</dependencies>
</profile>
<profile>
<id>docs</id>
<build>
+4 -4
View File
@@ -3,14 +3,14 @@
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>
<artifactId>spring-cloud-netflix</artifactId>
<version>4.2.0</version>
<version>4.2.1-SNAPSHOT</version>
<packaging>pom</packaging>
<name>Spring Cloud Netflix</name>
<description>Spring Cloud Netflix</description>
<parent>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-build</artifactId>
<version>4.2.0</version>
<version>4.2.1-SNAPSHOT</version>
<relativePath />
</parent>
<scm>
@@ -21,8 +21,8 @@
</scm>
<properties>
<bintray.package>netflix</bintray.package>
<spring-cloud-commons.version>4.2.0</spring-cloud-commons.version>
<spring-cloud-config.version>4.2.0</spring-cloud-config.version>
<spring-cloud-commons.version>4.2.1-SNAPSHOT</spring-cloud-commons.version>
<spring-cloud-config.version>4.2.1-SNAPSHOT</spring-cloud-config.version>
<testcontainers.version>1.20.4</testcontainers.version>
<mockserverclient.version>5.15.0</mockserverclient.version>
+2 -2
View File
@@ -5,11 +5,11 @@
<parent>
<artifactId>spring-cloud-dependencies-parent</artifactId>
<groupId>org.springframework.cloud</groupId>
<version>4.2.0</version>
<version>4.2.1-SNAPSHOT</version>
<relativePath/>
</parent>
<artifactId>spring-cloud-netflix-dependencies</artifactId>
<version>4.2.0</version>
<version>4.2.1-SNAPSHOT</version>
<packaging>pom</packaging>
<name>spring-cloud-netflix-dependencies</name>
<description>Spring Cloud Netflix Dependencies</description>
@@ -5,7 +5,7 @@
<parent>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-netflix</artifactId>
<version>4.2.0</version>
<version>4.2.1-SNAPSHOT</version>
<relativePath>..</relativePath> <!-- lookup parent from repository -->
</parent>
<artifactId>spring-cloud-netflix-eureka-client-tls-tests</artifactId>
@@ -1,5 +1,5 @@
/*
* Copyright 2018-2024 the original author or authors.
* Copyright 2018-2025 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.
@@ -16,6 +16,8 @@
package org.springframework.cloud.netflix.eureka;
import java.util.Collections;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.junit.jupiter.api.BeforeAll;
@@ -64,8 +66,8 @@ public class EurekaClientTests extends BaseCertTests {
@Bean
public RestTemplateDiscoveryClientOptionalArgs discoveryClientOptionalArgs() {
return new RestTemplateDiscoveryClientOptionalArgs(
new DefaultEurekaClientHttpRequestFactorySupplier(new RestTemplateTimeoutProperties()), null);
return new RestTemplateDiscoveryClientOptionalArgs(new DefaultEurekaClientHttpRequestFactorySupplier(
new RestTemplateTimeoutProperties(), Collections.emptySet()));
}
}
+1 -1
View File
@@ -6,7 +6,7 @@
<parent>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-netflix</artifactId>
<version>4.2.0</version>
<version>4.2.1-SNAPSHOT</version>
<relativePath>..</relativePath> <!-- lookup parent from repository -->
</parent>
<artifactId>spring-cloud-netflix-eureka-client</artifactId>
@@ -1,5 +1,5 @@
/*
* Copyright 2017-2024 the original author or authors.
* Copyright 2017-2025 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.
@@ -18,6 +18,7 @@ package org.springframework.cloud.netflix.eureka.config;
import java.io.IOException;
import java.security.GeneralSecurityException;
import java.util.Set;
import com.netflix.discovery.AbstractDiscoveryClientOptionalArgs;
import com.netflix.discovery.shared.transport.jersey.TransportClientFactories;
@@ -94,8 +95,10 @@ public class DiscoveryClientOptionalArgsConfiguration {
@Bean
@ConditionalOnMissingBean
EurekaClientHttpRequestFactorySupplier defaultEurekaClientHttpRequestFactorySupplier(
RestTemplateTimeoutProperties restTemplateTimeoutProperties) {
return new DefaultEurekaClientHttpRequestFactorySupplier(restTemplateTimeoutProperties);
RestTemplateTimeoutProperties restTemplateTimeoutProperties,
Set<EurekaClientHttpRequestFactorySupplier.RequestConfigCustomizer> requestConfigCustomizers) {
return new DefaultEurekaClientHttpRequestFactorySupplier(restTemplateTimeoutProperties,
requestConfigCustomizers);
}
@Bean
@@ -189,8 +192,10 @@ public class DiscoveryClientOptionalArgsConfiguration {
@Bean
@ConditionalOnMissingBean
EurekaClientHttpRequestFactorySupplier defaultEurekaClientHttpRequestFactorySupplier(
RestClientTimeoutProperties restClientTimeoutProperties) {
return new DefaultEurekaClientHttpRequestFactorySupplier(restClientTimeoutProperties);
RestClientTimeoutProperties restClientTimeoutProperties,
Set<EurekaClientHttpRequestFactorySupplier.RequestConfigCustomizer> requestConfigCustomizers) {
return new DefaultEurekaClientHttpRequestFactorySupplier(restClientTimeoutProperties,
requestConfigCustomizers);
}
@Bean
@@ -1,5 +1,5 @@
/*
* Copyright 2013-2024 the original author or authors.
* Copyright 2013-2025 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.
@@ -16,6 +16,8 @@
package org.springframework.cloud.netflix.eureka.config;
import java.util.Set;
import com.netflix.discovery.EurekaClientConfig;
import com.netflix.discovery.shared.transport.EurekaHttpClient;
@@ -54,7 +56,7 @@ import org.springframework.web.client.RestTemplate;
import org.springframework.web.reactive.function.client.WebClient;
/**
* Bootstrap configuration for config client that wants to lookup the config server via
* Bootstrap configuration for config client that wants to look the config server up via
* discovery.
*
* @author Dave Syer
@@ -103,8 +105,10 @@ public class EurekaConfigServerBootstrapConfiguration {
@Bean
@ConditionalOnMissingBean
EurekaClientHttpRequestFactorySupplier defaultEurekaClientHttpRequestFactorySupplier(
RestTemplateTimeoutProperties restTemplateTimeoutProperties) {
return new DefaultEurekaClientHttpRequestFactorySupplier(restTemplateTimeoutProperties);
RestTemplateTimeoutProperties restTemplateTimeoutProperties,
Set<EurekaClientHttpRequestFactorySupplier.RequestConfigCustomizer> requestConfigCustomizers) {
return new DefaultEurekaClientHttpRequestFactorySupplier(restTemplateTimeoutProperties,
requestConfigCustomizers);
}
/**
@@ -174,8 +178,10 @@ public class EurekaConfigServerBootstrapConfiguration {
@Bean
@ConditionalOnMissingBean
EurekaClientHttpRequestFactorySupplier defaultEurekaClientHttpRequestFactorySupplier(
RestClientTimeoutProperties restClientTimeoutProperties) {
return new DefaultEurekaClientHttpRequestFactorySupplier(restClientTimeoutProperties);
RestClientTimeoutProperties restClientTimeoutProperties,
Set<EurekaClientHttpRequestFactorySupplier.RequestConfigCustomizer> requestConfigCustomizers) {
return new DefaultEurekaClientHttpRequestFactorySupplier(restClientTimeoutProperties,
requestConfigCustomizers);
}
static class OnRestClientPresentAndEnabledCondition extends AllNestedConditions {
@@ -1,5 +1,5 @@
/*
* Copyright 2013-2024 the original author or authors.
* Copyright 2013-2025 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.
@@ -61,7 +61,8 @@ public class EurekaConfigServerBootstrapper implements BootstrapRegistryInitiali
EurekaHttpClient httpClient = new RestClientTransportClientFactory(
context.getOrElse(TlsProperties.class, null),
context.getOrElse(EurekaClientHttpRequestFactorySupplier.class,
new DefaultEurekaClientHttpRequestFactorySupplier(new RestClientTimeoutProperties())))
new DefaultEurekaClientHttpRequestFactorySupplier(new RestClientTimeoutProperties(),
Collections.emptySet())))
.newClient(HostnameBasedUrlRandomizer.randomEndpoint(config, getPropertyResolver(context)));
return new EurekaConfigServerInstanceProvider(httpClient, config)::getInstances;
});
@@ -1,5 +1,5 @@
/*
* Copyright 2013-2024 the original author or authors.
* Copyright 2013-2025 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.
@@ -16,11 +16,14 @@
package org.springframework.cloud.netflix.eureka.http;
import java.util.Collections;
import java.util.Set;
import java.util.concurrent.TimeUnit;
import javax.net.ssl.HostnameVerifier;
import javax.net.ssl.SSLContext;
import org.apache.hc.client5.http.config.ConnectionConfig;
import org.apache.hc.client5.http.config.RequestConfig;
import org.apache.hc.client5.http.impl.classic.CloseableHttpClient;
import org.apache.hc.client5.http.impl.classic.HttpClientBuilder;
@@ -50,9 +53,12 @@ public class DefaultEurekaClientHttpRequestFactorySupplier implements EurekaClie
private final TimeoutProperties timeoutProperties;
// TODO: switch to final after removing deprecated interfaces
private Set<RequestConfigCustomizer> requestConfigCustomizers = Collections.emptySet();
/**
* @deprecated in favour of
* {@link DefaultEurekaClientHttpRequestFactorySupplier#DefaultEurekaClientHttpRequestFactorySupplier(TimeoutProperties)}
* {@link DefaultEurekaClientHttpRequestFactorySupplier#DefaultEurekaClientHttpRequestFactorySupplier(TimeoutProperties, Set)}
*/
@Deprecated(forRemoval = true)
public DefaultEurekaClientHttpRequestFactorySupplier() {
@@ -61,17 +67,28 @@ public class DefaultEurekaClientHttpRequestFactorySupplier implements EurekaClie
/**
* @deprecated in favour of
* {@link DefaultEurekaClientHttpRequestFactorySupplier#DefaultEurekaClientHttpRequestFactorySupplier(TimeoutProperties)}
* {@link DefaultEurekaClientHttpRequestFactorySupplier#DefaultEurekaClientHttpRequestFactorySupplier(TimeoutProperties, Set)}
*/
@Deprecated(forRemoval = true)
public DefaultEurekaClientHttpRequestFactorySupplier(RestTemplateTimeoutProperties timeoutProperties) {
this.timeoutProperties = timeoutProperties;
}
/**
* @deprecated in favour of
* {@link DefaultEurekaClientHttpRequestFactorySupplier#DefaultEurekaClientHttpRequestFactorySupplier(TimeoutProperties, Set)}
*/
@Deprecated(forRemoval = true)
public DefaultEurekaClientHttpRequestFactorySupplier(TimeoutProperties timeoutProperties) {
this.timeoutProperties = timeoutProperties;
}
public DefaultEurekaClientHttpRequestFactorySupplier(TimeoutProperties timeoutProperties,
Set<RequestConfigCustomizer> requestConfigCustomizers) {
this.timeoutProperties = timeoutProperties;
this.requestConfigCustomizers = requestConfigCustomizers;
}
@Override
public ClientHttpRequestFactory get(SSLContext sslContext, @Nullable HostnameVerifier hostnameVerifier) {
HttpClientBuilder httpClientBuilder = HttpClientBuilder.create();
@@ -79,9 +96,7 @@ public class DefaultEurekaClientHttpRequestFactorySupplier implements EurekaClie
httpClientBuilder
.setConnectionManager(buildConnectionManager(sslContext, hostnameVerifier, timeoutProperties));
}
if (timeoutProperties != null) {
httpClientBuilder.setDefaultRequestConfig(buildRequestConfig());
}
httpClientBuilder.setDefaultRequestConfig(buildRequestConfig());
CloseableHttpClient httpClient = httpClientBuilder.build();
HttpComponentsClientHttpRequestFactory requestFactory = new HttpComponentsClientHttpRequestFactory();
@@ -90,7 +105,7 @@ public class DefaultEurekaClientHttpRequestFactorySupplier implements EurekaClie
}
private HttpClientConnectionManager buildConnectionManager(SSLContext sslContext, HostnameVerifier hostnameVerifier,
TimeoutProperties restTemplateTimeoutProperties) {
TimeoutProperties timeoutProperties) {
PoolingHttpClientConnectionManagerBuilder connectionManagerBuilder = PoolingHttpClientConnectionManagerBuilder
.create();
SSLConnectionSocketFactoryBuilder sslConnectionSocketFactoryBuilder = SSLConnectionSocketFactoryBuilder
@@ -102,20 +117,25 @@ public class DefaultEurekaClientHttpRequestFactorySupplier implements EurekaClie
sslConnectionSocketFactoryBuilder.setHostnameVerifier(hostnameVerifier);
}
connectionManagerBuilder.setSSLSocketFactory(sslConnectionSocketFactoryBuilder.build());
if (restTemplateTimeoutProperties != null) {
if (timeoutProperties != null) {
connectionManagerBuilder.setDefaultSocketConfig(SocketConfig.custom()
.setSoTimeout(Timeout.of(restTemplateTimeoutProperties.getSocketTimeout(), TimeUnit.MILLISECONDS))
.setSoTimeout(Timeout.of(timeoutProperties.getSocketTimeout(), TimeUnit.MILLISECONDS))
.build());
connectionManagerBuilder.setDefaultConnectionConfig(ConnectionConfig.custom()
.setConnectTimeout(Timeout.of(timeoutProperties.getConnectTimeout(), TimeUnit.MILLISECONDS))
.build());
}
return connectionManagerBuilder.build();
}
private RequestConfig buildRequestConfig() {
return RequestConfig.custom()
.setConnectTimeout(Timeout.of(timeoutProperties.getConnectTimeout(), TimeUnit.MILLISECONDS))
.setConnectionRequestTimeout(
Timeout.of(timeoutProperties.getConnectRequestTimeout(), TimeUnit.MILLISECONDS))
.build();
RequestConfig.Builder requestConfigBuilder = RequestConfig.custom();
if (timeoutProperties != null) {
requestConfigBuilder.setConnectionRequestTimeout(
Timeout.of(timeoutProperties.getConnectRequestTimeout(), TimeUnit.MILLISECONDS));
}
requestConfigCustomizers.forEach(customizer -> customizer.customize(requestConfigBuilder));
return requestConfigBuilder.build();
}
}
@@ -1,5 +1,5 @@
/*
* Copyright 2013-2022 the original author or authors.
* Copyright 2013-2025 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.
@@ -19,6 +19,8 @@ package org.springframework.cloud.netflix.eureka.http;
import javax.net.ssl.HostnameVerifier;
import javax.net.ssl.SSLContext;
import org.apache.hc.client5.http.config.RequestConfig;
import org.springframework.http.client.ClientHttpRequestFactory;
import org.springframework.lang.Nullable;
@@ -38,4 +40,17 @@ public interface EurekaClientHttpRequestFactorySupplier {
*/
ClientHttpRequestFactory get(SSLContext sslContext, @Nullable HostnameVerifier hostnameVerifier);
/**
* Allows customising the {@link RequestConfig} of the underlying Apache HC5 instance.
*
* @author Olga Maciaszek-Sharma
* @since 4.2.1
*/
@FunctionalInterface
interface RequestConfigCustomizer {
void customize(RequestConfig.Builder builder);
}
}
@@ -1,5 +1,5 @@
/*
* Copyright 2017-2022 the original author or authors.
* Copyright 2017-2025 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.
@@ -31,6 +31,7 @@ import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.Ordered;
import org.springframework.core.annotation.Order;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
@@ -45,6 +46,7 @@ import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseStatus;
@@ -59,6 +61,7 @@ import static org.springframework.util.Assert.isTrue;
*
* @author Daniel Lavoie
* @author Wonchul Heo
* @author Olga Maciaszek-Sharma
*/
@Configuration(proxyBeanMethods = false)
@RestController
@@ -172,7 +175,11 @@ public class EurekaServerMockApplication {
}
@GetMapping("/apps/{appName}")
public Application getApplication(@PathVariable String appName) {
public Application getApplication(@PathVariable String appName, @RequestHeader HttpHeaders headers) {
// Used to verify that RequestConfig customizer has taken effect
if (appName.equals("upgrade") && !headers.containsKey("upgrade")) {
throw new RuntimeException("No upgrade header found");
}
return new Application();
}
@@ -1,5 +1,5 @@
/*
* Copyright 2017-2024 the original author or authors.
* Copyright 2017-2025 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.
@@ -16,11 +16,15 @@
package org.springframework.cloud.netflix.eureka.http;
import java.util.Collections;
import java.util.Optional;
import java.util.Set;
import com.netflix.appinfo.providers.EurekaConfigBasedInstanceInfoProvider;
import com.netflix.discovery.shared.resolver.DefaultEndpoint;
import com.netflix.discovery.shared.transport.EurekaHttpClient;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
@@ -32,6 +36,8 @@ import org.springframework.cloud.netflix.eureka.RestClientTimeoutProperties;
import org.springframework.test.annotation.DirtiesContext;
import org.springframework.web.client.RestClient;
import static org.assertj.core.api.AssertionsForClassTypes.assertThatExceptionOfType;
/**
* Tests for {@link RestClientEurekaHttpClient}.
*
@@ -53,13 +59,9 @@ class RestClientEurekaHttpClientTests extends AbstractEurekaHttpClientTests {
@BeforeEach
void setup() {
eurekaHttpClient = new RestClientTransportClientFactory(Optional.empty(), Optional.empty(),
new DefaultEurekaClientHttpRequestFactorySupplier(new RestClientTimeoutProperties()),
RestClient::builder)
.newClient(new DefaultEndpoint(serviceUrl));
eurekaHttpClient = buildEurekaHttpClient();
EurekaInstanceConfigBean config = new EurekaInstanceConfigBean(inetUtils);
String appname = "customapp";
config.setIpAddress("127.0.0.1");
config.setHostname("localhost");
@@ -73,4 +75,22 @@ class RestClientEurekaHttpClientTests extends AbstractEurekaHttpClientTests {
info = new EurekaConfigBasedInstanceInfoProvider(config).get();
}
private EurekaHttpClient buildEurekaHttpClient() {
return buildEurekaHttpClient(Collections.emptySet());
}
@Test
void shouldCustomiseHttpClientRequestConfig() {
eurekaHttpClient = buildEurekaHttpClient(Set.of(builder -> builder.setProtocolUpgradeEnabled(false)));
assertThatExceptionOfType(RuntimeException.class).isThrownBy(() -> eurekaHttpClient.getApplication("upgrade"));
}
private EurekaHttpClient buildEurekaHttpClient(
Set<EurekaClientHttpRequestFactorySupplier.RequestConfigCustomizer> customizers) {
return new RestClientTransportClientFactory(Optional.empty(), Optional.empty(),
new DefaultEurekaClientHttpRequestFactorySupplier(new RestClientTimeoutProperties(), customizers),
RestClient::builder)
.newClient(new DefaultEndpoint(serviceUrl));
}
}
@@ -1,5 +1,5 @@
/*
* Copyright 2017-2024 the original author or authors.
* Copyright 2017-2025 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.
@@ -16,6 +16,7 @@
package org.springframework.cloud.netflix.eureka.http;
import java.util.Collections;
import java.util.Optional;
import com.netflix.discovery.shared.resolver.DefaultEndpoint;
@@ -42,7 +43,8 @@ class RestClientTransportClientFactoryTests {
@BeforeEach
void setup() {
transportClientFactory = new RestClientTransportClientFactory(Optional.empty(), Optional.empty(),
new DefaultEurekaClientHttpRequestFactorySupplier(new RestClientTimeoutProperties()),
new DefaultEurekaClientHttpRequestFactorySupplier(new RestClientTimeoutProperties(),
Collections.emptySet()),
RestClient::builder);
}
+1 -1
View File
@@ -5,7 +5,7 @@
<parent>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-netflix</artifactId>
<version>4.2.0</version>
<version>4.2.1-SNAPSHOT</version>
<relativePath>..</relativePath> <!-- lookup parent from repository -->
</parent>
<artifactId>spring-cloud-netflix-eureka-server</artifactId>
@@ -71,12 +71,18 @@ public class EurekaInstanceMonitor implements SmartApplicationListener {
@Override
public void onApplicationEvent(ApplicationEvent event) {
final Map<Tags, Long> aggregatedCounts = instanceRegistry.getApplications()
executor.execute(() -> {
Map<Tags, Long> aggregatedCounts = collectAggregatedCounts();
registerMetrics(aggregatedCounts);
});
}
private Map<Tags, Long> collectAggregatedCounts() {
return instanceRegistry.getApplications()
.getRegisteredApplications()
.stream()
.flatMap(application -> application.getInstances().stream())
.collect(Collectors.groupingBy(tagProvider::eurekaInstanceTags, Collectors.counting()));
executor.execute(() -> registerMetrics(aggregatedCounts));
}
private void registerMetrics(Map<Tags, Long> aggregatedCounts) {
@@ -30,7 +30,9 @@ import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.cloud.netflix.eureka.server.metrics.EurekaInstanceMonitor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.bind.annotation.RestController;
import static java.util.concurrent.TimeUnit.MILLISECONDS;
import static java.util.concurrent.TimeUnit.SECONDS;
import static org.assertj.core.api.Assertions.assertThat;
import static org.awaitility.Awaitility.await;
@@ -158,7 +160,8 @@ class EurekaInstanceMonitorTests {
}
private void assertEurekaInstance(Map<Tags, Long> meterRegistryCounts) {
await().atMost(5, SECONDS)
await().pollDelay(5, MILLISECONDS)
.atMost(5, SECONDS)
.pollInterval(fibonacci())
.untilAsserted(() -> meterRegistryCounts.forEach((tags,
count) -> assertThat((long) meterRegistry.get("eureka.server.instances").tags(tags).gauge().value())
@@ -168,6 +171,7 @@ class EurekaInstanceMonitorTests {
@Configuration(proxyBeanMethods = false)
@EnableAutoConfiguration
@EnableEurekaServer
@RestController
protected static class Application {
}
@@ -32,6 +32,7 @@ import org.springframework.cloud.netflix.eureka.server.metrics.EurekaInstanceTag
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import static java.util.concurrent.TimeUnit.MILLISECONDS;
import static java.util.concurrent.TimeUnit.SECONDS;
import static org.assertj.core.api.Assertions.assertThat;
import static org.awaitility.Awaitility.await;
@@ -89,7 +90,8 @@ class EurekaInstanceMonitorWithCustomTagsProviderTests {
}
private void assertEurekaInstance(Map<Tags, Long> meterRegistryCounts) {
await().atMost(5, SECONDS)
await().pollDelay(5, MILLISECONDS)
.atMost(6, SECONDS)
.pollInterval(fibonacci())
.untilAsserted(() -> meterRegistryCounts.forEach((tags,
count) -> assertThat((long) meterRegistry.get("eureka.server.instances").tags(tags).gauge().value())
@@ -4,7 +4,7 @@
<parent>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-netflix</artifactId>
<version>4.2.0</version>
<version>4.2.1-SNAPSHOT</version>
</parent>
<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
<name>Spring Cloud Starter Netflix Eureka Client</name>
@@ -3,7 +3,7 @@
<parent>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-netflix</artifactId>
<version>4.2.0</version>
<version>4.2.1-SNAPSHOT</version>
</parent>
<artifactId>spring-cloud-starter-netflix-eureka-server</artifactId>
<name>Spring Cloud Starter Netflix Eureka Server</name>