@Test public void shouldGive400OnInvalidLongConversion() throws IOException { FakeServletRequest request = new FakeServletRequest("POST", contextRoot, "/api", "/withLong"); request.setParameter("longValue", "one hundred"); expectedLogEvents.expect(ApiControllerAction.class, Level.DEBUG, "While processing ServletHttpExchange[POST " + contextRoot + "/api/withLong?longValue=one+hundred] arguments to " + "ApiControllerMethodAction{POST /withLong => ControllerWithTypedParameters.methodWithLong(long)}: " + new HttpRequestException("Could not convert longValue=one hundred to long")); servlet.service(request, response); assertThat(response.getStatus()).isEqualTo(400); assertThat(response.getStatusMessage()).contains("Could not convert longValue=one hundred to long"); }
@Override protected void service(HttpServletRequest req, HttpServletResponse resp) throws IOException { try ( MDC.MDCCloseable ignored = MDC.putCloseable("clientIp", req.getRemoteAddr()); MDC.MDCCloseable ignored2 = MDC.putCloseable("requestPath", req.getContextPath() + req.getServletPath() + req.getPathInfo()) ) { controllerException.verifyNoExceptions(); invokeAction(new ServletHttpExchange(req, resp)); } }
ApiServlet extends HttpServlet implements UserContext { @Override protected void service(HttpServletRequest req, HttpServletResponse resp) throws IOException { try ( MDC.MDCCloseable ignored = MDC.putCloseable("clientIp", req.getRemoteAddr()); MDC.MDCCloseable ignored2 = MDC.putCloseable("requestPath", req.getContextPath() + req.getServletPath() + req.getPathInfo()) ) { controllerException.verifyNoExceptions(); invokeAction(new ServletHttpExchange(req, resp)); } } }
ApiServlet extends HttpServlet implements UserContext { @Override protected void service(HttpServletRequest req, HttpServletResponse resp) throws IOException { try ( MDC.MDCCloseable ignored = MDC.putCloseable("clientIp", req.getRemoteAddr()); MDC.MDCCloseable ignored2 = MDC.putCloseable("requestPath", req.getContextPath() + req.getServletPath() + req.getPathInfo()) ) { controllerException.verifyNoExceptions(); invokeAction(new ServletHttpExchange(req, resp)); } } ApiServlet();  ApiServlet(Object controller); }
ApiServlet extends HttpServlet implements UserContext { @Override protected void service(HttpServletRequest req, HttpServletResponse resp) throws IOException { try ( MDC.MDCCloseable ignored = MDC.putCloseable("clientIp", req.getRemoteAddr()); MDC.MDCCloseable ignored2 = MDC.putCloseable("requestPath", req.getContextPath() + req.getServletPath() + req.getPathInfo()) ) { controllerException.verifyNoExceptions(); invokeAction(new ServletHttpExchange(req, resp)); } } ApiServlet();  ApiServlet(Object controller); ApiControllerContext getContext(); @Override boolean isUserLoggedIn(ApiHttpExchange exchange); @Override boolean isUserInRole(ApiHttpExchange exchange, String role); void registerController(Object controller); void registerControllers(Object... controllers); void registerControllerList(List<Object> controllers); @Override void init(ServletConfig config); void registerMBeans(); void registerMBeans(MBeanServer mBeanServer); @Override TimerRegistry getTimerRegistry(); void setTimerRegistry(TimerRegistry timerRegistry); }
ApiServlet extends HttpServlet implements UserContext { @Override protected void service(HttpServletRequest req, HttpServletResponse resp) throws IOException { try ( MDC.MDCCloseable ignored = MDC.putCloseable("clientIp", req.getRemoteAddr()); MDC.MDCCloseable ignored2 = MDC.putCloseable("requestPath", req.getContextPath() + req.getServletPath() + req.getPathInfo()) ) { controllerException.verifyNoExceptions(); invokeAction(new ServletHttpExchange(req, resp)); } } ApiServlet();  ApiServlet(Object controller); ApiControllerContext getContext(); @Override boolean isUserLoggedIn(ApiHttpExchange exchange); @Override boolean isUserInRole(ApiHttpExchange exchange, String role); void registerController(Object controller); void registerControllers(Object... controllers); void registerControllerList(List<Object> controllers); @Override void init(ServletConfig config); void registerMBeans(); void registerMBeans(MBeanServer mBeanServer); @Override TimerRegistry getTimerRegistry(); void setTimerRegistry(TimerRegistry timerRegistry);  }