提交 27942644 编写于 作者: R Rossen Stoyanchev

Fix JettyRequestUpgradeStrategy initialization bug

Closes gh-23313
上级 4edc7196
...@@ -95,7 +95,6 @@ public class JettyRequestUpgradeStrategy implements RequestUpgradeStrategy, Life ...@@ -95,7 +95,6 @@ public class JettyRequestUpgradeStrategy implements RequestUpgradeStrategy, Life
synchronized (this.lifecycleMonitor) { synchronized (this.lifecycleMonitor) {
ServletContext servletContext = this.servletContext; ServletContext servletContext = this.servletContext;
if (!isRunning() && servletContext != null) { if (!isRunning() && servletContext != null) {
this.running = true;
try { try {
this.factory = (this.webSocketPolicy != null ? this.factory = (this.webSocketPolicy != null ?
new WebSocketServerFactory(servletContext, this.webSocketPolicy) : new WebSocketServerFactory(servletContext, this.webSocketPolicy) :
...@@ -109,6 +108,7 @@ public class JettyRequestUpgradeStrategy implements RequestUpgradeStrategy, Life ...@@ -109,6 +108,7 @@ public class JettyRequestUpgradeStrategy implements RequestUpgradeStrategy, Life
return container.getAdapter(); return container.getAdapter();
}); });
this.factory.start(); this.factory.start();
this.running = true;
} }
catch (Throwable ex) { catch (Throwable ex) {
throw new IllegalStateException("Unable to start WebSocketServerFactory", ex); throw new IllegalStateException("Unable to start WebSocketServerFactory", ex);
...@@ -121,10 +121,10 @@ public class JettyRequestUpgradeStrategy implements RequestUpgradeStrategy, Life ...@@ -121,10 +121,10 @@ public class JettyRequestUpgradeStrategy implements RequestUpgradeStrategy, Life
public void stop() { public void stop() {
synchronized (this.lifecycleMonitor) { synchronized (this.lifecycleMonitor) {
if (isRunning()) { if (isRunning()) {
this.running = false;
if (this.factory != null) { if (this.factory != null) {
try { try {
this.factory.stop(); this.factory.stop();
this.running = false;
} }
catch (Throwable ex) { catch (Throwable ex) {
throw new IllegalStateException("Failed to stop WebSocketServerFactory", ex); throw new IllegalStateException("Failed to stop WebSocketServerFactory", ex);
...@@ -203,11 +203,11 @@ public class JettyRequestUpgradeStrategy implements RequestUpgradeStrategy, Life ...@@ -203,11 +203,11 @@ public class JettyRequestUpgradeStrategy implements RequestUpgradeStrategy, Life
} }
private void startLazily(HttpServletRequest request) { private void startLazily(HttpServletRequest request) {
if (this.servletContext != null) { if (isRunning()) {
return; return;
} }
synchronized (this.lifecycleMonitor) { synchronized (this.lifecycleMonitor) {
if (this.servletContext == null) { if (!isRunning()) {
this.servletContext = request.getServletContext(); this.servletContext = request.getServletContext();
start(); start();
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册