title: Enumeration Null pointer Exception?
body: <p>Hi I am using the HttpServletRequest and trying to get the set of headers set. </p>
  
  <p>Here is the code : </p>
  
  <pre><code>public static Map&lt;String, String&gt; getHeaders(HttpServletRequest request) { 
     Map&lt;String, String&gt; headers = new HashMap&lt;String, String&gt;();
  
    Enumeration&lt;String&gt; headerNames = request.getHeaderNames(); 
    if (headerNames != null) {
              while (headerNames.hasMoreElements()) {
                  String headerName = headerNames.nextElement();
                  String header = request.getHeader(headerName);
                  headers.put(headerName, header);
              }
          }
          return headers;
  
  }
  </code></pre>
  
  <p>This method seems to be throwing a Null pointer exception at the headerNames.nextElement(). </p>
  
  <p>Is it possible that the hasMoreElements check returns true but the element headerNames.nextElement in turn causes the null pointer exception? </p>
  
  <p>Stack Trace :       </p>
  
  <pre><code>    Stack trace : Caused by: java.lang.NullPointerException at org.apache.tomcat.util.buf.ByteChunk.equalsIgnoreCase(ByteChunk.java:608) at 
  org.apache.tomcat.util.buf.MessageBytes.equalsIgnoreCase(MessageBytes.java:325) 
  at org.apache.tomcat.util.http.NamesEnumerator.findNext(MimeHeaders.java:414) at org.apache.tomcat.util.http.NamesEnumerator.nextElement(MimeHeaders.java:438) 
  at org.apache.tomcat.util.http.NamesEnumerator.nextElement(MimeHeaders.java:396) at generateRequestHeaderMap...
  </code></pre>
  
  <p>It would be great if you guys could help me out with this issue. </p>