quarkusio / quarkus

Quarkus: Supersonic Subatomic Java.
https://quarkus.io
Apache License 2.0
13.77k stars 2.68k forks source link

Quarkus 3.9.5 - Single grpc server issues warn: Request Context already active etc. #40711

Open DaveO-Home opened 5 months ago

DaveO-Home commented 5 months ago

Describe the bug

When running gRPC combined with the Web Server, a warning is displayed: Request context already active when gRPC request started. Same warning for either a Java Client or Javascript Client.

Expected behavior

Warning message is suppressed.

Actual behavior

Request context already active when gRPC request started is logged.

How to Reproduce?

Download https://github.com/DaveO-Home/grpc-quarkus, README.md included.

Output of uname -a or ver

Linux mini-pc 6.8.9-300.fc40.x86_64 #1 SMP PREEMPT_DYNAMIC Thu May 2 18:59:06 UTC 2024 x86_64 GNU/Linux

Output of java -version

Java(TM) SE Runtime Environment Oracle GraalVM 21.0.2+13.1 (build 21.0.2+13-LTS-jvmci-23.1-b30) Java HotSpot(TM) 64-Bit Server VM Oracle GraalVM 21.0.2+13.1 (build 21.0.2+13-LTS-jvmci-23.1-b30, mixed mode, sharing)

Quarkus version or git rev

3.9.5

Build tool (ie. output of mvnw --version or gradlew --version)

------------------------------------------------------------ Gradle 8.6 ------------------------------------------------------------ Build time: 2024-02-02 16:47:16 UTC Revision: d55c486870a0dc6f6278f53d21381396d0741c6e Kotlin: 1.9.20 Groovy: 3.0.17 Ant: Apache Ant(TM) version 1.10.13 compiled on January 4 2023 JVM: 21.0.2 (Oracle Corporation 21.0.2+13-LTS-jvmci-23.1-b30) OS: Linux 6.8.9-300.fc40.x86_64 amd64

Additional information

No response

quarkus-bot[bot] commented 5 months ago

/cc @alesj (grpc), @cescoffier (grpc), @geoand (kotlin)

cescoffier commented 5 months ago

Note totally sure, but I cannot run the reproducer:

gradle quarkusDev

Welcome to Gradle 8.8!

Here are the highlights of this release:

For more details see https://docs.gradle.org/8.8/release-notes.html

Starting a Gradle Daemon (subsequent builds will be faster)

FAILURE: Build failed with an exception.

DaveO-Home commented 5 months ago

Did you try ./gradlew quarkusDev. That should pick up gradle 8.7 and the Quarkus config.

cescoffier commented 5 months ago

Same result with:

./gradlew quarkusDev
DaveO-Home commented 5 months ago

Note: Kotlin does not support Java 22 yet. There is a ./gradle/wrapper/gradle-wrapper.properties file right? Also there should be a ./gradle.properties file.

cescoffier commented 5 months ago

I'm using Java v21.0.3.

The ./gradle/wrapper/gradle-wrapper.properties indicates Gradle 8.6:

distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

The ./gradle.properties has nothing out of the ordinary:

org.gradle.jvmargs=-Xmx4096m
quarkusPlatformArtifactId=quarkus-bom
quarkusPlatformGroupId=io.quarkus.platform
quarkusPlatformVersion=3.9.5
quarkusPluginId=io.quarkus
quarkusPluginVersion=3.9.5
DaveO-Home commented 5 months ago

Could not resolve org.jetbrains.kotlin:kotlin-gradle-plugin-api:1.9.23 try changing to 1.9.24 in build.gradle

DaveO-Home commented 5 months ago

I have "Intellij Community"installed on my machine. If that is a requirement to use Kotlin in Gradle, then that is a problem!

cescoffier commented 5 months ago

I'm using my plain terminal. I'm surprised it worse for you. Which gradle and java versions are you using?

DaveO-Home commented 5 months ago

OpenJDK Runtime Environment (Red_Hat-21.0.3.0.9-1) (build 21.0.3+9) OpenJDK 64-Bit Server VM (Red_Hat-21.0.3.0.9-1) (build 21.0.3+9, mixed mode, sharing) I did change the Gradle version to 8.7 but 8.6 also works. I run in a plain terminal also on Fedora 40. Just ran gh repo clone DaveO-Home/grpc-quarkus and started up with gradlew quarkusDev without a change.

Last resort - clear your maven cache

DaveO-Home commented 5 months ago

Upgraded Kotlin & Kotlin Plugin to 2.0.0 and Gradle to 8.8. Should run with Java 17-22

DaveO-Home commented 4 months ago

The problem is with the following (I use in the websockets app):

    @RouteFilter(50)
    void getRemoteAddress(RoutingContext rc) {
        if (rc != null) {
            if (rc.request() != null && rc.request().remoteAddress() != null) {
                remoteAddress = rc.request().remoteAddress().toString();
            }
            rc.next();
        }
    }

Implemented from io.quarkus:quarkus-vertx-web:3.0.0.Beta1.

Is there an alternative?

cescoffier commented 4 months ago

Ah, that may explain it. This may activate the request scope. I can't remember, do you have the stack trace you see?

DaveO-Home commented 4 months ago

No, only the warning is produced.

cescoffier commented 4 months ago

Ok, so we will have to find all the places where the request scope gets activated unconditionally.

cescoffier commented 2 days ago

Just a haed's up - still didn't have time to look into that. Maybe @alesj can have a look.