Description
ContextHandler(anyHandler) NPE during . logging call 'because "this._vhosts" is null'
Happens in the constructor when given any handler, including several examples from Jetty 12 docs.
Does not happen if handler is omitted, i.e. new ContextHandler()
How to reproduce?
public static void main(String[] args) throws Exception {
ContextHandler simpleContextHandler = new ContextHandler(new Handler.Abstract.NonBlocking() {
@Override
public boolean handle(Request request, Response response, Callback callback){
callback.succeeded();
return true;
}
});
}
IDE: Eclipse 23, configured via maven dependencies
VM arguments:
-DJETTY_HOME=/Users/bill/Documents/workspace/worktracks -- this is irrelevant
Log/Stacktrace:
SLF4J(E): Failed toString() invocation on an object of type [org.eclipse.jetty.server.handler.ContextHandler]
SLF4J(E): Reported exception:
java.lang.NullPointerException: Cannot invoke "java.util.List.stream()" because "this._vhosts" is null
at org.eclipse.jetty.server.handler.ContextHandler.getVirtualHosts(ContextHandler.java:391)
at org.eclipse.jetty.server.handler.ContextHandler.toString(ContextHandler.java:1032)
at org.slf4j.helpers.MessageFormatter.safeObjectAppend(MessageFormatter.java:291)
at org.slf4j.helpers.MessageFormatter.deeplyAppendParameter(MessageFormatter.java:263)
at org.slf4j.helpers.MessageFormatter.arrayFormat(MessageFormatter.java:225)
at org.slf4j.helpers.MessageFormatter.arrayFormat(MessageFormatter.java:160)
at ch.qos.logback.classic.spi.LoggingEvent.getFormattedMessage(LoggingEvent.java:397)
at ch.qos.logback.classic.spi.LoggingEvent.prepareForDeferredProcessing(LoggingEvent.java:253)
at ch.qos.logback.core.OutputStreamAppender.subAppend(OutputStreamAppender.java:226)
at ch.qos.logback.core.OutputStreamAppender.append(OutputStreamAppender.java:102)
at ch.qos.logback.core.UnsynchronizedAppenderBase.doAppend(UnsynchronizedAppenderBase.java:85)
at ch.qos.logback.core.spi.AppenderAttachableImpl.appendLoopOnAppenders(AppenderAttachableImpl.java:51)
at ch.qos.logback.classic.Logger.appendLoopOnAppenders(Logger.java:272)
at ch.qos.logback.classic.Logger.callAppenders(Logger.java:259)
at ch.qos.logback.classic.Logger.buildLoggingEventAndAppend(Logger.java:426)
at ch.qos.logback.classic.Logger.filterAndLog_2(Logger.java:419)
at ch.qos.logback.classic.Logger.debug(Logger.java:495)
at org.eclipse.jetty.util.component.ContainerLifeCycle.addBean(ContainerLifeCycle.java:419)
at org.eclipse.jetty.util.component.ContainerLifeCycle.addBean(ContainerLifeCycle.java:317)
at org.eclipse.jetty.util.component.ContainerLifeCycle.updateBean(ContainerLifeCycle.java:802)
at org.eclipse.jetty.server.Handler$Singleton.updateHandler(Handler.java:397)
at org.eclipse.jetty.server.Handler$Wrapper.<init>(Handler.java:695)
at org.eclipse.jetty.server.Handler$Wrapper.<init>(Handler.java:682)
at org.eclipse.jetty.server.handler.ContextHandler.<init>(ContextHandler.java:177)
at org.eclipse.jetty.server.handler.ContextHandler.<init>(ContextHandler.java:167)
at worktrack.WorktracksServer.main(WorktracksServer.java:41)
Jetty version(s) 12.0.5
Jetty Environment core
Java version/vendor openjdk version "21.0.1" 2023-10-17 OpenJDK Runtime Environment (build 21.0.1+12-29)
Mac OS Big Sur
Description ContextHandler(anyHandler) NPE during . logging call 'because "this._vhosts" is null'
Happens in the constructor when given any handler, including several examples from Jetty 12 docs.
Does not happen if handler is omitted, i.e. new ContextHandler()
How to reproduce?
IDE: Eclipse 23, configured via maven dependencies
VM arguments:
-DJETTY_HOME=/Users/bill/Documents/workspace/worktracks
-- this is irrelevantLog/Stacktrace:
Imports: