Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GraphQL Reactive: RequestContext cleanup #27147

Merged

Conversation

phillip-kruger
Copy link
Member

More cleanup of the RequestContext. See #27040
Fix #27127

Signed-off-by: Phillip Kruger [email protected]

@phillip-kruger phillip-kruger added the triage/waiting-for-ci Ready to merge when CI successfully finishes label Aug 5, 2022
@phillip-kruger phillip-kruger merged commit cb4b2a8 into quarkusio:main Aug 5, 2022
@quarkus-bot quarkus-bot bot added this to the 2.12 - main milestone Aug 5, 2022
@quarkus-bot quarkus-bot bot added kind/bugfix and removed triage/waiting-for-ci Ready to merge when CI successfully finishes labels Aug 5, 2022
@gsmet gsmet modified the milestones: 2.12.0.CR1, 2.11.3.Final Aug 23, 2022
@deedarb
Copy link

deedarb commented Aug 31, 2022

after upgrading from 2.11.1 to 2.11.3 my app is not working.
i have a custom scalar type

    @AdaptToScalar(Scalar.String.class)
    public class I18nLabel {
        ...
        @Override
        public String toString() {
                Language lang = Optional.ofNullable(CDI.current()).map(cdi -> cdi.select(HttpServerRequest.class)).map(Instance::get).flatMap(WebUtils::extractLanguage).orElse(Language.EN);
	        return get(lang);
        }
    }

and exception is raised at extract language with error log:

[io.qua.ver.htt.run.QuarkusErrorHandler] (vert.x-eventloop-thread-1) HTTP Request to /api/store/graphql failed, error id: 84810bca-1f2e-4550-acc2-8bfdc7dccbab-1: javax.enterprise.context.ContextNotActiveException: RequestScoped context was not active when trying to obtain a bean instance for a client proxy of PRODUCER_METHOD bean [class=io.quarkus.vertx.http.runtime.CurrentRequestProducer, id=c786212c50efeac37ecc96f8570579f64be3bb5b]
        - you can activate the request context for a specific method using the @ActivateRequestContext interceptor binding
        at io.quarkus.arc.impl.ClientProxies.getDelegate(ClientProxies.java:53)
        at io.vertx.core.http.CurrentRequestProducer_ProducerMethod_getCurrentRequest_05f950ea7ab91d121ba0bac525b89d62f3261b2d_ClientProxy.arc$delegate(Unknown Source)
        at io.vertx.core.http.CurrentRequestProducer_ProducerMethod_getCurrentRequest_05f950ea7ab91d121ba0bac525b89d62f3261b2d_ClientProxy.getHeader(Unknown Source)
        at is.happy.common.util.WebUtils.extractLanguage(WebUtils.java:34)

WebUtils.extractLanguage ->

public static Optional<Language> extractLanguage(HttpServerRequest request) {
	    String acceptLanguage = request.getHeader(HttpHeaders.ACCEPT_LANGUAGE);
	    List<ParsableLanguageValue> languages = HeaderParser.sort(HeaderParser.convertToParsedHeaderValues(acceptLanguage, ParsableLanguageValue::new));
	    return Lists.nonEmpty(languages)
		    .map(list -> list.get(0))
		    .map(lang -> Language.valueOf(lang.tag().toUpperCase()));
    }

@gsmet
Copy link
Member

gsmet commented Aug 31, 2022

@deedarb please open a new issue with a simple Maven reproducer. Thanks.

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

Successfully merging this pull request may close these issues.

GraphQL random CDI context issues when using RestClients with @Source
4 participants