Uploaded image for project: 'Undertow'
  1. Undertow
  2. UNDERTOW-1777

Request attributes cleared before servlet filter completes running.

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: Major Major
    • None
    • 2.1.2.Final, 2.1.3.Final
    • Servlet
    • None
    • Hide

       

      1. Set an attribute into the request to be referenced later
      2. Read attribute from request in a servlet filter

       

      Attribute will not be present.

      Show
        Set an attribute into the request to be referenced later Read attribute from request in a servlet filter   Attribute will not be present.

      Request attributes can be cleared before servlet filters have completed running. This appeared in 2.1.2.Final. I think this was introduced here:

      https://github.com/undertow-io/undertow/commit/41501ac05dbb963c912216cdb9cfb3e175ee3bd4

      And is a recurrence of this: https://issues.redhat.com/browse/UNDERTOW-1573

      I think it's more significant though because the servlet filter has not completed running when attributes are cleared? Also no request body was present, I hit this with a GET call.

      Example of what triggered the problem:
       

      public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
        try {
               request.setAttribute("REQUEST_START_NANOS", System.nanoTime());
        } finally {
               // unboxing triggers an NPE
               long start = (long)request.getAttribute("REQUEST_START_NANOS");
               log.info("Request duration={}", System.nanoTime() - start);
        }
      }
      

       

              ropalka Richard Opalka
              safetytrick Michael Nielson (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Created:
                Updated:
                Resolved: