yahoo / elide

Elide is a Java library that lets you stand up a GraphQL/JSON-API web service with minimal effort.
https://elide.io
Other
991 stars 227 forks source link

NullPointerException for Async enabled with GraphQL defaults (disabled) #3245

Open white3km opened 2 weeks ago

white3km commented 2 weeks ago

Expected Behavior

Running Elide with the following settings (see application.yml below)

Current Behavior

Application has a single entity with latest Elide (7.1.0) and Spring Boot Starter (3.3.1). The application only has JSON API enabled and runs successfully when async is disabled. Once async is enabled then a null pointer exception is thrown during startup related to graphql configuration settings.

Steps to Reproduce (for bugs)

elide:
  defaultPageSize: 10
  maxPageSize: 500
  verboseErrors: true
  json-api:
    enabled: true
    path: ${API_PREFIX:/api}
  api-docs:
    path: /doc
    enabled: true
    version: openapi_3_0
  async:
    enabled: true
    thread-pool-size: 7
    cleanup:
      enabled: true
      query-max-run-time: 65s
      query-retention-duration: 7d
    export:
      enabled: true
      format:
        csv:
          writeHeader: true
      path: ${EXPORT_ENDPOINT:/export}
      appendFileExtension: true
      storageDestination: ${EXPORT_STORAGE_DIR:./temp}

Context

Log Output

2024-06-24T10:21:41.073-04:00 ERROR 13128 --- [simple-elide] [           main] o.s.boot.SpringApplication               : Application run failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'asyncExecutorService' defined in class path resource [com/yahoo/elide/spring/config/ElideAsyncConfiguration.class]: Failed to instantiate [com.yahoo.elide.async.service.AsyncExecutorService]: Factory method 'asyncExecutorService' threw exception with message: Cannot invoke "com.yahoo.elide.graphql.GraphQLSettings.getFederation()" because "graphQLSettings" is null
    at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:648) ~[spring-beans-6.1.10.jar:6.1.10]
    at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:636) ~[spring-beans-6.1.10.jar:6.1.10]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1337) ~[spring-beans-6.1.10.jar:6.1.10]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1167) ~[spring-beans-6.1.10.jar:6.1.10]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:562) ~[spring-beans-6.1.10.jar:6.1.10]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:522) ~[spring-beans-6.1.10.jar:6.1.10]
    at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:337) ~[spring-beans-6.1.10.jar:6.1.10]
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) ~[spring-beans-6.1.10.jar:6.1.10]
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:335) ~[spring-beans-6.1.10.jar:6.1.10]
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:200) ~[spring-beans-6.1.10.jar:6.1.10]
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:975) ~[spring-beans-6.1.10.jar:6.1.10]
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:962) ~[spring-context-6.1.10.jar:6.1.10]
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:624) ~[spring-context-6.1.10.jar:6.1.10]
    at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:146) ~[spring-boot-3.3.1.jar:3.3.1]
    at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:754) ~[spring-boot-3.3.1.jar:3.3.1]
    at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:456) ~[spring-boot-3.3.1.jar:3.3.1]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:335) ~[spring-boot-3.3.1.jar:3.3.1]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1363) ~[spring-boot-3.3.1.jar:3.3.1]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1352) ~[spring-boot-3.3.1.jar:3.3.1]
    at com.spring.boot.elide.simple.SimpleApplication.main(SimpleApplication.java:10) ~[classes/:na]
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.yahoo.elide.async.service.AsyncExecutorService]: Factory method 'asyncExecutorService' threw exception with message: Cannot invoke "com.yahoo.elide.graphql.GraphQLSettings.getFederation()" because "graphQLSettings" is null
    at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:177) ~[spring-beans-6.1.10.jar:6.1.10]
    at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:644) ~[spring-beans-6.1.10.jar:6.1.10]
    ... 19 common frames omitted
Caused by: java.lang.NullPointerException: Cannot invoke "com.yahoo.elide.graphql.GraphQLSettings.getFederation()" because "graphQLSettings" is null
    at com.yahoo.elide.graphql.ModelBuilder.<init>(ModelBuilder.java:130) ~[elide-graphql-7.1.0.jar:na]
    at com.yahoo.elide.graphql.QueryRunner.<init>(QueryRunner.java:91) ~[elide-graphql-7.1.0.jar:na]
    at com.yahoo.elide.async.service.AsyncExecutorService.<init>(AsyncExecutorService.java:73) ~[elide-async-7.1.0.jar:na]
    at com.yahoo.elide.spring.config.ElideAsyncConfiguration.asyncExecutorService(ElideAsyncConfiguration.java:118) ~[elide-spring-boot-autoconfigure-7.1.0.jar:na]
    at com.yahoo.elide.spring.config.ElideAsyncConfiguration$$SpringCGLIB$$0.CGLIB$asyncExecutorService$2(<generated>) ~[elide-spring-boot-autoconfigure-7.1.0.jar:na]
    at com.yahoo.elide.spring.config.ElideAsyncConfiguration$$SpringCGLIB$$FastClass$$1.invoke(<generated>) ~[elide-spring-boot-autoconfigure-7.1.0.jar:na]
    at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:258) ~[spring-core-6.1.10.jar:6.1.10]
    at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:348) ~[spring-context-6.1.10.jar:6.1.10]
    at com.yahoo.elide.spring.config.ElideAsyncConfiguration$$SpringCGLIB$$0.asyncExecutorService(<generated>) ~[elide-spring-boot-autoconfigure-7.1.0.jar:na]
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:na]
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77) ~[na:na]
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:na]
    at java.base/java.lang.reflect.Method.invoke(Method.java:568) ~[na:na]
    at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:140) ~[spring-beans-6.1.10.jar:6.1.10]
    ... 20 common frames omitted

Your Environment

Spring Boot Elide (elide-spring-boot-starter) Elide 7.1.0

white3km commented 2 weeks ago

Also fails with same error when graphql is explicitly disabled

 graphql:
    enabled: false
    federation:
      enabled: false