Skip to content

Commit 394a268

Browse files
committed
Merge remote-tracking branch 'origin/main'
2 parents 91bbde0 + 63eb399 commit 394a268

File tree

5 files changed

+59
-3
lines changed

5 files changed

+59
-3
lines changed

docs/modules/ROOT/pages/spring-cloud-commons/common-abstractions.adoc

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,21 @@ public class MyClass {
253253
The URI needs to use a virtual host name (that is, a service name, not a host name).
254254
The `BlockingLoadBalancerClient` is used to create a full physical address.
255255

256+
In order to leverage additional capabilities that Spring Boot provides for `RestTemplateBuilder` (for example, observability support) you may want to use the autoconfigured
257+
`RestTemplateBuilderConfigurer` while creating the `@LoadBalanced RestTemplateBuilder` beans:
258+
259+
[source,java,indent=0]
260+
----
261+
@Configuration
262+
public class MyConfiguration {
263+
264+
@LoadBalanced
265+
RestTemplateBuilder loadBalancedRestTemplateBuilder(RestTemplateBuilderConfigurer configurer) {
266+
return configurer.configure(new RestTemplateBuilder());
267+
}
268+
}
269+
----
270+
256271
IMPORTANT: To use it, add xref:spring-cloud-commons/loadbalancer.adoc#spring-cloud-loadbalancer-starter[Spring Cloud LoadBalancer starter] to your project.
257272

258273
[[multiple-resttemplate-builder-beans]]
@@ -333,6 +348,22 @@ public class MyClass {
333348
The URI needs to use a virtual host name (that is, a service name, not a host name).
334349
The `BlockingLoadBalancerClient` is used to create a full physical address.
335350

351+
In order to leverage additional capabilities that Spring Boot provides for `RestClient.Builder` (for example, observability support) you may want to use the autoconfigured
352+
`RestClientBuilderConfigurer` while creating the `@LoadBalanced RestClient.Builder` beans:
353+
354+
[source,java,indent=0]
355+
----
356+
@Configuration
357+
public class MyConfiguration {
358+
359+
@LoadBalanced
360+
@Bean
361+
RestClient.Builder restClientBuilder(RestClientBuilderConfigurer configurer) {
362+
return configurer.configure(RestClient.builder());
363+
}
364+
}
365+
----
366+
336367
IMPORTANT: To use it, add xref:spring-cloud-commons/loadbalancer.adoc#spring-cloud-loadbalancer-starter[Spring Cloud LoadBalancer starter] to your project.
337368

338369
[[multiple-restclient-objects]]
@@ -413,6 +444,24 @@ public class MyClass {
413444
The URI needs to use a virtual host name (that is, a service name, not a host name).
414445
The Spring Cloud LoadBalancer is used to create a full physical address.
415446

447+
In order to leverage additional capabilities that Spring Boot provides for `WebClient.Builder` (for example, observability support) you may want to use the autoconfigured
448+
`WebClientCustomizer` beans while creating the `@LoadBalanced WebClient.Builder` beans:
449+
450+
[source,java,indent=0]
451+
----
452+
@Configuration
453+
public class MyConfiguration {
454+
455+
@Bean
456+
@LoadBalanced
457+
public WebClient.Builder loadBalancedWebClientBuilder(ObjectProvider<WebClientCustomizer> customizerProvider) {
458+
WebClient.Builder builder = WebClient.builder();
459+
customizerProvider.orderedStream().forEach((customizer) -> customizer.customize(builder));
460+
return builder;
461+
}
462+
}
463+
----
464+
416465
IMPORTANT: If you want to use a `@LoadBalanced WebClient.Builder`, you need to have a Spring Cloud LoadBalancer
417466
implementation in the classpath. We recommend that you add the
418467
xref:spring-cloud-commons/loadbalancer.adoc#spring-cloud-loadbalancer-starter[Spring Cloud LoadBalancer starter] to your project.

pom.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,10 @@
8080
<artifactId>httpclient5</artifactId>
8181
</dependency>
8282
</ignoredDependencies>
83+
<ignoredResourcePatterns>
84+
<ignoredResourcePattern>mockito-extensions/org.mockito.plugins.MockResolver</ignoredResourcePattern>
85+
</ignoredResourcePatterns>
86+
<checkTestClasspath>false</checkTestClasspath>
8387
</configuration>
8488
</plugin>
8589
</plugins>

spring-cloud-commons/src/main/java/org/springframework/cloud/configuration/TlsProperties.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2017-2020 the original author or authors.
2+
* Copyright 2017-2024 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -16,6 +16,7 @@
1616

1717
package org.springframework.cloud.configuration;
1818

19+
import java.util.Locale;
1920
import java.util.Map;
2021

2122
import org.springframework.core.io.Resource;
@@ -143,7 +144,7 @@ private String fileExtensionOf(Resource resource) {
143144
String name = resource.getFilename();
144145
int index = name.lastIndexOf('.');
145146

146-
return index < 0 ? "" : name.substring(index + 1).toLowerCase();
147+
return index < 0 ? "" : name.substring(index + 1).toLowerCase(Locale.ROOT);
147148
}
148149

149150
}

spring-cloud-commons/src/test/java/org/springframework/cloud/client/loadbalancer/LoadBalancedRestClientIntegrationTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ void shouldBuildLoadBalancedRestClientInConstructor() {
5050
RestClient client = restClientBuilder.build();
5151

5252
// Interceptors are not visible in RestClient
53-
assertThatThrownBy(() -> client.get().uri("http://test-service").retrieve())
53+
assertThatThrownBy(() -> client.get().uri("http://test-service").retrieve().toBodilessEntity())
5454
.hasMessage("LoadBalancerInterceptor invoked.");
5555
}
5656

src/checkstyle/checkstyle-suppressions.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,6 @@
2222
<suppress files=".*AutoConfiguration.*" checks="HideUtilityClassConstructor"/>
2323
<suppress files=".*AutoConfiguration.*" checks="FinalClass"/>
2424
<suppress files=".*ReactiveDiscoveryClient.*" checks="JavadocVariable"/>
25+
<suppress files="[\\/]src[\\/](test|testFixtures)[\\/](java|java21)[\\/]" checks="RegexpSinglelineJava" id="toLowerCaseWithoutLocale"/>
26+
<suppress files="[\\/]src[\\/](test|testFixtures)[\\/](java|java21)[\\/]" checks="RegexpSinglelineJava" id="toUpperCaseWithoutLocale"/>
2527
</suppressions>

0 commit comments

Comments
 (0)