Return-Path: X-Original-To: apmail-hc-dev-archive@www.apache.org Delivered-To: apmail-hc-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 99720E11C for ; Wed, 27 Feb 2013 05:34:01 +0000 (UTC) Received: (qmail 49144 invoked by uid 500); 27 Feb 2013 05:34:01 -0000 Delivered-To: apmail-hc-dev-archive@hc.apache.org Received: (qmail 49029 invoked by uid 500); 27 Feb 2013 05:34:00 -0000 Mailing-List: contact dev-help@hc.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "HttpComponents Project" Delivered-To: mailing list dev@hc.apache.org Received: (qmail 49006 invoked by uid 99); 27 Feb 2013 05:34:00 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 27 Feb 2013 05:34:00 +0000 X-ASF-Spam-Status: No, hits=-0.7 required=5.0 tests=RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of asankha.apache@gmail.com designates 209.85.160.48 as permitted sender) Received: from [209.85.160.48] (HELO mail-pb0-f48.google.com) (209.85.160.48) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 27 Feb 2013 05:33:54 +0000 Received: by mail-pb0-f48.google.com with SMTP id wy12so139870pbc.35 for ; Tue, 26 Feb 2013 21:33:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:sender:message-id:date:from:user-agent:mime-version:to :subject:references:in-reply-to:content-type :content-transfer-encoding; bh=keMqLLTuTFy08fGo/Atw0yH9VLweWQ/pubrSAGW648c=; b=DyUPmjrwLIxr+b9Nn2Mn8ZPcIiw4AE1+fbq6ofN/ZgSoAyeV0JRtYViqNwAsBJAwUW b1v214L1+9KiCiuL2j9p4rFXjtnKmOcijj+HvuYIs0FZaO/dD6ghdjejnbzu7eP6+DNp aNe9o2WJzEGlZbZoMvBXLziZllSMnQ0tYwSc+odn/7CP9dbzCL72NGedVTgcvyQC1Mx8 Ku8AZC7wjAvQ0yd2yumFfueZ5G3Ur/oLsPm0Ob+LT9OxC8rV52Bd7vRO482uucG3zeYB THzbmed+wntPme/oTHQxGrVyd8/MnaA1Xw5gNl5GcuMvGLgr2CIUdKiCQYMHsLXy3bcU 0HNA== X-Received: by 10.66.221.67 with SMTP id qc3mr5768951pac.85.1361943212702; Tue, 26 Feb 2013 21:33:32 -0800 (PST) Received: from [192.168.1.102] ([112.134.223.14]) by mx.google.com with ESMTPS id zv5sm2296528pab.2.2013.02.26.21.33.30 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 26 Feb 2013 21:33:31 -0800 (PST) Sender: Asankha Perera Message-ID: <512D9AA7.9070603@apache.org> Date: Wed, 27 Feb 2013 11:03:27 +0530 From: "Asankha C. Perera" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:15.0) Gecko/20120912 Thunderbird/15.0.1 MIME-Version: 1.0 To: HttpComponents Project Subject: Re: Truncated content-length delimited message bodies with sendfile References: <512368A0.80804@apache.org> <1361392500.28706.5.camel@ubuntu> In-Reply-To: <1361392500.28706.5.camel@ubuntu> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org Hi Oleg > The behavior of Channel#isOpen() is correct. A channel can be open > locally (or half-closed) even if it ha been closed by the remote peer. > As long as the channel is half-closed it should return -1 on all read > operations instead of throwing an I/O error. Yes, I see.. it would have been great if FileChannel.transferFrom() returned -1 as well, without hiding that underneath the JDK layer, when actually encountered > The problem is this utterly crazy implementation of FileChannelImpl > > http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/6-b14/sun/nio/ch/FileChannelImpl.java#607 > > I do not see a reasonable way of working around this insanity. The only > thing we can do is to plea to Oracle to fix it and pray they would > heed. What if we make our LengthDelimitedEncoder try to read into the session buffer, if bytes read is found to be zero? This may not be optimal, but at least, results in the correct operation. bytesRead = dst.transferFrom(this.channel, position, count); if (bytesRead == 0) { bytesRead = this.buffer.fill(this.channel); } regards asankha -- Asankha C. Perera AdroitLogic, http://adroitlogic.org http://esbmagic.blogspot.com --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org For additional commands, e-mail: dev-help@hc.apache.org