Improved semantic of close() method, now executed only once.

This commit is contained in:
Simone Bordet 2014-01-07 17:59:56 +01:00
parent b59057c184
commit 4722ac1720
1 changed files with 11 additions and 14 deletions

View File

@ -19,6 +19,7 @@
package org.eclipse.jetty.client.http;
import java.util.concurrent.TimeoutException;
import java.util.concurrent.atomic.AtomicBoolean;
import org.eclipse.jetty.client.HttpConnection;
import org.eclipse.jetty.client.HttpDestination;
@ -35,9 +36,9 @@ public class HttpConnectionOverHTTP extends AbstractConnection implements Connec
{
private static final Logger LOG = Log.getLogger(HttpConnectionOverHTTP.class);
private final AtomicBoolean closed = new AtomicBoolean();
private final Delegate delegate;
private final HttpChannelOverHTTP channel;
private boolean closed;
private long idleTimeout;
public HttpConnectionOverHTTP(EndPoint endPoint, HttpDestination destination)
@ -75,16 +76,9 @@ public class HttpConnectionOverHTTP extends AbstractConnection implements Connec
fillInterested();
}
@Override
public void onClose()
{
closed = true;
super.onClose();
}
protected boolean isClosed()
{
return closed;
return closed.get();
}
@Override
@ -126,11 +120,14 @@ public class HttpConnectionOverHTTP extends AbstractConnection implements Connec
@Override
public void close()
{
getHttpDestination().close(this);
getEndPoint().shutdownOutput();
LOG.debug("{} oshut", this);
getEndPoint().close();
LOG.debug("{} closed", this);
if (closed.compareAndSet(false, true))
{
getHttpDestination().close(this);
getEndPoint().shutdownOutput();
LOG.debug("{} oshut", this);
getEndPoint().close();
LOG.debug("{} closed", this);
}
}
@Override