hc-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Oleg Kalnichevski (JIRA)" <j...@apache.org>
Subject [jira] Commented: (HTTPCORE-51) My HttpRequestExecutionHandler.submitRequest is being called repeatedly
Date Sun, 04 Mar 2007 13:08:51 GMT

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

Oleg Kalnichevski commented on HTTPCORE-51:
-------------------------------------------

Anders,

I tweaked the code in SVN somewhat to make sure NHttpClientHandler#requestReady() does not
fire unnecessarily. Could you please re-test your application against SVN trunk? Please note
that the application does not have to take any action in response to this event if it is not
ready to submit a new HTTP request. requestReady() event is intended to notify the service
handler the connection is ready for submission of a new HTTP request. It does not imply the
handler is expected to take any action.

Oleg

> My HttpRequestExecutionHandler.submitRequest is being called repeatedly
> -----------------------------------------------------------------------
>
>                 Key: HTTPCORE-51
>                 URL: https://issues.apache.org/jira/browse/HTTPCORE-51
>             Project: HttpComponents Core
>          Issue Type: Bug
>          Components: HttpCore NIO
>         Environment: Windows Vista
>            Reporter: Anders Wallgren
>         Assigned To: Oleg Kalnichevski
>             Fix For: 4.0-alpha4
>
>
> In my test suite, I'm sending a single post, but I'm finding that my HttpRequestExecutionHandler.submitRequest
handler is being called multiple times.  I think I've tracked it down to DefaultNHttpClientConnection.productOutput:
>     public void produceOutput(final NHttpClientHandler handler) {
>         try {
>             if (this.outbuf.hasData()) {
>                 this.outbuf.flush(this.session.channel());   <<--- this is called
>             }
>             if (!this.outbuf.hasData()) {
>                 if (this.closed) {
>                     this.session.close();
>                     resetOutput();
>                     return;
>                 } else {
>                     if (this.contentEncoder != null) {
>                         handler.outputReady(this, this.contentEncoder);
>                         if (this.contentEncoder.isCompleted()) {
>                             resetOutput();   <<<<----- then this 
>                         }
>                     }
>                 }
>                 if (this.contentEncoder == null && !this.outbuf.hasData()) {
>                     this.session.clearEvent(EventMask.WRITE);
>                 }
>             }
>         } catch (IOException ex) {
>             handler.exception(this, ex);
>         } finally {
>             // Finally set buffered output flag
>             this.hasBufferedOutput = this.outbuf.hasData();
>         }
>         if (this.request == null && !this.closed) {
>             handler.requestReady(this);   <<<--- then this
>         }
>     }
> The sequence of events is that my submitRequest is called once, then when the channel
becomes writable, produceOutput is called.  It's a small request (3 bytes of content), so
the first branch is followed and outbuf is flushed.  Then there is no more data, and the second
branch is called, where resetOutput is called, but the method doesn't return.  Then, at the
bottom of produceOutput, handle.requestReady is called again, since resetOutput set request
to null.
> Am I doing something wrong, or is there a bug here?

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: httpcomponents-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: httpcomponents-dev-help@jakarta.apache.org


Mime
View raw message