Project: Tomcat
Bug 42753 Race condition when using available() or reading in CometProcessor.event()
Reported: 2007-06-27 05:21:53 | Status: resolved fixed

Tomcat version: 6.0.13 (no 6.0.13 available in the version field) When trying to process data in CometProcessor.event() either during the BEGIN event or during the READ event, it is impossible to guarantee that all data has been read before returning (since new data may arrive between the last statement before the return, and the return statement itself). However, the CoyoteProcessor does this check: } else if (!error && read && request.getAvailable()) { // If this was a read and not all bytes have been read, or if no data // was read from the connector, then it is an error error = true; log.error(sm.getString("coyoteAdapter.read")); } causing a severe error and the Comet request to break when this race condition manifests itself. I am using the following code according to the aio.html description to read data in my comet event handler: while (request.getInputStream().available() > 0) { // read some data } // ***** NO MORE DATA AVAILABLE return; And I am experiencing the error as described in certain conditions (rapid arrival of fragmented data): SEVERE: The servlet did not read all available bytes during the processing of the read event

Files changed in fix:
java/org/apache/catalina/core/ApplicationFilterFactory.java