Skip to content

GraphQLServletListener cant be registered in OSGI #164

Closed
@maarten-blokker

Description

@maarten-blokker

Im trying to register a GraphQLServletListener so i can set some headers on the response. When i register a listener in OSGI, the following code should pick it up and add it to the configuration:

OsgiGraphQLHttpServlet.java

    @Reference(cardinality = ReferenceCardinality.MULTIPLE, policy = ReferencePolicy.DYNAMIC)
    public void bindServletListener(GraphQLServletListener listener) {
        this.addListener(listener);
    }

which then calls:

AbstractGraphQLHttpServlet

    public void addListener(GraphQLServletListener servletListener) {
        configuration.add(servletListener);
    }

However, the configuration field is not initialised yet until the servlet gets registered. So an NPE is thrown.

graphql-java version: 11.0
graphql-java-servlet version: 7.3.3

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