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

NPE in HttpServletResponse.getHeaders

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Major 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 } }

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

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

                Created:
                Updated:
                Resolved: