Uploaded image for project: 'WildFly'
  1. WildFly
  2. WFLY-3474

NPE in HttpServletResponse.getHeaders

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • Major
    • 9.0.0.Alpha1
    • 8.0.0.Final, 8.1.0.Final
    • Web (Undertow)
    • None
    • Hide
      public class TestServlet extends HttpServlet {
      
          @Override
          protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
              resp.setHeader("Foo", "bar");
      
              Collection<String> foo = resp.getHeaders("Foo"); // ok
              Collection<String> unset = resp.getHeaders("unset"); // throws NPE
          }
      }
      
      Show
      public class TestServlet extends HttpServlet { @Override protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { resp.setHeader( "Foo" , "bar" ); Collection< String > foo = resp.getHeaders( "Foo" ); // ok Collection< String > unset = resp.getHeaders( "unset" ); // throws NPE } }

    Description

      Calling getHeaders(java.lang.String name) on HttpServletResponse produces NullPointerException if the requested header is not set. An empty collection should be returned.

      Attachments

        Activity

          People

            sdouglas1@redhat.com Stuart Douglas
            jmalek_jira Jaroslav Málek (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: