NullPointerException from vertx core in StaticHandlerImpl.getFile

274 views
Skip to first unread message

Brian Saastad

unread,
Jun 27, 2016, 1:08:14 PM6/27/16
to vert.x
We using vert.x 3.2.1.  The app is in a two-host cluster behind a load balancer, simple http server.  Sometimes it will stop honoring http requests with the following exception.  It does not happen on both hosts at the same time -- once it starts, the affected host is dead while the other continues to work fine.  Has anyone seen this except

vert.x-eventloop-thread-2] ERROR io.vertx.core.impl.ContextImpl - Unhandled exception
java.lang.NullPointerException
    at io.vertx.ext.web.impl.Utils.pathOffset(Utils.java:209)
    at io.vertx.ext.web.handler.impl.StaticHandlerImpl.getFile(StaticHandlerImpl.java:506)
    at io.vertx.ext.web.handler.impl.StaticHandlerImpl.sendStatic(StaticHandlerImpl.java:174)
    at io.vertx.ext.web.handler.impl.StaticHandlerImpl.sendDirectory(StaticHandlerImpl.java:222)
    at io.vertx.ext.web.handler.impl.StaticHandlerImpl.lambda$sendStatic$2(StaticHandlerImpl.java:191)
    at io.vertx.ext.web.handler.impl.StaticHandlerImpl$$Lambda$122/1352176477.handle(Unknown Source)
    at io.vertx.core.impl.FutureImpl.checkCallHandler(FutureImpl.java:158)
    at io.vertx.core.impl.FutureImpl.setHandler(FutureImpl.java:100)
    at io.vertx.core.impl.ContextImpl.lambda$null$16(ContextImpl.java:305)
    at io.vertx.core.impl.ContextImpl$$Lambda$24/301425080.handle(Unknown Source)
    at io.vertx.core.impl.ContextImpl.lambda$wrapTask$18(ContextImpl.java:335)
    at io.vertx.core.impl.ContextImpl$$Lambda$25/465546070.run(Unknown Source)
    at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:358)
    at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:357)
    at io.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:112)
    at java.lang.Thread.run(Thread.java:745)

Khen Ofek

unread,
Jun 28, 2016, 7:44:14 AM6/28/16
to vert.x
Yes, I also encountered this exception with 3.2.1
My setup was just a single server without load balance.

I was hoping that 3.3.0 will fix this issue.

Khen Ofek

Paulo Lopes

unread,
Jun 28, 2016, 7:57:47 AM6/28/16
to vert.x
Can you create a reproducer project so we can investigate?

Thanks!

Jody Schering

unread,
Aug 11, 2016, 2:45:52 PM8/11/16
to vert.x
I'm also seeing this issue in vertx 3.3.2 in io.vertx.ext.web.impl.Utils.pathOffset(Utils.java:214) It's failing on line 214 in the pathOffset method which is:

String routePath = context.currentRoute().getPath();

It appears the currentRoute() returns null so the getPath() fails with the NullPointerException. 

I'd be happy to to create a reproducer project but I'm not sure when or what causes this? What is this code trying to do and when is it called? I see no visible impact to the application and it seems to happen randomly.

Exception:
Aug 09, 2016 12:27:51 PM [SEVERE] io.vertx.core.impl.ContextImpl: Unhandled exception
java.lang.NullPointerException
        at io.vertx.ext.web.impl.Utils.pathOffset(Utils.java:214)
        at io.vertx.ext.web.handler.impl.StaticHandlerImpl.getFile(StaticHandlerImpl.java:518)
        at io.vertx.ext.web.handler.impl.StaticHandlerImpl.sendStatic(StaticHandlerImpl.java:176)
        at io.vertx.ext.web.handler.impl.StaticHandlerImpl.sendDirectory(StaticHandlerImpl.java:218)
        at io.vertx.ext.web.handler.impl.StaticHandlerImpl.lambda$sendStatic$0(StaticHandlerImpl.java:189)
        at io.vertx.ext.web.handler.impl.StaticHandlerImpl$$Lambda$132/2045304508.handle(Unknown Source)
        at io.vertx.core.impl.FutureImpl.checkCallHandler(FutureImpl.java:158)
        at io.vertx.core.impl.FutureImpl.setHandler(FutureImpl.java:100)
        at io.vertx.core.impl.ContextImpl.lambda$null$1(ContextImpl.java:315)
        at io.vertx.core.impl.ContextImpl$$Lambda$27/1545623630.handle(Unknown Source)
        at io.vertx.core.impl.ContextImpl.lambda$wrapTask$3(ContextImpl.java:359)
        at io.vertx.core.impl.ContextImpl$$Lambda$28/458691103.run(Unknown Source)
        at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:339)
        at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:393)
        at io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:742)
        at java.lang.Thread.run(Thread.java:745)

Code:
public static String pathOffset(String path, RoutingContext context) {
    int prefixLen = 0;
    String mountPoint = context.mountPoint();
    if (mountPoint != null) {
      prefixLen = mountPoint.length();
    }
    String routePath = context.currentRoute().getPath();
    if (routePath != null) {
      prefixLen += routePath.length() - 1;
    }
    return prefixLen != 0 ? path.substring(prefixLen) : path;
  }
Reply all
Reply to author
Forward
0 new messages