File tree Expand file tree Collapse file tree 2 files changed +13
-2
lines changed
main/java/org/springframework/grpc/client
test/java/org/springframework/grpc/client Expand file tree Collapse file tree 2 files changed +13
-2
lines changed Original file line number Diff line number Diff line change 22
22
23
23
import org .springframework .beans .factory .InitializingBean ;
24
24
import org .springframework .beans .factory .NoSuchBeanDefinitionException ;
25
+ import org .springframework .beans .factory .NoUniqueBeanDefinitionException ;
25
26
import org .springframework .context .ApplicationContext ;
27
+ import org .springframework .core .log .LogAccessor ;
26
28
import org .springframework .grpc .internal .ApplicationContextBeanLookupUtils ;
27
29
28
30
import io .grpc .ClientInterceptor ;
36
38
*/
37
39
public class ClientInterceptorsConfigurer implements InitializingBean {
38
40
41
+ private final LogAccessor log = new LogAccessor (getClass ());
42
+
39
43
private final ApplicationContext applicationContext ;
40
44
41
45
private List <ClientInterceptor > globalInterceptors ;
@@ -87,7 +91,14 @@ private ClientInterceptorFilter findInterceptorFilter() {
87
91
try {
88
92
return this .applicationContext .getBean (ClientInterceptorFilter .class );
89
93
}
94
+ catch (NoUniqueBeanDefinitionException noUniqueBeanEx ) {
95
+ this .log .warn (noUniqueBeanEx ,
96
+ () -> "No unique ClientInterceptorFilter bean found. Consider defining a single bean or marking one as @Primary" );
97
+ return null ;
98
+ }
90
99
catch (NoSuchBeanDefinitionException ignored ) {
100
+ this .log .debug (
101
+ () -> "No ClientInterceptorFilter bean found - filtering will not be applied to client interceptors." );
91
102
return null ;
92
103
}
93
104
}
Original file line number Diff line number Diff line change @@ -173,7 +173,7 @@ void whenBlendInterceptorsTrueThenGlobalInterceptorsBlended() {
173
173
}
174
174
175
175
@ Nested
176
- class WithInterceptorFilters {
176
+ class WithInterceptorFilter {
177
177
178
178
@ Test
179
179
void whenFilterExcludesOneGlobalInterceptor_thenBuilderGetsOnlyAllowedOnes () {
@@ -196,7 +196,7 @@ void whenFilterIncludesAllGlobalInterceptors_thenBuilderGetsOnlyAllowedOnes() {
196
196
ManagedChannelBuilder <?> builder = Mockito .mock ();
197
197
ClientInterceptorsConfigurerTests .this .contextRunner ()
198
198
.withUserConfiguration (GlobalClientInterceptorsConfig .class )
199
- .withBean (ClientInterceptorFilter .class , () -> (interceptor , __ ) -> true )
199
+ .withBean (ClientInterceptorFilter .class , () -> (__ , ___ ) -> true )
200
200
.run (context -> {
201
201
var factory = Mockito .mock (GrpcChannelFactory .class );
202
202
var configurer = context .getBean (ClientInterceptorsConfigurer .class );
You can’t perform that action at this time.
0 commit comments