-
Bug
-
Resolution: Unresolved
-
Major
-
None
-
2.3.12.Final
ServletNameAttribute (%{SERVLET_NAME}) can be added to access log format to output the servlet name which handled for the request.
However, it can throw NullPointerException (NPE) when a request is not handled by the servlet application (for example, a request is handled by Undertow Handler like file handler in WildFly/JBoss EAP configuration). And no log entry is output to the access log when NPE occurs.
ERROR [io.undertow.request] (default task-1) UT005071: Undertow request failed HttpServerExchange{ GET /}: java.lang.NullPointerException at io.undertow.servlet@2.3.10.Final//io.undertow.servlet.attribute.ServletNameAttribute.readAttribute(ServletNameAttribute.java:46) at io.undertow.core@2.3.10.Final//io.undertow.attribute.SubstituteEmptyWrapper$SubstituteEmptyAttribute.readAttribute(SubstituteEmptyWrapper.java:32) at io.undertow.core@2.3.10.Final//io.undertow.attribute.CompositeExchangeAttribute.readAttribute(CompositeExchangeAttribute.java:42) at io.undertow.core@2.3.10.Final//io.undertow.server.handlers.accesslog.AccessLogHandler$AccessLogCompletionListener.exchangeEvent(AccessLogHandler.java:156) at io.undertow.core@2.3.10.Final//io.undertow.server.HttpServerExchange$ExchangeCompleteNextListener.proceed(HttpServerExchange.java:1983) at org.wildfly.extension.undertow@31.0.0.Final//org.wildfly.extension.undertow.deployment.GlobalRequestControllerHandler$1.exchangeEvent(GlobalRequestControllerHandler.java:36) at io.undertow.core@2.3.10.Final//io.undertow.server.HttpServerExchange.invokeExchangeCompleteListeners(HttpServerExchange.java:1358) at io.undertow.core@2.3.10.Final//io.undertow.server.HttpServerExchange.terminateResponse(HttpServerExchange.java:1646) at io.undertow.core@2.3.10.Final//io.undertow.server.Connectors.terminateResponse(Connectors.java:182) at io.undertow.core@2.3.10.Final//io.undertow.server.protocol.http.ServerFixedLengthStreamSinkConduit.channelFinished(ServerFixedLengthStreamSinkConduit.java:58) at io.undertow.core@2.3.10.Final//io.undertow.conduits.AbstractFixedLengthStreamSinkConduit.exitFlush(AbstractFixedLengthStreamSinkConduit.java:316) at io.undertow.core@2.3.10.Final//io.undertow.conduits.AbstractFixedLengthStreamSinkConduit.flush(AbstractFixedLengthStreamSinkConduit.java:234) at org.jboss.xnio@3.8.12.Final//org.xnio.conduits.ConduitStreamSinkChannel.flush(ConduitStreamSinkChannel.java:162) at io.undertow.core@2.3.10.Final//io.undertow.channels.DetachableStreamSinkChannel.flush(DetachableStreamSinkChannel.java:119) at io.undertow.core@2.3.10.Final//io.undertow.io.AsyncSenderImpl.close(AsyncSenderImpl.java:376) at io.undertow.core@2.3.10.Final//io.undertow.io.DefaultIoCallback.onComplete(DefaultIoCallback.java:54) at io.undertow.core@2.3.10.Final//io.undertow.server.handlers.resource.PathResource$1ServerTask.run(PathResource.java:186) at io.undertow.core@2.3.10.Final//io.undertow.server.handlers.resource.PathResource$1ServerTask.onComplete(PathResource.java:209) at io.undertow.core@2.3.10.Final//io.undertow.io.AsyncSenderImpl.invokeOnComplete(AsyncSenderImpl.java:435) at io.undertow.core@2.3.10.Final//io.undertow.io.AsyncSenderImpl.send(AsyncSenderImpl.java:192) at io.undertow.core@2.3.10.Final//io.undertow.server.handlers.resource.PathResource$1ServerTask.run(PathResource.java:196) at io.undertow.core@2.3.10.Final//io.undertow.server.handlers.resource.PathResource.serveImpl(PathResource.java:265) at io.undertow.core@2.3.10.Final//io.undertow.server.handlers.resource.PathResource.serve(PathResource.java:121) at io.undertow.core@2.3.10.Final//io.undertow.server.handlers.resource.ResourceHandler$1.handleRequest(ResourceHandler.java:337) at io.undertow.core@2.3.10.Final//io.undertow.server.Connectors.executeRootHandler(Connectors.java:393) at io.undertow.core@2.3.10.Final//io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:859) at org.jboss.threads@2.4.0.Final//org.jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35) at org.jboss.threads@2.4.0.Final//org.jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:1990) at org.jboss.threads@2.4.0.Final//org.jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1486) at org.jboss.threads@2.4.0.Final//org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1348) at org.jboss.xnio@3.8.12.Final//org.xnio.XnioWorker$WorkerThreadFactory$1$1.run(XnioWorker.java:1282) at java.base/java.lang.Thread.run(Thread.java:829)
It should not throw NPE. It should output just "-" when the request not handled by the servlet application.