1 Reply Latest reply on Oct 6, 2014 12:09 PM by Dimitris Andreadis

    Reading post data (https enabled) from a HttpServletRequest will freeze the servlet if request body > 4096 bytes

    Mi Gr Newbie



      I'm observing a strange behavior on EAP 6.3 alpha with https enabled.

      I'm using this simple code to read the body of a post request:


      protectedvoid doPost(HttpServletRequest request, HttpServletResponse resp)
           throws ServletException, java.io.IOException {
           byte[] buffer = new byte[4096];
           InputStream in = request.getInputStream();
           try {
           while (true) {
                int byteCount = in.read(buffer); // always returns 0 when request body > 4096 bytes
                if (byteCount == -1) {


      The problem occurs when the size of the request body exceeds 4096 bytes. Then a call to read(buffer) of the servlet's input stream always returns 0 (not -1, the stream is never closed), causing the servlet to get stuck in an infinite loop. This problem only appears when using https.


      Adjusting the max-save-post-size didn't change anything (I'm not sure if that parameter is actually relevant in that case).


      My question is why is the input stream behaving that way? Is that some configuration issue or am I doing something wrong in my code?


      Any hints are highly appreciated!

      Thank you very much in advance,