spring-cloud / spring-cloud/spring-cloud-netflix

@Bean Annotation on Collection<RequetInterceptor> Not working

Open
#1,465 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

documentation
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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.