Merge pull request #3199 from lachlan-roberts/jetty-10.0.x-3139-npe-websocket-sci
Issue #3139 - NPE in WebSocketContainerInitializer for jetty10
This commit is contained in:
commit
1d9e7b7613
|
@ -57,6 +57,8 @@ public class WebSocketJsrServer
|
|||
ServletContextHandler.SESSIONS);
|
||||
context.setContextPath("/");
|
||||
handlers.addHandler(context);
|
||||
handlers.addHandler(new DefaultHandler());
|
||||
server.setHandler(handlers);
|
||||
|
||||
// Enable javax.websocket configuration for the context
|
||||
ServerContainer wsContainer = JavaxWebSocketServletContainerInitializer
|
||||
|
@ -65,9 +67,6 @@ public class WebSocketJsrServer
|
|||
// Add your websockets to the container
|
||||
wsContainer.addEndpoint(EchoJsrSocket.class);
|
||||
|
||||
handlers.addHandler(new DefaultHandler());
|
||||
|
||||
server.setHandler(handlers);
|
||||
server.start();
|
||||
context.dumpStdErr();
|
||||
server.join();
|
||||
|
|
|
@ -22,7 +22,6 @@ import java.time.Duration;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.Executor;
|
||||
|
||||
import javax.servlet.ServletContext;
|
||||
import javax.servlet.ServletException;
|
||||
import javax.websocket.DeploymentException;
|
||||
|
@ -84,6 +83,8 @@ public class JavaxWebSocketServerContainer
|
|||
public static JavaxWebSocketServerContainer ensureContainer(ServletContext servletContext) throws ServletException
|
||||
{
|
||||
ContextHandler contextHandler = ServletContextHandler.getServletContextHandler(servletContext, "Javax Websocket");
|
||||
if (contextHandler.getServer() == null)
|
||||
throw new IllegalStateException("Server has not been set on the ServletContextHandler");
|
||||
|
||||
JavaxWebSocketServerContainer container = contextHandler.getBean(JavaxWebSocketServerContainer.class);
|
||||
if (container==null)
|
||||
|
@ -96,8 +97,7 @@ public class JavaxWebSocketServerContainer
|
|||
|
||||
Executor executor = httpClient == null?null:httpClient.getExecutor();
|
||||
if (executor == null)
|
||||
executor = (Executor)servletContext
|
||||
.getAttribute("org.eclipse.jetty.server.Executor");
|
||||
executor = (Executor)servletContext.getAttribute("org.eclipse.jetty.server.Executor");
|
||||
if (executor == null)
|
||||
executor = contextHandler.getServer().getThreadPool();
|
||||
|
||||
|
|
Loading…
Reference in New Issue