dev@grizzly.java.net

Re: About connection leak

From: Bongjae Chang <bongjae.chang_at_gmail.com>
Date: Sun, 03 Jun 2012 15:19:22 +0900

Hi,

This is already resolved at the issue #1240:
http://java.net/jira/browse/GRIZZLY-1240 :-)

I think future.cancel(true) couldn't also resolve the problem because there
was no implementation as Alexey's words until he fixed it.

Thanks!

Regards,
Bongjae Chang

From: Fuyou001 <fuyou001_at_gmail.com>
Reply-To: <dev_at_grizzly.java.net>
Date: Saturday, June 2, 2012 9:10 AM
To: "dev_at_grizzly.java.net" <dev_at_grizzly.java.net>
Cc: "dev_at_grizzly.java.net" <dev_at_grizzly.java.net>
Subject: Re: About connection leak

Hi
You can use future.cancel(true)


发自我的 iPhone

在 2012-3-29,17:59,Oleksiy Stashok <oleksiy.stashok_at_oracle.com> 写道:

> Hi Bonjae,
>
> you found a bug.
> IMO your expectation that future.cancel() has to close connection is correct,
> but we've never implemented it.
>
> Pls. file an issue (possible fix is also welcome :))
>
> Thank you.
>
> WBR,
> Alexey.
>
> On 03/29/2012 11:53 AM, Bongjae Chang wrote:
>>
>>
>>
>> Hi,
>>
>>
>>
>>
>> When I used grizzly-memcached, I experienced connection leak when the trial
>> of connecting a server was timed out.
>>
>>
>>
>>
>>
>> Connecting logic is simple.
>>
>> ---
>>
>> final Future<Connection> future = connectorHandler.connect(serverAddr);
>>
>> final Connection<SocketAddress> connection;
>>
>> try {
>>
>> connection = future.get(shortTimeout, timeunit);
>>
>> } catch( ...) {
>>
>> ...
>>
>> } catch(TimeoutException te) {
>>
>> // at this point, connection is null and I don't need to get a connection
>> anymore. ---(1)
>>
>> }
>>
>> ---
>>
>>
>>
>>
>> When it was timed out at (1), the connection is null. So I couldn't
>> disconnect the connection.
>>
>> At (1), the only way which I could try to do was "future.cancel()" but the
>> connection was not disconnected. If the connection will be established
>> successfully after timeout, the connection will be alive forever.
>>
>>
>>
>>
>> I would like to know how to disconnect the late connection after timeout in
>> order to prevent the connection leak.
>>
>>
>>
>>
>> Thanks.
>>
>>
>>
>>
>> Regards,
>>
>> Bongjae Chang
>>
>>
>>
>>
>
>