Consistent volatile access to running flag in Lifecycle implementations

Issue: SPR-16596
Issue: SPR-16488

(cherry picked from commit d4a8f76)
This commit is contained in:
Juergen Hoeller
2018-03-15 15:17:55 +01:00
parent 6158634d67
commit b8c92ce931
15 changed files with 76 additions and 109 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2016 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.
@@ -156,7 +156,7 @@ public class GenericMessageEndpointManager implements SmartLifecycle, Initializi
private int phase = Integer.MAX_VALUE;
private boolean running = false;
private volatile boolean running = false;
private final Object lifecycleMonitor = new Object();
@@ -318,9 +318,7 @@ public class GenericMessageEndpointManager implements SmartLifecycle, Initializi
*/
@Override
public boolean isRunning() {
synchronized (this.lifecycleMonitor) {
return this.running;
}
return this.running;
}
/**