Skip to content
This repository was archived by the owner on Dec 19, 2023. It is now read-only.

GraphQLErrorHandlerFactory scans for beans with request scope and dies #254

Closed
juangamnik opened this issue Jun 4, 2019 · 2 comments
Closed
Labels
Milestone

Comments

@juangamnik
Copy link

juangamnik commented Jun 4, 2019

  • Spring Boot 2.1.4.RELEASE
  • Java 11
  • graphql-kickstart.version 5.9.0

As mentioned in #219 there is a problem with the scan mechanism of GraphQLErrorHandlerFactory. In #create(...):33ff all bean names that pass the applicationContext::containsBean check are scanned for exception handlers. The Javadoc of the method #containsBean(...) suggests that only singleton beans are returned. On the contrary, there is a hint that a true of this method does not mean that #getBean() will work for that bean. Unfortunately, exactly this is done in the scanning function #scanForExceptionHandlers(...):41, in order to get the class of the bean.

In my case, this tried to load a request scoped bean defined in a @Configuration via @Bean annotated method with @Scope(value = WebApplicationContext.SCOPE_REQUEST, proxyMode = ScopedProxyMode.TARGET_CLASS) and the whole creation of the factory dies.

Instead of using Class<?> objClz = context.getBean(name).getClass() in line 41 of GraphQLErrorHandlerFactory it would be much better to use Class<?> objClz = context.getType(name).

@oliemansm oliemansm added this to the 5.9.1 milestone Jun 19, 2019
@oliemansm
Copy link
Member

Thanks, I've changed this in 5.9.1

@juangamnik
Copy link
Author

Thanks!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants