0

我正在使用“vert.x”创建一个除了“Content-Type:application/x-www-form-urlencoded”之外的发布请求。并得到“路由 java.lang.NullPointerException 中的意外异常”,但是当我删除内容类型时,相同的请求工作正常。

我正在使用 vert.x 3.3.3 并尝试使用垂直创建路线。

Router router = Router.router(vertx);

```
//--- 
router.post("/sample-api").handler(new myHandler());

   // This allows post with content-type "application/json" and "Unexpected 
   // exception in route java.lang.NullPointerException" error with 
   // "application/x-www-form-urlencoded"


//---
router.route(HttpMethod.POST, "/sample-api").consumes("application/x-www-form-urlencoded").handler(new myHandler());

   // This gives 404 on the post with content-type "application/json" and 
   // "Unexpected exception in route java.lang.NullPointerException" error 
   // with "application/x-www-form-urlencoded"
Error msg with content-type : application/x-www-form-urlencoded

    Unexpected exception in route java.lang.NullPointerException
            at java.util.Objects.requireNonNull(Objects.java:203)
            at io.vertx.core.file.impl.FileSystemImpl.existsInternal(FileSystemImpl.java:772)
            at io.vertx.core.file.impl.FileSystemImpl.existsBlocking(FileSystemImpl.java:333)
            at io.vertx.ext.web.handler.impl.BodyHandlerImpl$BHandler.makeUploadDir(BodyHandlerImpl.java:141)
            at io.vertx.ext.web.handler.impl.BodyHandlerImpl$BHandler.<init>(BodyHandlerImpl.java:124)
            at io.vertx.ext.web.handler.impl.BodyHandlerImpl.handle(BodyHandlerImpl.java:65)
            at io.vertx.ext.web.handler.impl.BodyHandlerImpl.handle(BodyHandlerImpl.java:40)
            at io.vertx.ext.web.impl.RouteImpl.handleContext(RouteImpl.java:215)
            at io.vertx.ext.web.impl.RoutingContextImplBase.iterateNext(RoutingContextImplBase.java:78)
            at io.vertx.ext.web.impl.RoutingContextImpl.next(RoutingContextImpl.java:94)
            at io.vertx.ext.web.impl.RouterImpl.accept(RouterImpl.java:79)
            at io.vertx.core.http.impl.ServerConnection.handleRequest(ServerConnection.java:286)

    with status 500

    expected value:

    Status 200



*** Request working fine with other headers.


Header --- --- ----
host: randomHost
Accept: */*
User-Agent: random/1.0
X-Signature: randomSignature
Connection: keep-alive
Content-Type:application/x-www-form-urlencoded

4

0 回答 0