spring-cloud / spring-cloud/spring-cloud-netflix
@Bean Annotation on Collection<RequetInterceptor> Not working
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 5k
- Forks
- 2.5k
- Avg merge
- 1d 2h
- Merged PRs (30d)
- 10
Description
From looking at the documentation on customizing FeignClients, I am experiencing that the following code is not working to create a list of RequestInterceptors...I have to create individual RequestInterceptrs instead and annotate with "@Bean"
@Bean
public RequestInterceptor xAuthTokenForwardingRequestInterceptor(){
log.info("Configuring instance [{}]", RequestInterceptor.class);
return new HystrixHeaderForwardingRequestInterceptor( "X-Auth-Token");
}
@Bean
public RequestInterceptor xAuthUserTokenForwardingRequestInterceptor(){
log.info("Configuring instance [{}]", RequestInterceptor.class);
return new HystrixHeaderForwardingRequestInterceptor( "X-Auth-User-Token");
}
// This does not work despite the Spring Cloud/Netflix documentation saying it should work
// @Bean
// public Collection<RequestInterceptor> headerForwardingRequestInterceptors(){
// log.info("Configuring instance [{}]", RequestInterceptor.class);
//
// List<RequestInterceptor> interceptors = new ArrayList<>();
//
// this.properties.getForwardedHeaders().forEach(fh->{
// interceptors.add(new HystrixHeaderForwardingRequestInterceptor( fh));
// });
//
// log.info("headerForwardingRequestInterceptors - configured interceptor:[{}]", interceptors);
// return interceptors;
// }
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the Feign client customization documentation referenced in the report and reproduce the supplied @Bean configurations, comparing separate RequestInterceptor beans with the Collection bean. Trace the existing RequestInterceptor bean-discovery entry point; done when the reported collection behavior is explained and covered by a regression test or the documentation is corrected.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, spring
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100