org.springframework.web.util.NestedServletException: Request processing failed; nested exception is java.lang.IllegalArgumentException: Cannot parse date value "0" for "If-Modified-Since" header

Spring JIRA | Dan Costelloe | 8 months ago
  1. 0

    Greetings, I discovered an issue recently after migrating a spring-boot application from 1.2.7.RELEASE to 1.3.3.RELEASE. After upgrading, the underlying spring-web module is spring-web:4.2.5.RELEASE. Prior to the upgrade, the version was spring-web:4.1.8.RELEASE. Client requests had previously been sending the header "If-Modified-Since: 0" wihout errors After the upgrade, same requests cause 500 server error and the following stack-trace: {code} org.springframework.web.util.NestedServletException: Request processing failed; nested exception is java.lang.IllegalArgumentException: Cannot parse date value "0" for "If-Modified-Since" header at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:980) at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:859) at javax.servlet.http.HttpServlet.service(HttpServlet.java:622) at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:844) at javax.servlet.http.HttpServlet.service(HttpServlet.java:729) at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:812) at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:587) at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:143) at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:595) at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:223) at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1127) at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:515) at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:185) at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1061) at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141) at org.eclipse.jetty.server.Dispatcher.forward(Dispatcher.java:191) at org.eclipse.jetty.server.Dispatcher.error(Dispatcher.java:77) at org.eclipse.jetty.server.handler.ErrorHandler.handle(ErrorHandler.java:92) at com.groupon.lex.service.jetty.CustomErrorHandler.handle(CustomErrorHandler.java:70) at org.eclipse.jetty.server.Response.sendError(Response.java:597) at org.eclipse.jetty.server.Response.sendError(Response.java:544) at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:647) at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:143) at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:577) at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:223) at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1127) at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:515) at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:185) at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1061) at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141) at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:97) at org.eclipse.jetty.server.handler.RequestLogHandler.handle(RequestLogHandler.java:95) at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:97) at org.eclipse.jetty.server.Server.handle(Server.java:499) at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:311) at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:257) at org.eclipse.jetty.io.AbstractConnection$2.run(AbstractConnection.java:544) at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:635) at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:555) at java.lang.Thread.run(Thread.java:745) Caused by: java.lang.IllegalArgumentException: Cannot parse date value "0" for "If-Modified-Since" header at org.springframework.http.HttpHeaders.getFirstDate(HttpHeaders.java:970) at org.springframework.http.HttpHeaders.getIfModifiedSince(HttpHeaders.java:805) at org.springframework.web.servlet.mvc.method.annotation.HttpEntityMethodProcessor.isResourceNotModified(HttpEntityMethodProcessor.java:191) at org.springframework.web.servlet.mvc.method.annotation.HttpEntityMethodProcessor.handleReturnValue(HttpEntityMethodProcessor.java:173) at org.springframework.web.method.support.HandlerMethodReturnValueHandlerComposite.handleReturnValue(HandlerMethodReturnValueHandlerComposite.java:80) at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:126) at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:817) at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:731) at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:85) at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:959) at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:893) at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:968) ... 39 common frames omitted {code} It seems that a question about this issue has also been asked on StackOverflow: http://stackoverflow.com/questions/33806370/spring-boot-throwing-exception-on-invalid-if-modified-since-value I'm currently working around the issue using a filter which removes the problematic header, however it looks (to my eyes at least) like a fairly straightforward fix could be implemented in HttpHeaders.java I've forked the codebase and will submit a PR once JIRA gives me a ticket ID.

    Spring JIRA | 8 months ago | Dan Costelloe
    org.springframework.web.util.NestedServletException: Request processing failed; nested exception is java.lang.IllegalArgumentException: Cannot parse date value "0" for "If-Modified-Since" header
  2. 0

    Greetings, I discovered an issue recently after migrating a spring-boot application from 1.2.7.RELEASE to 1.3.3.RELEASE. After upgrading, the underlying spring-web module is spring-web:4.2.5.RELEASE. Prior to the upgrade, the version was spring-web:4.1.8.RELEASE. Client requests had previously been sending the header "If-Modified-Since: 0" wihout errors After the upgrade, same requests cause 500 server error and the following stack-trace: {code} org.springframework.web.util.NestedServletException: Request processing failed; nested exception is java.lang.IllegalArgumentException: Cannot parse date value "0" for "If-Modified-Since" header at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:980) at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:859) at javax.servlet.http.HttpServlet.service(HttpServlet.java:622) at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:844) at javax.servlet.http.HttpServlet.service(HttpServlet.java:729) at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:812) at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:587) at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:143) at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:595) at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:223) at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1127) at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:515) at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:185) at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1061) at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141) at org.eclipse.jetty.server.Dispatcher.forward(Dispatcher.java:191) at org.eclipse.jetty.server.Dispatcher.error(Dispatcher.java:77) at org.eclipse.jetty.server.handler.ErrorHandler.handle(ErrorHandler.java:92) at com.groupon.lex.service.jetty.CustomErrorHandler.handle(CustomErrorHandler.java:70) at org.eclipse.jetty.server.Response.sendError(Response.java:597) at org.eclipse.jetty.server.Response.sendError(Response.java:544) at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:647) at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:143) at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:577) at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:223) at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1127) at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:515) at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:185) at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1061) at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141) at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:97) at org.eclipse.jetty.server.handler.RequestLogHandler.handle(RequestLogHandler.java:95) at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:97) at org.eclipse.jetty.server.Server.handle(Server.java:499) at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:311) at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:257) at org.eclipse.jetty.io.AbstractConnection$2.run(AbstractConnection.java:544) at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:635) at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:555) at java.lang.Thread.run(Thread.java:745) Caused by: java.lang.IllegalArgumentException: Cannot parse date value "0" for "If-Modified-Since" header at org.springframework.http.HttpHeaders.getFirstDate(HttpHeaders.java:970) at org.springframework.http.HttpHeaders.getIfModifiedSince(HttpHeaders.java:805) at org.springframework.web.servlet.mvc.method.annotation.HttpEntityMethodProcessor.isResourceNotModified(HttpEntityMethodProcessor.java:191) at org.springframework.web.servlet.mvc.method.annotation.HttpEntityMethodProcessor.handleReturnValue(HttpEntityMethodProcessor.java:173) at org.springframework.web.method.support.HandlerMethodReturnValueHandlerComposite.handleReturnValue(HandlerMethodReturnValueHandlerComposite.java:80) at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:126) at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:817) at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:731) at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:85) at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:959) at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:893) at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:968) ... 39 common frames omitted {code} It seems that a question about this issue has also been asked on StackOverflow: http://stackoverflow.com/questions/33806370/spring-boot-throwing-exception-on-invalid-if-modified-since-value I'm currently working around the issue using a filter which removes the problematic header, however it looks (to my eyes at least) like a fairly straightforward fix could be implemented in HttpHeaders.java I've forked the codebase and will submit a PR once JIRA gives me a ticket ID.

    Spring JIRA | 8 months ago | Dan Costelloe
    org.springframework.web.util.NestedServletException: Request processing failed; nested exception is java.lang.IllegalArgumentException: Cannot parse date value "0" for "If-Modified-Since" header
  3. 0

    new RequestSpecBuilder().addHeader - Can we use variable to specify the value?

    Google Groups | 6 months ago | Anil Shekhar
    java.lang.IllegalArgumentException: Header value cannot be null
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    new RequestSpecBuilder().addHeader - Can we use variable to specify the value?

    Google Groups | 6 months ago | Anil Shekhar
    java.lang.IllegalArgumentException: Header value cannot be null
  6. 0

    new RequestSpecBuilder().addHeader - Can we use variable to specify the value?

    Google Groups | 6 months ago | Anil Shekhar
    java.lang.IllegalArgumentException: Header value cannot be null

    Not finding the right solution?
    Take a tour to get the most out of Samebug.

    Tired of useless tips?

    Automated exception search integrated into your IDE

    Root Cause Analysis

    1. java.lang.IllegalArgumentException

      Cannot parse date value "0" for "If-Modified-Since" header

      at org.springframework.http.HttpHeaders.getFirstDate()
    2. Spring
      HttpHeaders.getIfModifiedSince
      1. org.springframework.http.HttpHeaders.getFirstDate(HttpHeaders.java:970)
      2. org.springframework.http.HttpHeaders.getIfModifiedSince(HttpHeaders.java:805)
      2 frames
    3. Spring MVC
      HttpEntityMethodProcessor.handleReturnValue
      1. org.springframework.web.servlet.mvc.method.annotation.HttpEntityMethodProcessor.isResourceNotModified(HttpEntityMethodProcessor.java:191)
      2. org.springframework.web.servlet.mvc.method.annotation.HttpEntityMethodProcessor.handleReturnValue(HttpEntityMethodProcessor.java:173)
      2 frames
    4. Spring
      HandlerMethodReturnValueHandlerComposite.handleReturnValue
      1. org.springframework.web.method.support.HandlerMethodReturnValueHandlerComposite.handleReturnValue(HandlerMethodReturnValueHandlerComposite.java:80)
      1 frame
    5. Spring MVC
      FrameworkServlet.doGet
      1. org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:126)
      2. org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:817)
      3. org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:731)
      4. org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:85)
      5. org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:959)
      6. org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:893)
      7. org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:968)
      8. org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:859)
      8 frames
    6. JavaServlet
      HttpServlet.service
      1. javax.servlet.http.HttpServlet.service(HttpServlet.java:622)
      1 frame
    7. Spring MVC
      FrameworkServlet.service
      1. org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:844)
      1 frame
    8. JavaServlet
      HttpServlet.service
      1. javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
      1 frame
    9. Jetty
      ErrorHandler.handle
      1. org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:812)
      2. org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:587)
      3. org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:143)
      4. org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:595)
      5. org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:223)
      6. org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1127)
      7. org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:515)
      8. org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:185)
      9. org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1061)
      10. org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141)
      11. org.eclipse.jetty.server.Dispatcher.forward(Dispatcher.java:191)
      12. org.eclipse.jetty.server.Dispatcher.error(Dispatcher.java:77)
      13. org.eclipse.jetty.server.handler.ErrorHandler.handle(ErrorHandler.java:92)
      13 frames
    10. com.groupon.lex
      CustomErrorHandler.handle
      1. com.groupon.lex.service.jetty.CustomErrorHandler.handle(CustomErrorHandler.java:70)
      1 frame
    11. Jetty
      QueuedThreadPool$3.run
      1. org.eclipse.jetty.server.Response.sendError(Response.java:597)
      2. org.eclipse.jetty.server.Response.sendError(Response.java:544)
      3. org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:647)
      4. org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:143)
      5. org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:577)
      6. org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:223)
      7. org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1127)
      8. org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:515)
      9. org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:185)
      10. org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1061)
      11. org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141)
      12. org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:97)
      13. org.eclipse.jetty.server.handler.RequestLogHandler.handle(RequestLogHandler.java:95)
      14. org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:97)
      15. org.eclipse.jetty.server.Server.handle(Server.java:499)
      16. org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:311)
      17. org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:257)
      18. org.eclipse.jetty.io.AbstractConnection$2.run(AbstractConnection.java:544)
      19. org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:635)
      20. org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:555)
      20 frames
    12. Java RT
      Thread.run
      1. java.lang.Thread.run(Thread.java:745)
      1 frame