Skip to content

Can not post body to custom management endpoint in DEV mode #48151

@lschmierer

Description

@lschmierer

Describe the bug

Hi, I am trying to accept simple plain/text on a post endpoint.

class Management {
    fun registerManagementRoutes(@Observes mi: ManagementInterface) {
        mi.router()
            .post("/test")
            // .handler(BodyHandler.create()) // does not change anything
            .handler { rc: RoutingContext ->
                val message = rc.body().asString()
                rc.response().end("Received: $message")
            }
    }
}

Expected behavior

curl -X POST http://localhost:9000/test -H "Content-Type: plain/text" -d hello --verbose

should return "Received: hello"

Actual behavior

Running

curl -X POST http://localhost:9000/test -H "Content-Type: plain/text" -d hello --verbose

the server just does not accepts or routes the request, my handler is never called.

curl -X POST http://localhost:9000/test -H "Content-Type: application/x-www-form-urlencoded" -d hello --verbose

on the other hand gives

Note: Unnecessary use of -X or --request, POST is already inferred.
*   Trying [::1]:9000...
* connect to ::1 port 9000 failed: Connection refused
*   Trying 127.0.0.1:9000...
* Connected to localhost (127.0.0.1) port 9000
> POST /test HTTP/1.1
> Host: localhost:9000
> User-Agent: curl/8.4.0
> Accept: */*
> Content-Type: application/x-www-form-urlencoded
> Content-Length: 5
> 
< HTTP/1.1 500 Internal Server Error
< content-type: text/plain; charset=utf-8
< content-length: 2402
< 

500 - Internal Server Error
---------------------------

Details:
        Error id d1513df2-a061-4b0e-990b-f3b72f260633-1, java.lang.IllegalStateException: Request has already been read
Stack:
        java.lang.IllegalStateException: Request has already been read
        at io.vertx.core.http.impl.Http1xServerRequest.checkEnded(Http1xServerRequest.java:733)
        at io.vertx.core.http.impl.Http1xServerRequest.setExpectMultipart(Http1xServerRequest.java:522)
        at io.vertx.core.http.impl.HttpServerRequestWrapper.setExpectMultipart(HttpServerRequestWrapper.java:190)
        at io.vertx.core.http.impl.HttpServerRequestWrapper.setExpectMultipart(HttpServerRequestWrapper.java:190)
        at io.vertx.ext.web.handler.impl.BodyHandlerImpl$BHandler.<init>(BodyHandlerImpl.java:230)
        at io.vertx.ext.web.handler.impl.BodyHandlerImpl.handle(BodyHandlerImpl.java:126)
        at io.vertx.ext.web.handler.impl.BodyHandlerImpl.handle(BodyHandlerImpl.java:45)
        at io.quarkus.vertx.http.runtime.VertxHttpRecorder$18.handle(VertxHttpRecorder.java:1622)
        at io.quarkus.vertx.http.runtime.VertxHttpRecorder$18.handle(VertxHttpRecorder.java:1593)
        at io.vertx.ext.web.impl.RouteState.handleContext(RouteState.java:1283)
        at io.vertx.ext.web.impl.RoutingContextImplBase.iterateNext(RoutingContextImplBase.java:177)
        at io.vertx.ext.web.impl.RoutingContextImpl.next(RoutingContextImpl.java:151)
        at io.quarkus.vertx.http.runtime.devmode.VertxHttpHotReplacementSetup$5.handle(VertxHttpHotReplacementSetup.java:206)
        at io.quarkus.vertx.http.runtime.devmode.VertxHttpHotReplacementSetup$5.handle(VertxHttpHotReplacementSetup.java:194)
        at io.vertx.core.impl.future.FutureImpl$4.onSuccess(FutureImpl.java:176)
        at io.vertx.core.impl.future.FutureBase.lambda$emitSuccess$0(FutureBase.java:60)
        at io.netty.util.concurrent.AbstractEventExecutor.runTask(AbstractEventExecutor.java:173)
        at io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:166)
        at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:472)
        at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:569)
        at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:998)
        at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
        at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
        at java.base/java.lang.Thread.run(Thread.java:1583)
* Connection #0 to host localhost left intact

How to Reproduce?

quarkus-management-vertx.zip

Output of uname -a or ver

Darwin DaMac-J9QVF643HM 23.4.0 Darwin Kernel Version 23.4.0: Wed Feb 21 21:44:54 PST 2024; root:xnu-10063.101.15~2/RELEASE_ARM64_T6030 arm64

Output of java -version

openjdk version "22.0.2" 2024-07-16 OpenJDK Runtime Environment (build 22.0.2+9-70) OpenJDK 64-Bit Server VM (build 22.0.2+9-70, mixed mode, sharing)

Quarkus version or git rev

reproduced on 3.15, 3.20, 3.23

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

------------------------------------------------------------ Gradle 8.13 ------------------------------------------------------------ Build time: 2025-02-25 09:22:14 UTC Revision: 073314332697ba45c16c0a0ce1891fa6794179ff Kotlin: 2.0.21 Groovy: 3.0.22 Ant: Apache Ant(TM) version 1.10.15 compiled on August 25 2024 Launcher JVM: 22.0.2 (Oracle Corporation 22.0.2+9-70) Daemon JVM: /Users/lukas.schmierer/Library/Java/JavaVirtualMachines/openjdk-22.0.2/Contents/Home (no JDK specified, using current Java home) OS: Mac OS X 14.4 aarch64

Additional information

No response

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