Fix JettyRequestUpgradeStrategy initialization bug
Closes gh-23313
This commit is contained in:
parent
4edc7196fb
commit
2794264480
|
|
@ -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
|
||||||
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
|
||||||
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
|
||||||
}
|
}
|
||||||
|
|
||||||
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();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue