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 57C1B8705 for ; Wed, 24 Aug 2011 14:22:54 +0000 (UTC) Received: (qmail 76364 invoked by uid 500); 24 Aug 2011 14:22:54 -0000 Delivered-To: apmail-hc-dev-archive@hc.apache.org Received: (qmail 76274 invoked by uid 500); 24 Aug 2011 14:22:53 -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 76266 invoked by uid 99); 24 Aug 2011 14:22:53 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 24 Aug 2011 14:22:53 +0000 X-ASF-Spam-Status: No, hits=-2000.9 required=5.0 tests=ALL_TRUSTED,RP_MATCHES_RCVD X-Spam-Check-By: apache.org Received: from [140.211.11.116] (HELO hel.zones.apache.org) (140.211.11.116) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 24 Aug 2011 14:22:50 +0000 Received: from hel.zones.apache.org (hel.zones.apache.org [140.211.11.116]) by hel.zones.apache.org (Postfix) with ESMTP id 6213FCDD7F for ; Wed, 24 Aug 2011 14:22:29 +0000 (UTC) Date: Wed, 24 Aug 2011 14:22:29 +0000 (UTC) From: "Oleg Kalnichevski (JIRA)" To: dev@hc.apache.org Message-ID: <1334196892.9344.1314195749398.JavaMail.tomcat@hel.zones.apache.org> In-Reply-To: <2072810163.5382.1314110729120.JavaMail.tomcat@hel.zones.apache.org> Subject: [jira] [Commented] (HTTPCORE-270) IllegalStateException in AbstractSessionOutputBuffer MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 X-Virus-Checked: Checked by ClamAV on apache.org [ https://issues.apache.org/jira/browse/HTTPCORE-270?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13090244#comment-13090244 ] Oleg Kalnichevski commented on HTTPCORE-270: -------------------------------------------- Yes, please do bounce this discussion to the dev list. I'll answer your questions from there. Oleg > IllegalStateException in AbstractSessionOutputBuffer > ---------------------------------------------------- > > Key: HTTPCORE-270 > URL: https://issues.apache.org/jira/browse/HTTPCORE-270 > Project: HttpComponents HttpCore > Issue Type: Bug > Components: HttpCore > Affects Versions: 4.2-alpha1 > Reporter: William R. Speirs > Priority: Critical > Fix For: 4.2-alpha2 > > Attachments: SocketOutputBuffer.diff > > > I am using httpclient-4.1.2 & httpcore-4.2-alpha1. In making an DefaultHttpClient.execute() call I get the following exception: > java.lang.IllegalStateException: Current state = RESET, new state = FLUSHED > at java.nio.charset.CharsetEncoder.throwIllegalStateException(CharsetEncoder.java:951) > at java.nio.charset.CharsetEncoder.flush(CharsetEncoder.java:640) > at org.apache.http.impl.io.AbstractSessionOutputBuffer.writeEncoded(AbstractSessionOutputBuffer.java:264) > at org.apache.http.impl.io.AbstractSessionOutputBuffer.writeLine(AbstractSessionOutputBuffer.java:247) > at org.apache.http.impl.conn.LoggingSessionOutputBuffer.writeLine(LoggingSessionOutputBuffer.java:99) > at org.apache.http.impl.io.AbstractMessageWriter.write(AbstractMessageWriter.java:97) > at org.apache.http.impl.AbstractHttpClientConnection.sendRequestHeader(AbstractHttpClientConnection.java:253) > On line 264 of AbstractSessionOutputBuffer.java, encoder.flush() is being called. My thought (I have not completely debugged) is that in this instance, cbuf.hasRemaining() is false, and therefor the following calls are being made: > encoder.reset() > encoder.flush() > This is resulting in the above exception. > I believe the following small patch will short-circuit the code, and fix the issue. > Thoughts? > Index: httpcore/src/main/java/org/apache/http/impl/io/AbstractSessionOutputBuffer.java > =================================================================== > --- httpcore/src/main/java/org/apache/http/impl/io/AbstractSessionOutputBuffer.java (revision 1160689) > +++ httpcore/src/main/java/org/apache/http/impl/io/AbstractSessionOutputBuffer.java (working copy) > @@ -256,6 +256,10 @@ > if (this.bbuf == null) { > this.bbuf = ByteBuffer.allocate(1024); > } > + if(!cbuf.hasRemaining()) { > + return; > + } > + > this.encoder.reset(); > while (cbuf.hasRemaining()) { > CoderResult result = this.encoder.encode(cbuf, this.bbuf, true); -- This message is automatically generated by JIRA. For more information on JIRA, see: http://www.atlassian.com/software/jira --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org For additional commands, e-mail: dev-help@hc.apache.org