VertX Sync with Router

120 views
Skip to first unread message

Jan Vladimir Mostert

unread,
Feb 16, 2017, 4:34:41 AM2/16/17
to vert.x
I'm experimenting with VertX Sync ...

A regular VertX Web setup is done like this:


vertx.createHttpServer().requestHandler { request ->
router.accept(request)
}.listen(config.getInt("application.port"))
Now If I want to use vertx sync, change it as follow:


vertx.createHttpServer().requestHandler(Sync.fiberHandler { request ->
router.accept(request)
}).listen(config.getInt("application.port"))



On startup, I'm seeing the following exception:


Exception in thread "main" java.lang.IllegalStateException: Not in context
        at io.vertx.ext.sync.Sync.getContextScheduler(Sync.java:184)
        at io.vertx.ext.sync.Sync.fiberHandler(Sync.java:147)
        at Api.main(Api.kt:108)

Can VertX Sync be used with the router ?

Lior Knaany

unread,
May 29, 2017, 6:56:37 PM5/29/17
to vert.x
Hi, Did you find an answer to this one? 
I'm having an issue which seems related.

vertx.createHttpServer(options).requestHandler(Sync.fiberHandler(createRouter()::accept)).listen(options.getPort());


get a null pointer at runtime:
01:55:20.538 [vert.x-eventloop-thread-7] ERROR com.zr.hotrod.Handlers.SearchHandler - io.vertx.core.VertxException: java.lang.NullPointerException
WARNING
: Uninstrumented methods (marked '**') or call-sites (marked '!!') detected on the call stack:
 at co
.paralleluniverse.common.util.ExtendedStackTrace.here (ExtendedStackTrace.java:44 bci: 8)
 at co
.paralleluniverse.fibers.Fiber.checkInstrumentation (Fiber.java:1626 bci: 0)
 at co
.paralleluniverse.fibers.Fiber.verifySuspend (Fiber.java:1599 bci: 6)
 at co
.paralleluniverse.fibers.Stack.popMethod (Stack.java:153 bci: 11)
 at io
.vertx.ext.sync.Sync.lambda$getContextScheduler$2(java.lang.Thread,io.vertx.core.Context,java.lang.Runnable) (Sync.java:200 bci: 165)
 at co
.paralleluniverse.fibers.FiberExecutorScheduler.execute(java.lang.Runnable) (FiberExecutorScheduler.java:77 bci: 5) **
 at co
.paralleluniverse.fibers.RunnableFiberTask.submit (RunnableFiberTask.java:289 bci: 5) **
 at co
.paralleluniverse.fibers.Fiber.start (Fiber.java:1058 bci: 62)
 at io
.vertx.ext.sync.Sync.lambda$fiberHandler$0 (Sync.java:148 bci: 15) **
 at io
.vertx.ext.web.impl.RouteImpl.handleContext (RouteImpl.java:217 bci: 12) **
 at io
.vertx.ext.web.impl.RoutingContextImplBase.iterateNext (RoutingContextImplBase.java:78 bci: 145) **
 at io
.vertx.ext.web.impl.RoutingContextImpl.next (RoutingContextImpl.java:118 bci: 1) **
 at io
.vertx.ext.web.handler.impl.TimeoutHandlerImpl.handle (TimeoutHandlerImpl.java:45 bci: 38) **
 at io
.vertx.ext.web.handler.impl.TimeoutHandlerImpl.handle (TimeoutHandlerImpl.java:27 bci: 5)
 at io
.vertx.ext.web.impl.RouteImpl.handleContext (RouteImpl.java:217 bci: 12) **
 at io
.vertx.ext.web.impl.RoutingContextImplBase.iterateNext (RoutingContextImplBase.java:78 bci: 145) **
 at io
.vertx.ext.web.impl.RoutingContextImpl.next (RoutingContextImpl.java:118 bci: 1) **
 at com
.zr.hotrod.backpressure.OOMCircuitBreaker.outOfMemorySaver (OOMCircuitBreaker.java:32 bci: 32) (optimized) !! (instrumented suspendable calls at: [])
 at io
.vertx.ext.web.impl.RouteImpl.handleContext (RouteImpl.java:217 bci: 12) **
 at io
.vertx.ext.web.impl.RoutingContextImplBase.iterateNext (RoutingContextImplBase.java:78 bci: 145) **
 at io
.vertx.ext.web.impl.RoutingContextImpl.next (RoutingContextImpl.java:118 bci: 1) **
 at com
.zr.hotrod.log.JsonLoggerHandler.handle (JsonLoggerHandler.java:43 bci: 46) **
 at com
.zr.hotrod.log.JsonLoggerHandler.handle (JsonLoggerHandler.java:23 bci: 5) (optimized)
 at io
.vertx.ext.web.impl.RouteImpl.handleContext (RouteImpl.java:217 bci: 12) **
 at io
.vertx.ext.web.impl.RoutingContextImplBase.iterateNext (RoutingContextImplBase.java:78 bci: 145) **
 at io
.vertx.ext.web.impl.RoutingContextImpl.next (RoutingContextImpl.java:118 bci: 1) **
 at io
.vertx.ext.web.impl.RouterImpl.accept (RouterImpl.java:79 bci: 79) **
 at io
.vertx.ext.sync.Sync.lambda$null$19031fba$1 (Sync.java:148 bci: 2) (optimized)
 at co
.paralleluniverse.strands.SuspendableUtils$VoidSuspendableCallable.run (SuspendableUtils.java:44 bci: 4)
 at co
.paralleluniverse.strands.SuspendableUtils$VoidSuspendableCallable.run (SuspendableUtils.java:32 bci: 1)
 at co
.paralleluniverse.fibers.Fiber.run (Fiber.java:1027 bci: 11)
 at co
.paralleluniverse.fibers.Fiber.run1 (Fiber.java:1022 bci: 1)

Tim Fox

unread,
May 30, 2017, 2:44:15 AM5/30/17
to vert.x
Do you have a reproducer?

Jan Mostert

unread,
Jun 25, 2017, 12:41:44 PM6/25/17
to vert.x
Did you setup quasar instrumentation ?

Also, if you're going to be using Fibers, remember that you need to either use Comsat libraries or do a bit of work to make these libs quasar compatible.
Also note that you can't be blocking a fibers, the point of fibers is to make async code work like synchronous code.

--
You received this message because you are subscribed to a topic in the Google Groups "vert.x" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/vertx/iBlsQj-Zny8/unsubscribe.
To unsubscribe from this group and all its topics, send an email to vertx+un...@googlegroups.com.
Visit this group at https://groups.google.com/group/vertx.
To view this discussion on the web, visit https://groups.google.com/d/msgid/vertx/b2e9e883-ebba-465e-834b-605801075110%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages