Work around Jetty websocket client bug

Add workaround for Jetty JsrSession NullPointerException bug
(https://github.com/eclipse/jetty.project/issues/1202) in
`spring-boot-sample-websocket-jetty`.

See gh-7599
This commit is contained in:
Phillip Webb
2016-12-24 11:21:26 -08:00
parent a23591e047
commit a116579cfc
3 changed files with 101 additions and 8 deletions

View File

@@ -22,9 +22,11 @@ import java.util.concurrent.atomic.AtomicReference;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.eclipse.jetty.websocket.jsr356.ClientContainer;
import org.junit.Test;
import org.junit.runner.RunWith;
import samples.websocket.jetty.SampleJettyWebSocketsApplication;
import samples.websocket.jetty.client.FixedClientContainer;
import samples.websocket.jetty.client.GreetingService;
import samples.websocket.jetty.client.SimpleClientWebSocketHandler;
import samples.websocket.jetty.client.SimpleGreetingService;
@@ -123,18 +125,18 @@ public class CustomContainerWebSocketsApplicationTests {
}
@Bean
public WebSocketConnectionManager wsConnectionManager() {
public WebSocketConnectionManager wsConnectionManager() throws Exception {
WebSocketConnectionManager manager = new WebSocketConnectionManager(client(),
handler(), this.webSocketUri);
manager.setAutoStartup(true);
return manager;
}
@Bean
public StandardWebSocketClient client() {
return new StandardWebSocketClient();
public StandardWebSocketClient client() throws Exception {
ClientContainer container = new FixedClientContainer();
container.start();
return new StandardWebSocketClient(container);
}
@Bean