Skip to content

Commit c1b08f8

Browse files
committed
Revert "Use ObjectProvider for DeferringLoadBalancerExchangeFilterFunction."
This reverts commit 8fdd79f. # Conflicts: # spring-cloud-commons/src/main/java/org/springframework/cloud/client/loadbalancer/reactive/LoadBalancerWebClientBuilderBeanPostProcessor.java
1 parent 20d6372 commit c1b08f8

File tree

4 files changed

+8
-88
lines changed

4 files changed

+8
-88
lines changed

spring-cloud-commons/src/main/java/org/springframework/cloud/client/loadbalancer/SimpleObjectProvider.java

Lines changed: 0 additions & 60 deletions
This file was deleted.

spring-cloud-commons/src/main/java/org/springframework/cloud/client/loadbalancer/reactive/DeferringLoadBalancerExchangeFilterFunction.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2024 the original author or authors.
2+
* Copyright 2012-2020 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.
@@ -55,7 +55,7 @@ void tryResolveDelegate() {
5555
if (delegate == null) {
5656
delegate = exchangeFilterFunctionProvider.getIfAvailable();
5757
if (delegate == null) {
58-
throw new IllegalStateException("LoadBalancerExchangeFilterFunction not available.");
58+
throw new IllegalStateException("ReactorLoadBalancerExchangeFilterFunction not available.");
5959
}
6060
}
6161
}

spring-cloud-commons/src/main/java/org/springframework/cloud/client/loadbalancer/reactive/LoadBalancerBeanPostProcessorAutoConfiguration.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
import org.springframework.context.annotation.Bean;
2828
import org.springframework.context.annotation.Conditional;
2929
import org.springframework.context.annotation.Configuration;
30+
import org.springframework.context.annotation.Lazy;
3031
import org.springframework.context.annotation.Primary;
3132
import org.springframework.web.reactive.function.client.WebClient;
3233

@@ -47,10 +48,9 @@
4748
@Conditional(LoadBalancerBeanPostProcessorAutoConfiguration.OnAnyLoadBalancerImplementationPresentCondition.class)
4849
public class LoadBalancerBeanPostProcessorAutoConfiguration {
4950

50-
@SuppressWarnings("rawtypes")
5151
@Bean
5252
public static LoadBalancerWebClientBuilderBeanPostProcessor loadBalancerWebClientBuilderBeanPostProcessor(
53-
ObjectProvider<DeferringLoadBalancerExchangeFilterFunction> deferringExchangeFilterFunction,
53+
@Lazy DeferringLoadBalancerExchangeFilterFunction deferringExchangeFilterFunction,
5454
ApplicationContext context) {
5555
return new LoadBalancerWebClientBuilderBeanPostProcessor(deferringExchangeFilterFunction, context);
5656
}

spring-cloud-commons/src/main/java/org/springframework/cloud/client/loadbalancer/reactive/LoadBalancerWebClientBuilderBeanPostProcessor.java

Lines changed: 4 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2024 the original author or authors.
2+
* Copyright 2012-2020 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.
@@ -17,10 +17,8 @@
1717
package org.springframework.cloud.client.loadbalancer.reactive;
1818

1919
import org.springframework.beans.BeansException;
20-
import org.springframework.beans.factory.ObjectProvider;
2120
import org.springframework.beans.factory.config.BeanPostProcessor;
2221
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
23-
import org.springframework.cloud.client.loadbalancer.SimpleObjectProvider;
2422
import org.springframework.context.ApplicationContext;
2523
import org.springframework.web.reactive.function.client.WebClient;
2624

@@ -32,28 +30,15 @@
3230
* @author Olga Maciaszek-Sharma
3331
* @since 2.2.0
3432
*/
35-
@SuppressWarnings({ "removal", "rawtypes" })
3633
public class LoadBalancerWebClientBuilderBeanPostProcessor implements BeanPostProcessor {
3734

38-
private final ObjectProvider<DeferringLoadBalancerExchangeFilterFunction> exchangeFilterFunctionObjectProvider;
35+
private final DeferringLoadBalancerExchangeFilterFunction exchangeFilterFunction;
3936

4037
private final ApplicationContext context;
4138

42-
/**
43-
* @deprecated in favour of
44-
* {@link LoadBalancerWebClientBuilderBeanPostProcessor#LoadBalancerWebClientBuilderBeanPostProcessor(ObjectProvider, ApplicationContext)}
45-
*/
46-
@Deprecated(forRemoval = true)
4739
public LoadBalancerWebClientBuilderBeanPostProcessor(
4840
DeferringLoadBalancerExchangeFilterFunction exchangeFilterFunction, ApplicationContext context) {
49-
this.exchangeFilterFunctionObjectProvider = new SimpleObjectProvider<>(exchangeFilterFunction);
50-
this.context = context;
51-
}
52-
53-
public LoadBalancerWebClientBuilderBeanPostProcessor(
54-
ObjectProvider<DeferringLoadBalancerExchangeFilterFunction> exchangeFilterFunction,
55-
ApplicationContext context) {
56-
this.exchangeFilterFunctionObjectProvider = exchangeFilterFunction;
41+
this.exchangeFilterFunction = exchangeFilterFunction;
5742
this.context = context;
5843
}
5944

@@ -63,12 +48,7 @@ public Object postProcessBeforeInitialization(Object bean, String beanName) thro
6348
if (context.findAnnotationOnBean(beanName, LoadBalanced.class) == null) {
6449
return bean;
6550
}
66-
DeferringLoadBalancerExchangeFilterFunction exchangeFilterFunction = exchangeFilterFunctionObjectProvider
67-
.getIfAvailable();
68-
if (exchangeFilterFunction == null) {
69-
throw new IllegalStateException("LoadBalancerExchangeFilterFunction not found");
70-
}
71-
((WebClient.Builder) bean).filter(exchangeFilterFunctionObjectProvider.getIfAvailable());
51+
((WebClient.Builder) bean).filter(exchangeFilterFunction);
7252
}
7353
return bean;
7454
}

0 commit comments

Comments
 (0)