Post-merge cleanup
This commit is contained in:
parent
04b6afe879
commit
77252270ff
|
@ -218,30 +218,40 @@ public class ClientContainer extends ContainerLifeCycle implements WebSocketCont
|
|||
}
|
||||
|
||||
@Override
|
||||
public Session connectToServer(Class<? extends Endpoint> endpointClass, ClientEndpointConfig config, URI path) throws DeploymentException, IOException
|
||||
public Session connectToServer(final Class<? extends Endpoint> endpointClass, final ClientEndpointConfig config, URI path) throws DeploymentException, IOException
|
||||
{
|
||||
ConfiguredEndpoint instance = newConfiguredEndpoint(endpointClass, config);
|
||||
ClientEndpointConfig clientEndpointConfig = config;
|
||||
if (clientEndpointConfig == null)
|
||||
{
|
||||
clientEndpointConfig = new EmptyClientEndpointConfig();
|
||||
}
|
||||
ConfiguredEndpoint instance = newConfiguredEndpoint(endpointClass, clientEndpointConfig);
|
||||
return connect(instance, path);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Session connectToServer(Class<?> annotatedEndpointClass, URI path) throws DeploymentException, IOException
|
||||
public Session connectToServer(final Class<?> annotatedEndpointClass, final URI path) throws DeploymentException, IOException
|
||||
{
|
||||
ConfiguredEndpoint instance = newConfiguredEndpoint(annotatedEndpointClass, null);
|
||||
ConfiguredEndpoint instance = newConfiguredEndpoint(annotatedEndpointClass, new EmptyClientEndpointConfig());
|
||||
return connect(instance, path);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Session connectToServer(Endpoint endpoint, ClientEndpointConfig config, URI path) throws DeploymentException, IOException
|
||||
public Session connectToServer(final Endpoint endpoint, final ClientEndpointConfig config, final URI path) throws DeploymentException, IOException
|
||||
{
|
||||
ConfiguredEndpoint instance = newConfiguredEndpoint(endpoint, config);
|
||||
ClientEndpointConfig clientEndpointConfig = config;
|
||||
if (clientEndpointConfig == null)
|
||||
{
|
||||
clientEndpointConfig = new EmptyClientEndpointConfig();
|
||||
}
|
||||
ConfiguredEndpoint instance = newConfiguredEndpoint(endpoint, clientEndpointConfig);
|
||||
return connect(instance, path);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Session connectToServer(Object endpoint, URI path) throws DeploymentException, IOException
|
||||
{
|
||||
ConfiguredEndpoint instance = newConfiguredEndpoint(endpoint, null);
|
||||
ConfiguredEndpoint instance = newConfiguredEndpoint(endpoint, new EmptyClientEndpointConfig());
|
||||
return connect(instance, path);
|
||||
}
|
||||
|
||||
|
|
|
@ -74,7 +74,7 @@ public class JettyClientContainerProvider extends ContainerProvider
|
|||
{
|
||||
SimpleContainerScope containerScope = new SimpleContainerScope(WebSocketPolicy.newClientPolicy());
|
||||
QueuedThreadPool threadPool= new QueuedThreadPool();
|
||||
String name = "qtp-JSR356CLI-" + hashCode();
|
||||
String name = "Jsr356Client@" + hashCode();
|
||||
threadPool.setName(name);
|
||||
threadPool.setDaemon(true);
|
||||
containerScope.setExecutor(threadPool);
|
||||
|
|
|
@ -224,7 +224,7 @@ public class WebSocketClient extends ContainerLifeCycle implements WebSocketCont
|
|||
private WebSocketClient(SslContextFactory sslContextFactory, Executor executor, ByteBufferPool bufferPool, DecoratedObjectFactory objectFactory)
|
||||
{
|
||||
this.httpClient = new HttpClient(sslContextFactory);
|
||||
this.httpClient.setExecutor(executor);
|
||||
this.httpClient.setExecutor(getExecutor(executor));
|
||||
this.httpClient.setByteBufferPool(bufferPool);
|
||||
addBean(this.httpClient);
|
||||
|
||||
|
@ -234,7 +234,7 @@ public class WebSocketClient extends ContainerLifeCycle implements WebSocketCont
|
|||
|
||||
this.sessionFactory = new WebSocketSessionFactory(containerScope);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Create WebSocketClient based on pre-existing Container Scope, to allow sharing of
|
||||
* internal features like Executor, ByteBufferPool, SSLContextFactory, etc.
|
||||
|
@ -264,17 +264,7 @@ public class WebSocketClient extends ContainerLifeCycle implements WebSocketCont
|
|||
sslContextFactory = new SslContextFactory();
|
||||
}
|
||||
this.httpClient = new HttpClient(sslContextFactory);
|
||||
Executor executor = scope.getExecutor();
|
||||
if (executor == null)
|
||||
{
|
||||
QueuedThreadPool threadPool = new QueuedThreadPool();
|
||||
String name = "WebSocketClient@" + hashCode();
|
||||
threadPool.setName(name);
|
||||
threadPool.setDaemon(true);
|
||||
executor = threadPool;
|
||||
}
|
||||
|
||||
this.httpClient.setExecutor(executor);
|
||||
this.httpClient.setExecutor(getExecutor(scope.getExecutor()));
|
||||
addBean(this.httpClient);
|
||||
|
||||
this.extensionRegistry = new WebSocketExtensionFactory(containerScope);
|
||||
|
@ -431,6 +421,21 @@ public class WebSocketClient extends ContainerLifeCycle implements WebSocketCont
|
|||
return httpClient.getExecutor();
|
||||
}
|
||||
|
||||
// Internal getExecutor for defaulting to internal executor if not provided
|
||||
private Executor getExecutor(final Executor executor)
|
||||
{
|
||||
if (executor == null)
|
||||
{
|
||||
QueuedThreadPool threadPool = new QueuedThreadPool();
|
||||
String name = "WebSocketClient@" + hashCode();
|
||||
threadPool.setName(name);
|
||||
threadPool.setDaemon(true);
|
||||
return threadPool;
|
||||
}
|
||||
|
||||
return executor;
|
||||
}
|
||||
|
||||
public ExtensionFactory getExtensionFactory()
|
||||
{
|
||||
return extensionRegistry;
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
// ========================================================================
|
||||
//
|
||||
|
||||
package org.eclipse.jetty.websocket.jsr356;
|
||||
package org.eclipse.jetty.websocket.tests.client.jsr356;
|
||||
|
||||
import static org.hamcrest.CoreMatchers.containsString;
|
||||
import static org.hamcrest.CoreMatchers.hasItem;
|
||||
|
@ -33,6 +33,7 @@ import java.util.List;
|
|||
import javax.websocket.ContainerProvider;
|
||||
import javax.websocket.WebSocketContainer;
|
||||
|
||||
import org.eclipse.jetty.websocket.jsr356.JettyClientContainerProvider;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
|
@ -53,6 +54,7 @@ public class DelayedStartClientTest
|
|||
List<String> threadNames = getThreadNames();
|
||||
assertThat("Threads", threadNames, not(hasItem(containsString("WebSocketContainer@"))));
|
||||
assertThat("Threads", threadNames, not(hasItem(containsString("HttpClient@"))));
|
||||
assertThat("Threads", threadNames, not(hasItem(containsString("Jsr356Client@"))));
|
||||
}
|
||||
|
||||
private List<String> getThreadNames()
|
|
@ -16,7 +16,7 @@
|
|||
// ========================================================================
|
||||
//
|
||||
|
||||
package org.eclipse.jetty.websocket.jsr356.server;
|
||||
package org.eclipse.jetty.websocket.tests.server.jsr356;
|
||||
|
||||
import static org.hamcrest.CoreMatchers.containsString;
|
||||
import static org.hamcrest.CoreMatchers.hasItem;
|
||||
|
@ -57,6 +57,7 @@ import org.eclipse.jetty.util.IO;
|
|||
import org.eclipse.jetty.websocket.api.util.WSURI;
|
||||
import org.eclipse.jetty.websocket.jsr356.ClientContainer;
|
||||
import org.eclipse.jetty.websocket.jsr356.JettyClientContainerProvider;
|
||||
import org.eclipse.jetty.websocket.jsr356.server.ServerContainer;
|
||||
import org.eclipse.jetty.websocket.jsr356.server.deploy.WebSocketServerContainerInitializer;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
@ -182,9 +183,8 @@ public class DelayedStartClientOnServerTest
|
|||
{
|
||||
if (threadName.startsWith("HttpClient@") && !threadName.endsWith("-scheduler"))
|
||||
{
|
||||
throw new AssertionError("Found non-scheduler HttpClient thread in <" +
|
||||
threadNames.stream().collect(Collectors.joining("[", ", ", "]"))
|
||||
+ ">");
|
||||
throw new AssertionError("Found non-scheduler HttpClient thread in " +
|
||||
threadNames.stream().collect(Collectors.joining(", ", "[", "]")));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -229,6 +229,7 @@ public class DelayedStartClientOnServerTest
|
|||
assertNoHttpClientPoolThreads(threadNames);
|
||||
assertThat("Threads", threadNames, not(hasItem(containsString("WebSocketContainer@"))));
|
||||
assertThat("Threads", threadNames, not(hasItem(containsString("WebSocketClient@"))));
|
||||
assertThat("Threads", threadNames, not(hasItem(containsString("Jsr356Client@"))));
|
||||
}
|
||||
finally
|
||||
{
|
||||
|
@ -254,7 +255,7 @@ public class DelayedStartClientOnServerTest
|
|||
assertThat("Response", response, startsWith("Connected to ws://"));
|
||||
List<String> threadNames = getThreadNames();
|
||||
assertNoHttpClientPoolThreads(threadNames);
|
||||
assertThat("Threads", threadNames, hasItem(containsString("WebSocketContainer@")));
|
||||
assertThat("Threads", threadNames, hasItem(containsString("Jsr356Client@")));
|
||||
}
|
||||
finally
|
||||
{
|
||||
|
@ -306,6 +307,7 @@ public class DelayedStartClientOnServerTest
|
|||
assertNoHttpClientPoolThreads(threadNames);
|
||||
assertThat("Threads", threadNames, not(hasItem(containsString("WebSocketContainer@"))));
|
||||
assertThat("Threads", threadNames, not(hasItem(containsString("WebSocketClient@"))));
|
||||
assertThat("Threads", threadNames, not(hasItem(containsString("Jsr356Client@"))));
|
||||
}
|
||||
finally
|
||||
{
|
||||
|
@ -331,6 +333,7 @@ public class DelayedStartClientOnServerTest
|
|||
List<String> threadNames = getThreadNames();
|
||||
assertNoHttpClientPoolThreads(threadNames);
|
||||
assertThat("Threads", threadNames, not(hasItem(containsString("WebSocketContainer@"))));
|
||||
assertThat("Threads", threadNames, not(hasItem(containsString("Jsr356Client@"))));
|
||||
}
|
||||
finally
|
||||
{
|
Loading…
Reference in New Issue