https://bz.apache.org/bugzilla/show_bug.cgi?id=63573
Bug ID: 63573 Summary: For some requests, ServletInputStream.read(byte[] buffer) repeatedly returns 0 at EOF, fails to return -1 Product: Tomcat 8 Version: 8.5.38 Hardware: PC OS: Linux Status: NEW Severity: normal Priority: P2 Component: Catalina Assignee: dev@tomcat.apache.org Reporter: ferhat.sa...@cs.com.tr Target Milestone: ---- This happens for 5-12 POST requests daily, on a system that gets around 50,000 POST requests a day. All POST requests are for the same servlet, an XML payload is posted to it. I've traced the code to InputBuffer.read(byte,offset,length) and the problem is probably with InputBuffer.checkByteBufferEof() which seems to determine if EOF is reached in that code. When it happens, the simple stream copy loop below will turn into a tight, CPU hogging endless loop with each read returning 0 bytes: InputStream xmlis = request.getInputStream(); ByteArrayOutputStream baos = new ByteArrayOutputStream(); int n = 0; byte[] buff = new byte[xmlis.available()]; do { n = xmlis.read(buff); if (n > 0) { baos.write(buff, 0, n); } } while (n >= 0); baos.close(); I've implemented a timeout mechanism as a workaround, and the data arrives intact, albeit after a few thousand reads with 0 bytes returned. -- 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