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