Consistent volatile access to running flag in Lifecycle implementations

Issue: SPR-16488
This commit is contained in:
Juergen Hoeller
2018-03-15 15:17:55 +01:00
parent b8d94f8a20
commit d4a8f76bf9
18 changed files with 97 additions and 136 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2017 the original author or authors.
* Copyright 2002-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -54,7 +54,7 @@ public class JettyWebSocketClient extends WebSocketClientSupport implements WebS
private final boolean externallyManaged;
private boolean running = false;
private volatile boolean running = false;
private final Object lifecycleMonitor = new Object();
@@ -135,9 +135,7 @@ public class JettyWebSocketClient extends WebSocketClientSupport implements WebS
@Override
public boolean isRunning() {
synchronized (this.lifecycleMonitor) {
return this.running;
}
return this.running;
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2017 the original author or authors.
* Copyright 2002-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -135,10 +135,6 @@ public class HandshakeWebSocketService implements WebSocketService, Lifecycle {
return this.upgradeStrategy;
}
@Override
public boolean isRunning() {
return this.running;
}
@Override
public void start() {
@@ -168,6 +164,11 @@ public class HandshakeWebSocketService implements WebSocketService, Lifecycle {
}
}
@Override
public boolean isRunning() {
return this.running;
}
@Override
public Mono<Void> handleRequest(ServerWebExchange exchange, WebSocketHandler handler) {