Author: remy.maucherat(a)jboss.com
Date: 2014-03-03 11:21:50 -0500 (Mon, 03 Mar 2014)
New Revision: 2374
Modified:
branches/7.4.x/src/main/java/org/apache/coyote/http11/InternalNioInputBuffer.java
Log:
Remove bad code to handle exception thrown during blocking read.
Modified:
branches/7.4.x/src/main/java/org/apache/coyote/http11/InternalNioInputBuffer.java
===================================================================
---
branches/7.4.x/src/main/java/org/apache/coyote/http11/InternalNioInputBuffer.java 2014-02-26
14:33:13 UTC (rev 2373)
+++
branches/7.4.x/src/main/java/org/apache/coyote/http11/InternalNioInputBuffer.java 2014-03-03
16:21:50 UTC (rev 2374)
@@ -446,7 +446,13 @@
} else {
// Prepare the internal input buffer for reading
prepare();
- nRead = blockingRead(readTimeout, unit);
+ try {
+ nRead = channel.readBytes(bbuf, readTimeout, unit);
+ } catch (Exception e) {
+ if (CoyoteLogger.HTTP_LOGGER.isDebugEnabled()) {
+ CoyoteLogger.HTTP_LOGGER.errorWithBlockingRead(e);
+ }
+ }
if (nRead > 0) {
bbuf.flip();
if (nRead > (buf.length - end)) {
@@ -463,6 +469,8 @@
throw new EOFException(MESSAGES.failedRead());
} else if (nRead == NioChannel.OP_STATUS_READ_TIMEOUT) {
throw new SocketTimeoutException(MESSAGES.failedRead());
+ } else if (nRead == 0) {
+ throw new EOFException(MESSAGES.failedRead());
}
}
return nRead;
@@ -484,36 +492,6 @@
}
/**
- * Close the channel
- */
- private void close(NioChannel channel) {
- endpoint.closeChannel(channel);
- }
-
- /**
- * Read a sequence of bytes in blocking mode from he current channel
- *
- * @param bb
- * @return the number of bytes read or -1 if the end of the stream was
- * reached
- */
- private int blockingRead(long timeout, TimeUnit unit) {
- int nr = 0;
- try {
- long readTimeout = timeout > 0 ? timeout : Integer.MAX_VALUE;
- nr = this.channel.readBytes(bbuf, readTimeout, unit);
- if (nr < 0) {
- close(channel);
- }
- } catch (Exception e) {
- if (CoyoteLogger.HTTP_LOGGER.isDebugEnabled()) {
- CoyoteLogger.HTTP_LOGGER.errorWithBlockingRead(e);
- }
- }
- return nr;
- }
-
- /**
* This class is an input buffer which will read its data from an input
* stream.
*/
Show replies by date