-
Notifications
You must be signed in to change notification settings - Fork 3k
Description
Describe the bug
In the Quarkus Rest project, when the @RunOnVirtualThread annotation is added to the implementation of jakarta.ws.rs.core.Application.
Blocking endpoints method are now considered non-blocking.
MainApplication.java
import io.smallrye.common.annotation.RunOnVirtualThread;
import jakarta.ws.rs.core.Application;
@RunOnVirtualThread
public class MainApplication extends Application {
}
Echo.java
import jakarta.ws.rs.GET;
import jakarta.ws.rs.Path;
import java.time.Instant;
@Path("")
public class Echo {
private final System.Logger logger = System.getLogger(Echo.class.getName());
@GET()
@Path("now")
public Instant now() {
Instant now = Instant.now();
String threadName = Thread.currentThread().getName();
logger.log(System.Logger.Level.INFO,"thread: "+threadName+", time:"+now);
return now;
}
}
error log
2025-07-31 12:35:51,149 ERROR [org.jbo.res.rea.ser.cor.sta.RuntimeResourceDeployment] (Quarkus Main Thread) a method was both non-blocking and @RunOnVirtualThread, it is now considered @RunOnVirtual and blocking
when add @RunOnVirtualThread annotation on method now() An exception will be thrown at startup.
import io.smallrye.common.annotation.RunOnVirtualThread;
import jakarta.ws.rs.GET;
import jakarta.ws.rs.Path;
import java.time.Instant;
@Path("")
public class Echo {
private final System.Logger logger = System.getLogger(Echo.class.getName());
@RunOnVirtualThread
@GET()
@Path("now")
public Instant now() {
Instant now = Instant.now();
String threadName = Thread.currentThread().getName();
logger.log(System.Logger.Level.INFO,"thread: "+threadName+", time:"+now);
return now;
}
}
error log
2025-07-31 12:49:59,969 ERROR [io.qua.dep.dev.IsolatedDevModeMain] (main) Failed to start quarkus: java.lang.RuntimeException: io.quarkus.builder.BuildException: Build failure: Build failed due to errors
[error]: Build step io.quarkus.resteasy.reactive.server.deployment.ResteasyReactiveProcessor#setupEndpoints threw an exception: jakarta.enterprise.inject.spi.DeploymentException: Method 'now' of class 'com.jacky.Echo' is considered a non blocking method. @RunOnVirtualThread can only be used on methods considered blocking
at org.jboss.resteasy.reactive.common.processor.EndpointIndexer.isRunOnVirtualThread(EndpointIndexer.java:888)
at org.jboss.resteasy.reactive.common.processor.EndpointIndexer.createResourceMethod(EndpointIndexer.java:756)
at org.jboss.resteasy.reactive.common.processor.EndpointIndexer.createEndpoints(EndpointIndexer.java:448)
at org.jboss.resteasy.reactive.common.processor.EndpointIndexer.createEndpoints(EndpointIndexer.java:312)
at io.quarkus.resteasy.reactive.server.deployment.ResteasyReactiveProcessor.setupEndpoints(ResteasyReactiveProcessor.java:726)
at java.base/java.lang.invoke.MethodHandle.invokeWithArguments(MethodHandle.java:735)
at io.quarkus.deployment.ExtensionLoader$3.execute(ExtensionLoader.java:889)
at io.quarkus.builder.BuildContext.run(BuildContext.java:255)
at org.jboss.threads.ContextHandler$1.runWith(ContextHandler.java:18)
at org.jboss.threads.EnhancedQueueExecutor$Task.doRunWith(EnhancedQueueExecutor.java:2651)
at org.jboss.threads.EnhancedQueueExecutor$Task.run(EnhancedQueueExecutor.java:2630)
at org.jboss.threads.EnhancedQueueExecutor.runThreadBody(EnhancedQueueExecutor.java:1622)
at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1589)
at java.base/java.lang.Thread.run(Thread.java:1447)
at org.jboss.threads.JBossThread.run(JBossThread.java:501)
at io.quarkus.runner.bootstrap.AugmentActionImpl.runAugment(AugmentActionImpl.java:372)
at io.quarkus.runner.bootstrap.AugmentActionImpl.createInitialRuntimeApplication(AugmentActionImpl.java:289)
at io.quarkus.runner.bootstrap.AugmentActionImpl.createInitialRuntimeApplication(AugmentActionImpl.java:61)
at io.quarkus.deployment.dev.IsolatedDevModeMain.firstStart(IsolatedDevModeMain.java:89)
at io.quarkus.deployment.dev.IsolatedDevModeMain.accept(IsolatedDevModeMain.java:432)
at io.quarkus.deployment.dev.IsolatedDevModeMain.accept(IsolatedDevModeMain.java:55)
at io.quarkus.bootstrap.app.CuratedApplication.runInCl(CuratedApplication.java:143)
at io.quarkus.bootstrap.app.CuratedApplication.runInAugmentClassLoader(CuratedApplication.java:98)
Expected behavior
No response
Actual behavior
no error and now() method considered @RunOnVirtual
How to Reproduce?
Output of uname -a
or ver
Darwin Jacky.local 24.5.0 Darwin Kernel Version 24.5.0: Tue Apr 22 19:48:46 PDT 2025; root:xnu-11417.121.6~2/RELEASE_ARM64_T8103 arm64
Output of java -version
java version "24.0.1" 2025-04-15 Java(TM) SE Runtime Environment Oracle GraalVM 24.0.1+9.1 (build 24.0.1+9-jvmci-b01) Java HotSpot(TM) 64-Bit Server VM Oracle GraalVM 24.0.1+9.1 (build 24.0.1+9-jvmci-b01, mixed mode, sharing)
Quarkus version or git rev
3.25
Build tool (ie. output of mvnw --version
or gradlew --version
)
Gradle 8.14
Additional information
No response