|
21 | 21 | import org.springframework.boot.autoconfigure.EnableAutoConfiguration; |
22 | 22 | import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; |
23 | 23 | import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; |
24 | | -import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication; |
25 | | -import org.springframework.boot.autoconfigure.condition.NoneNestedConditions; |
26 | 24 | import org.springframework.boot.autoconfigure.http.HttpMessageConvertersAutoConfiguration; |
| 25 | +import org.springframework.boot.web.client.ClientHttpRequestFactories; |
| 26 | +import org.springframework.boot.web.client.ClientHttpRequestFactorySettings; |
27 | 27 | import org.springframework.boot.web.client.RestClientCustomizer; |
28 | 28 | import org.springframework.context.annotation.Bean; |
29 | 29 | import org.springframework.context.annotation.Conditional; |
|
33 | 33 | /** |
34 | 34 | * {@link EnableAutoConfiguration Auto-configuration} for {@link RestClient}. |
35 | 35 | * <p> |
36 | | - * This will produce a {@link RestClient.Builder RestClient.Builder} bean with the |
37 | | - * {@code prototype} scope, meaning each injection point will receive a newly cloned |
38 | | - * instance of the builder. |
| 36 | + * This will produce a {@link org.springframework.web.client.RestClient.Builder |
| 37 | + * RestClient.Builder} bean with the {@code prototype} scope, meaning each injection point |
| 38 | + * will receive a newly cloned instance of the builder. |
39 | 39 | * |
40 | 40 | * @author Arjen Poutsma |
41 | 41 | * @since 3.2.0 |
42 | 42 | */ |
43 | 43 | @AutoConfiguration(after = HttpMessageConvertersAutoConfiguration.class) |
44 | 44 | @ConditionalOnClass(RestClient.class) |
45 | | -@Conditional(RestClientAutoConfiguration.NotReactiveWebApplicationCondition.class) |
| 45 | +@Conditional(NotReactiveWebApplicationCondition.class) |
46 | 46 | public class RestClientAutoConfiguration { |
47 | 47 |
|
48 | 48 | @Bean |
49 | 49 | @Scope("prototype") |
50 | 50 | @ConditionalOnMissingBean |
51 | 51 | public RestClient.Builder webClientBuilder(ObjectProvider<RestClientCustomizer> customizerProvider) { |
52 | | - RestClient.Builder builder = RestClient.builder(); |
| 52 | + RestClient.Builder builder = RestClient.builder() |
| 53 | + .requestFactory(ClientHttpRequestFactories.get(ClientHttpRequestFactorySettings.DEFAULTS)); |
53 | 54 | customizerProvider.orderedStream().forEach((customizer) -> customizer.customize(builder)); |
54 | 55 | return builder; |
55 | 56 | } |
56 | 57 |
|
57 | | - static class NotReactiveWebApplicationCondition extends NoneNestedConditions { |
58 | | - |
59 | | - NotReactiveWebApplicationCondition() { |
60 | | - super(ConfigurationPhase.PARSE_CONFIGURATION); |
61 | | - } |
62 | | - |
63 | | - @ConditionalOnWebApplication(type = ConditionalOnWebApplication.Type.REACTIVE) |
64 | | - private static class ReactiveWebApplication { |
65 | | - |
66 | | - } |
67 | | - |
68 | | - } |
69 | | - |
70 | 58 | } |
0 commit comments