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.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;
}