https://issues.apache.org/bugzilla/show_bug.cgi?id=52055

--- Comment #13 from Sudhan Moghe <sudhan.mo...@gmail.com> ---
Rest of the stack trace is my application code.
I am starting async processing with

if (request.isAsyncSupported()) {
    final AsyncContext asyncCtx = request.startAsync(request, response);
    final Runnable command = new AsyncRequestProcessor(asyncCtx, this,
this.actionObjects);
    Executor executor =
(Executor)request.getServletContext().getAttribute(Constants.ASYNC_REQUEST_EXECUTOR);
    executor.execute(command);
}

Next line on stack trace is 
ServletUtils.getBytesOfStream(ServletUtils.java:425)

Code of same is
public static ByteArrayInputStreamExt getBytesOfStream(final Map<String,
Object> helperMap, final InputStream stream, int len, boolean chunked) throws
IOException {
    try {
        ByteArrayInputStreamExt bais = (ByteArrayInputStreamExt)
helperMap.get(Constants.DATA);
        byte[] tempBuf = null;
        if (bais == null) {
            tempBuf = new byte[len];
            bais = new ByteArrayInputStreamExt(tempBuf);
        } else {
            tempBuf = bais.getBuffer();
        }
        int readSoFar = 0;
        int bytesRead = 0;
        while (len > readSoFar) {
            bytesRead = stream.read(tempBuf, readSoFar, (len - readSoFar));
            if (bytesRead == -1) {
                if (chunked) {
                    if (readSoFar == 0) {
                        bais.reset(0);
                        return bais;
                    } else {
                        bais.reset(readSoFar);
                        return bais;
                    }
                }
                throw new IOException("Failed to read from inputstream");
            }
            readSoFar += bytesRead;
        }
        bais.reset(len);
        return bais;
    } catch (OutOfMemoryError th) {
        logger.error("Creating a byte array of length: " + len + " has resulted
in OOM error: " + th.getMessage());
    }
    return null;
}

And this method is called with

ServletUtils.getBytesOfStream(request.getInputStream(), length);

This method is called in a loop reading 10MB at a time. For chunked, loop stops
with EOF. The ByteArrayInputStreamExt handling is for reusing the byte[].

This happens only when client aborts.

Let me know if you need anymore info. Which class should I check if I have to
debug this?

Thanks,
Sudhan

-- 
You are receiving this mail because:
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org

Reply via email to