You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@hc.apache.org by DELHOSTE Fabrice <Fa...@gemalto.com> on 2010/03/24 17:19:32 UTC

AsyncHttpClient Advice

Hi,

We are currently using the asynchttpclient trunk (thx for previous feedback). We encounter 2 problems.

1) In HTTPExchangeImpl constructor, I changed responseFuture to be initialized *before* leasing the session (it was after).
Because sometimes the response is so fast that the responseFuture is still null...and handlers are sending a NullPointerException.

HTTPExchangeImpl.java:

        this.listener = listener;
        this.responseFuture = new BasicFuture<HttpResponse>(callback);
        this.sessionFuture = sessmrg.leaseSession(route, state, new
InternalFutureCallback());


2) Now, when running under high load test, I encounter the following one during this:

SessionPool.java:180

            if (getAllocatedTotal() >= this.maxTotal) {
                if (!this.availableSessions.isEmpty()) {
                    PoolEntry<T> entry = this.availableSessions.remove();
                    entryShutdown(entry);
                    SessionPoolForRoute<T> pool = getPool(entry.getRoute());
                    pool.freeEntry(entry, false);
                }
            }

The freeEntry is sending me an IllegalException coming from SessionPoolForRoute saying that "the entry has not been leased from this pool".
I haven't fully dived into the code...if possible, could you please give me advice on that so I can find the problem (synchronization?).
At the moment I just made a silly change: I commented this code and everything seems to work, even for high loads.

Thanks,
Fabrice


Re: AsyncHttpClient Advice

Posted by Oleg Kalnichevski <ol...@apache.org>.
DELHOSTE Fabrice wrote:
> Hi,
> 
> We are currently using the asynchttpclient trunk (thx for previous feedback). We encounter 2 problems.
> 
> 1) In HTTPExchangeImpl constructor, I changed responseFuture to be initialized *before* leasing the session (it was after).
> Because sometimes the response is so fast that the responseFuture is still null...and handlers are sending a NullPointerException.
> 
> HTTPExchangeImpl.java:
> 
>         this.listener = listener;
>         this.responseFuture = new BasicFuture<HttpResponse>(callback);
>         this.sessionFuture = sessmrg.leaseSession(route, state, new
> InternalFutureCallback());
> 
> 

Sounds reasonable. I committed the fix to the repository


> 2) Now, when running under high load test, I encounter the following one during this:
> 
> SessionPool.java:180
> 
>             if (getAllocatedTotal() >= this.maxTotal) {
>                 if (!this.availableSessions.isEmpty()) {
>                     PoolEntry<T> entry = this.availableSessions.remove();
>                     entryShutdown(entry);
>                     SessionPoolForRoute<T> pool = getPool(entry.getRoute());
>                     pool.freeEntry(entry, false);
>                 }
>             }
> 
> The freeEntry is sending me an IllegalException coming from SessionPoolForRoute saying that "the entry has not been leased from this pool".
> I haven't fully dived into the code...if possible, could you please give me advice on that so I can find the problem (synchronization?).
> At the moment I just made a silly change: I commented this code and everything seems to work, even for high loads.
> 

Can you post a complete stack trace? This piece of code is not entirely 
useless. It attempts to shut down idle sessions when the pool is running 
at its maximum capacity to make space for new sessions. It should not be 
just commented out.

Just a general remark: I am more than happy to review and commit patches 
but it is unlikely I can invest considerable time into debugging of the 
code.

Oleg


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