Hi All

I seem to have found a possible bug in the IdentityDecoder which checks
for "this.channel.isOpen()" to detect the EOF when using file channels.
However, it seems like although the remote party does close its side of
the socket, that we will not see it unless we read from the channel, as
the "dst.transferFrom(this.channel, position, count)" only returns 0 or
the number of bytes read - and not -1. The attached fix would use the
session input buffer to attempt a read after a zero byte read - and
hopefully will not cause an issue if its a false alarm and there was
data read into the buffer.

If this is indeed a bug, and the attached is a proper fix, I will commit
it to the code with a JIRA

thanks
asankha

-- 
Asankha C. Perera
AdroitLogic, http://adroitlogic.org

http://esbmagic.blogspot.com




Index: src/main/java/org/apache/http/impl/nio/codecs/IdentityDecoder.java
===================================================================
--- src/main/java/org/apache/http/impl/nio/codecs/IdentityDecoder.java	(revision 919387)
+++ src/main/java/org/apache/http/impl/nio/codecs/IdentityDecoder.java	(working copy)
@@ -116,6 +116,9 @@
                                           "].  Please grow the file before writing.");
                 
                 bytesRead = dst.transferFrom(this.channel, position, count);
+                if (bytesRead == 0) {
+                    bytesRead = buffer.fill(this.channel);
+                }
             } else {
                 bytesRead = -1;
             }

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

Reply via email to