-
Bug
-
Resolution: Done
-
Major
-
2.2.0.GA, 2.3.1
-
None
-
-
Low
I also checked 2.3.1 version and the same code is present there as well as in 2.2.0.ga.
org.jboss.resteasy.spi.UnhandledException: java.lang.NullPointerException at org.jboss.resteasy.core.SynchronousDispatcher.writeFailure(SynchronousDispatcher.java:429) at org.jboss.resteasy.core.SynchronousDispatcher.executeExceptionMapper(SynchronousDispatcher.java:313) at org.jboss.resteasy.core.SynchronousDispatcher.handleReaderException(SynchronousDispatcher.java:392) at org.jboss.resteasy.core.SynchronousDispatcher.handleException(SynchronousDispatcher.java:222) at org.jboss.resteasy.core.SynchronousDispatcher.handleInvokerException(SynchronousDispatcher.java:190) at org.jboss.resteasy.core.SynchronousDispatcher.getResponse(SynchronousDispatcher.java:534) at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:496) at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:119) at org.jboss.resteasy.plugins.server.servlet.ServletContainerDispatcher.service(ServletContainerDispatcher.java:208) at org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:55) at org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:50) at javax.servlet.http.HttpServlet.service(HttpServlet.java:717) ... Caused by: java.lang.NullPointerException at org.jboss.resteasy.core.SynchronousDispatcher.writeJaxrsResponse(SynchronousDispatcher.java:563) at org.jboss.resteasy.core.SynchronousDispatcher.writeFailure(SynchronousDispatcher.java:416) ... 44 more
The problem is following in SynchronousDispatcher.java:
public boolean executeExceptionMapper(HttpRequest request, HttpResponse response, Throwable exception) writeFailure(request, response, mapper.toResponse(exception)); // returns null what is allowed according to the ExceptionMapper.toResponse javadoc protected void writeFailure(HttpRequest request, HttpResponse response, Response jaxrsResponse) writeJaxrsResponse(request, response, jaxrsResponse); // calls writeJaxrsResponse without a null-pointer check protected void writeJaxrsResponse(HttpRequest request, HttpResponse response, Response jaxrsResponse) throws WriterException Object type = jaxrsResponse.getMetadata().getFirst( // jaxrsResponse is null, NPE is thrown HttpHeaderNames.CONTENT_TYPE);