Merge branch 'jetty-9' of ssh://git.eclipse.org/gitroot/jetty/org.eclipse.jetty.project into jetty-9
This commit is contained in:
commit
7ab495515a
|
@ -43,6 +43,12 @@ public class HttpAuthenticationStore implements AuthenticationStore
|
|||
authentications.remove(authentication);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clearAuthentications()
|
||||
{
|
||||
authentications.clear();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Authentication findAuthentication(String type, String uri, String realm)
|
||||
{
|
||||
|
|
|
@ -125,7 +125,6 @@ public class HttpClient extends AggregateLifeCycle
|
|||
public HttpClient(SslContextFactory sslContextFactory)
|
||||
{
|
||||
this.sslContextFactory = sslContextFactory;
|
||||
addBean(sslContextFactory);
|
||||
}
|
||||
|
||||
public SslContextFactory getSslContextFactory()
|
||||
|
@ -136,6 +135,9 @@ public class HttpClient extends AggregateLifeCycle
|
|||
@Override
|
||||
protected void doStart() throws Exception
|
||||
{
|
||||
if (sslContextFactory != null)
|
||||
addBean(sslContextFactory);
|
||||
|
||||
if (executor == null)
|
||||
executor = new QueuedThreadPool();
|
||||
addBean(executor);
|
||||
|
@ -171,13 +173,17 @@ public class HttpClient extends AggregateLifeCycle
|
|||
|
||||
for (HttpDestination destination : destinations.values())
|
||||
destination.close();
|
||||
|
||||
destinations.clear();
|
||||
|
||||
conversations.clear();
|
||||
|
||||
handlers.clear();
|
||||
requestListeners.clear();
|
||||
cookieStore.clear();
|
||||
authenticationStore.clearAuthentications();
|
||||
authenticationStore.clearAuthenticationResults();
|
||||
|
||||
super.doStop();
|
||||
|
||||
LOG.info("Stopped {}", this);
|
||||
}
|
||||
|
||||
|
@ -424,6 +430,11 @@ public class HttpClient extends AggregateLifeCycle
|
|||
this.scheduler = scheduler;
|
||||
}
|
||||
|
||||
public SelectorManager getSelectorManager()
|
||||
{
|
||||
return selectorManager;
|
||||
}
|
||||
|
||||
public int getMaxConnectionsPerAddress()
|
||||
{
|
||||
return maxConnectionsPerAddress;
|
||||
|
@ -474,6 +485,13 @@ public class HttpClient extends AggregateLifeCycle
|
|||
this.maxRedirects = maxRedirects;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dump(Appendable out, String indent) throws IOException
|
||||
{
|
||||
dumpThis(out);
|
||||
dump(out, indent, getBeans(), destinations.values());
|
||||
}
|
||||
|
||||
protected class ClientSelectorManager extends SelectorManager
|
||||
{
|
||||
public ClientSelectorManager()
|
||||
|
@ -544,18 +562,6 @@ public class HttpClient extends AggregateLifeCycle
|
|||
{
|
||||
getExecutor().execute(task);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void connectionOpened(org.eclipse.jetty.io.Connection connection)
|
||||
{
|
||||
connection.onOpen();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void connectionClosed(org.eclipse.jetty.io.Connection connection)
|
||||
{
|
||||
connection.onClose();
|
||||
}
|
||||
}
|
||||
|
||||
private class ConnectionCallback extends FutureCallback<Connection>
|
||||
|
|
|
@ -261,6 +261,7 @@ public class HttpConnection extends AbstractConnection implements Connection
|
|||
LOG.debug("{} oshut", this);
|
||||
getEndPoint().close();
|
||||
LOG.debug("{} closed", this);
|
||||
client.getSelectorManager().connectionClosed(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -18,7 +18,10 @@
|
|||
|
||||
package org.eclipse.jetty.client;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.channels.AsynchronousCloseException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Queue;
|
||||
import java.util.concurrent.ArrayBlockingQueue;
|
||||
import java.util.concurrent.BlockingQueue;
|
||||
|
@ -33,10 +36,12 @@ import org.eclipse.jetty.client.api.Response;
|
|||
import org.eclipse.jetty.client.api.Result;
|
||||
import org.eclipse.jetty.util.Callback;
|
||||
import org.eclipse.jetty.util.FutureCallback;
|
||||
import org.eclipse.jetty.util.component.AggregateLifeCycle;
|
||||
import org.eclipse.jetty.util.component.Dumpable;
|
||||
import org.eclipse.jetty.util.log.Log;
|
||||
import org.eclipse.jetty.util.log.Logger;
|
||||
|
||||
public class HttpDestination implements Destination, AutoCloseable
|
||||
public class HttpDestination implements Destination, AutoCloseable, Dumpable
|
||||
{
|
||||
private static final Logger LOG = Log.getLogger(HttpDestination.class);
|
||||
|
||||
|
@ -301,6 +306,24 @@ public class HttpDestination implements Destination, AutoCloseable
|
|||
LOG.debug("Closed {}", this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String dump()
|
||||
{
|
||||
return AggregateLifeCycle.dump(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dump(Appendable out, String indent) throws IOException
|
||||
{
|
||||
AggregateLifeCycle.dumpObject(out, this + " - requests queued: " + requests.size());
|
||||
List<String> connections = new ArrayList<>();
|
||||
for (Connection connection : idleConnections)
|
||||
connections.add(connection + " - IDLE");
|
||||
for (Connection connection : activeConnections)
|
||||
connections.add(connection + " - ACTIVE");
|
||||
AggregateLifeCycle.dump(out, indent, connections);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
|
|
|
@ -33,6 +33,11 @@ public interface AuthenticationStore
|
|||
*/
|
||||
public void removeAuthentication(Authentication authentication);
|
||||
|
||||
/**
|
||||
* Removes all {@link Authentication}s stored
|
||||
*/
|
||||
public void clearAuthentications();
|
||||
|
||||
/**
|
||||
* Returns the authentication that matches the given type (for example, "Basic" or "Digest"),
|
||||
* the given request URI and the given realm.
|
||||
|
|
|
@ -177,14 +177,34 @@ public abstract class SelectorManager extends AbstractLifeCycle implements Dumpa
|
|||
*
|
||||
* @param connection the connection just opened
|
||||
*/
|
||||
abstract protected void connectionOpened(Connection connection);
|
||||
public void connectionOpened(Connection connection)
|
||||
{
|
||||
try
|
||||
{
|
||||
connection.onOpen();
|
||||
}
|
||||
catch (Exception x)
|
||||
{
|
||||
LOG.info("Exception while notifying connection " + connection, x);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>Callback method invoked when a connection is closed.</p>
|
||||
*
|
||||
* @param connection the connection just closed
|
||||
*/
|
||||
abstract protected void connectionClosed(Connection connection);
|
||||
public void connectionClosed(Connection connection)
|
||||
{
|
||||
try
|
||||
{
|
||||
connection.onClose();
|
||||
}
|
||||
catch (Exception x)
|
||||
{
|
||||
LOG.info("Exception while notifying connection " + connection, x);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>Callback method invoked when a non-blocking connect cannot be completed.</p>
|
||||
|
|
|
@ -146,14 +146,13 @@ public class SslConnection extends AbstractConnection
|
|||
{
|
||||
// Begin the handshake
|
||||
_sslEngine.beginHandshake();
|
||||
super.onOpen();
|
||||
}
|
||||
catch (SSLException x)
|
||||
{
|
||||
getEndPoint().close();
|
||||
throw new RuntimeIOException(x);
|
||||
}
|
||||
|
||||
super.onOpen();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -101,19 +101,6 @@ public class SelectChannelEndPointInterestsTest
|
|||
}
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public void connectionOpened(Connection connection)
|
||||
{
|
||||
connection.onOpen();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void connectionClosed(Connection connection)
|
||||
{
|
||||
connection.onClose();
|
||||
}
|
||||
|
||||
};
|
||||
selectorManager.start();
|
||||
}
|
||||
|
|
|
@ -18,9 +18,6 @@
|
|||
|
||||
package org.eclipse.jetty.io;
|
||||
|
||||
import static org.hamcrest.Matchers.*;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import java.io.BufferedInputStream;
|
||||
import java.io.BufferedOutputStream;
|
||||
import java.io.IOException;
|
||||
|
@ -49,6 +46,12 @@ import org.junit.Assert;
|
|||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.hamcrest.Matchers.greaterThan;
|
||||
import static org.hamcrest.Matchers.greaterThanOrEqualTo;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
public class SelectChannelEndPointTest
|
||||
{
|
||||
private static final Logger LOG = Log.getLogger(SelectChannelEndPointTest.class);
|
||||
|
@ -79,18 +82,6 @@ public class SelectChannelEndPointTest
|
|||
_lastEndPointLatch.countDown();
|
||||
return endp;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void connectionOpened(Connection connection)
|
||||
{
|
||||
connection.onOpen();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void connectionClosed(Connection connection)
|
||||
{
|
||||
connection.onClose();
|
||||
}
|
||||
};
|
||||
|
||||
// Must be volatile or the test may fail spuriously
|
||||
|
@ -613,7 +604,7 @@ public class SelectChannelEndPointTest
|
|||
String data = "Now is the time for all good men to come to the aid of the party";
|
||||
client.getOutputStream().write(data.getBytes("UTF-8"));
|
||||
BufferedInputStream in = new BufferedInputStream(client.getInputStream());
|
||||
|
||||
|
||||
int byteNum = 0;
|
||||
try
|
||||
{
|
||||
|
|
|
@ -88,18 +88,6 @@ public class SslConnectionTest
|
|||
_lastEndp=endp;
|
||||
return endp;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void connectionOpened(Connection connection)
|
||||
{
|
||||
connection.onOpen();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void connectionClosed(Connection connection)
|
||||
{
|
||||
connection.onClose();
|
||||
}
|
||||
};
|
||||
|
||||
// Must be volatile or the test may fail spuriously
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>maven-plugin-plugin</artifactId>
|
||||
<version>2.9</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>exec-plugin-doc</id>
|
||||
|
|
|
@ -20,7 +20,6 @@ package org.eclipse.jetty.spdy;
|
|||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
import javax.net.ssl.SSLEngine;
|
||||
|
||||
import org.eclipse.jetty.io.AbstractConnection;
|
||||
|
@ -43,16 +42,16 @@ public class NextProtoNegoServerConnection extends AbstractConnection implements
|
|||
private final List<String> protocols;
|
||||
private final String defaultProtocol;
|
||||
private boolean completed; // No need to be volatile: it is modified and read by the same thread
|
||||
|
||||
|
||||
|
||||
|
||||
public NextProtoNegoServerConnection(DecryptedEndPoint endPoint, Connector connector, List<String>protocols, String defaultProtocol)
|
||||
{
|
||||
super(endPoint, connector.getExecutor());
|
||||
this.connector = connector;
|
||||
this.connector = connector;
|
||||
this.protocols = protocols;
|
||||
this.defaultProtocol=defaultProtocol;
|
||||
engine = endPoint.getSslConnection().getSSLEngine();
|
||||
|
||||
|
||||
NextProtoNego.put(engine,this);
|
||||
}
|
||||
|
||||
|
@ -62,12 +61,12 @@ public class NextProtoNegoServerConnection extends AbstractConnection implements
|
|||
super.onOpen();
|
||||
fillInterested();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onClose()
|
||||
public void onClose()
|
||||
{
|
||||
super.onClose();
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFillable()
|
||||
|
|
|
@ -30,7 +30,6 @@ import java.util.Queue;
|
|||
import java.util.concurrent.ConcurrentLinkedQueue;
|
||||
import java.util.concurrent.Executor;
|
||||
import java.util.concurrent.Future;
|
||||
|
||||
import javax.net.ssl.SSLEngine;
|
||||
|
||||
import org.eclipse.jetty.io.ByteBufferPool;
|
||||
|
@ -281,9 +280,10 @@ public class SPDYClient
|
|||
DecryptedEndPoint sslEndPoint = sslConnection.getDecryptedEndPoint();
|
||||
NextProtoNegoClientConnection connection = new NextProtoNegoClientConnection(channel, sslEndPoint, attachment, client.factory.executor, client);
|
||||
sslEndPoint.setConnection(connection);
|
||||
connectionOpened(connection);
|
||||
return sslConnection;
|
||||
}
|
||||
|
||||
|
||||
SPDYClientConnectionFactory connectionFactory = new SPDYClientConnectionFactory();
|
||||
return connectionFactory.newConnection(channel, endPoint, attachment);
|
||||
}
|
||||
|
@ -293,19 +293,6 @@ public class SPDYClient
|
|||
throw x;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void connectionOpened(Connection connection)
|
||||
{
|
||||
connection.onOpen();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void connectionClosed(Connection connection)
|
||||
{
|
||||
connection.onClose();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -49,7 +49,7 @@ public class AggregateLifeCycle extends AbstractLifeCycle implements Destroyable
|
|||
private boolean _started = false;
|
||||
|
||||
enum Managed { MANAGED, UNMANAGED, AUTO };
|
||||
|
||||
|
||||
private class Bean
|
||||
{
|
||||
private final Object _bean;
|
||||
|
@ -75,7 +75,7 @@ public class AggregateLifeCycle extends AbstractLifeCycle implements Destroyable
|
|||
{
|
||||
// indicate that we are started, so that addBean will start other beans added.
|
||||
_started = true;
|
||||
|
||||
|
||||
// start our managed and auto beans
|
||||
for (Bean b : _beans)
|
||||
{
|
||||
|
@ -100,7 +100,7 @@ public class AggregateLifeCycle extends AbstractLifeCycle implements Destroyable
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
super.doStart();
|
||||
}
|
||||
|
||||
|
@ -245,8 +245,8 @@ public class AggregateLifeCycle extends AbstractLifeCycle implements Destroyable
|
|||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Manages a bean already contained by this aggregate, so that it is started/stopped/destroyed with this
|
||||
* aggregate.
|
||||
|
@ -446,12 +446,12 @@ public class AggregateLifeCycle extends AbstractLifeCycle implements Destroyable
|
|||
else
|
||||
dumpObject(out, b._bean);
|
||||
break;
|
||||
|
||||
|
||||
case UNMANAGED:
|
||||
out.append(indent).append(" +~ ");
|
||||
dumpObject(out, b._bean);
|
||||
break;
|
||||
|
||||
|
||||
case AUTO:
|
||||
out.append(indent).append(" += ");
|
||||
if (b._bean instanceof Dumpable)
|
||||
|
@ -459,7 +459,7 @@ public class AggregateLifeCycle extends AbstractLifeCycle implements Destroyable
|
|||
else
|
||||
dumpObject(out, b._bean);
|
||||
break;
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -490,9 +490,6 @@ public class AggregateLifeCycle extends AbstractLifeCycle implements Destroyable
|
|||
else
|
||||
dumpObject(out, o);
|
||||
}
|
||||
|
||||
if (i != size)
|
||||
out.append(indent).append(" |\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -143,16 +143,4 @@ public class WebSocketClientSelectorManager extends SelectorManager
|
|||
{
|
||||
this.sslContextFactory = sslContextFactory;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void connectionOpened(Connection connection)
|
||||
{
|
||||
connection.onOpen();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void connectionClosed(Connection connection)
|
||||
{
|
||||
connection.onClose();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue