hc-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "William R. Speirs (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (HTTPCORE-270) IllegalStateException in AbstractSessionOutputBuffer
Date Tue, 23 Aug 2011 15:27:29 GMT

    [ https://issues.apache.org/jira/browse/HTTPCORE-270?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13089539#comment-13089539
] 

William R. Speirs commented on HTTPCORE-270:
--------------------------------------------

I'll work on a unit test. I'm curious as to why no one has hit this before me though. From
AbstractMessageWriter.java 96-97:

this.lineBuf.clear();
this.sessionBuffer.writeLine(this.lineBuf);

Basically just writing a newline (after the headers, before the body of the request). I would
think that EVERY request would trigger this. Curious...


> 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
>
>
> 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


Mime
View raw message