BlockingHandler causes Response has already been written

267 views
Skip to first unread message

i...@bluerbn.com

unread,
Dec 28, 2017, 1:07:09 PM12/28/17
to vert.x
Hello,

I had a normal route handler (non blocking) that worked perfectly fine.

Once I chagned it to blockingHandler - it started throwing this exception :


:02:42.706 ERROR i.v.e.w.i.RoutingContextImplBase:104 - Unexpected exception in route
java
.lang.IllegalStateException: Response has already been written
 at io
.vertx.core.http.impl.HttpServerResponseImpl.checkWritten(HttpServerResponseImpl.java:576)
 at io
.vertx.core.http.impl.HttpServerResponseImpl.putHeader(HttpServerResponseImpl.java:158)
 at io
.vertx.core.http.impl.HttpServerResponseImpl.putHeader(HttpServerResponseImpl.java:55)
 at com
.bluerbn.commons.config.vertx.HttpServerVerticle.respond(HttpServerVerticle.java:136)
 at com
.bluerbn.commons.config.vertx.HttpServerVerticle.reportFailure(HttpServerVerticle.java:131)
 at io
.vertx.ext.web.impl.RouteImpl.handleFailure(RouteImpl.java:223)
 at io
.vertx.ext.web.impl.RoutingContextImplBase.iterateNext(RoutingContextImplBase.java:76)
 at io
.vertx.ext.web.impl.RoutingContextImpl.next(RoutingContextImpl.java:118)
 at io
.vertx.ext.web.impl.RoutingContextImpl.doFail(RoutingContextImpl.java:408)
 at io
.vertx.ext.web.impl.RoutingContextImpl.fail(RoutingContextImpl.java:151)
 at io
.vertx.ext.web.impl.BlockingHandlerDecorator.lambda$handle$1(BlockingHandlerDecorator.java:53)
 at io
.vertx.core.impl.FutureImpl.checkCallHandler(FutureImpl.java:188)
 at io
.vertx.core.impl.FutureImpl.setHandler(FutureImpl.java:100)
 at io
.vertx.core.impl.ContextImpl.lambda$null$0(ContextImpl.java:287)
 at io
.vertx.core.impl.ContextImpl.lambda$wrapTask$2(ContextImpl.java:337)
 at io
.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:163)
 at io
.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:403)
 at io
.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:445)
 at io
.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:858)
 at java
.lang.Thread.run(Thread.java:748)


This is the code:
router.get("/api/wallets/:id").blockingHandler(this::getById, false);


 
private void getById(RoutingContext routingContext) {
       
String id = routingContext.request().getParam("id");
       
       
Entity entity = dao.getById(id);
       
Dto dto =  convertEntityToDto(entity);
        routingContext
.response().setStatusCode(HttpStatus.OK.value()).end(CodecUtils.toJson(dto));
     
 
}

The dao executes SELECT to MySql using hiberante.  (Blocking code).

Any ideas?
Could it be timeout issue?

Regards,
Ido 

Jez P

unread,
Dec 28, 2017, 1:42:45 PM12/28/17
to vert.x
Without seeing more of your code, anyone would be guessing. Could you share a simple reproducer via GitHub?
Reply all
Reply to author
Forward
0 new messages