Skip to content
This repository was archived by the owner on Dec 19, 2023. It is now read-only.
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

Description

@juangamnik
  • 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).

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions