Core: Fix NPE. The future field is set from a different thread.

Closes #10630
This commit is contained in:
Martijn van Groningen 2015-04-16 15:07:18 +02:00
parent af191d7888
commit 161e74029f

View File

@ -525,7 +525,7 @@ public class InternalClusterService extends AbstractLifecycleComponent<ClusterSe
class NotifyTimeout implements Runnable { class NotifyTimeout implements Runnable {
final TimeoutClusterStateListener listener; final TimeoutClusterStateListener listener;
final TimeValue timeout; final TimeValue timeout;
ScheduledFuture future; volatile ScheduledFuture future;
NotifyTimeout(TimeoutClusterStateListener listener, TimeValue timeout) { NotifyTimeout(TimeoutClusterStateListener listener, TimeValue timeout) {
this.listener = listener; this.listener = listener;
@ -538,7 +538,7 @@ public class InternalClusterService extends AbstractLifecycleComponent<ClusterSe
@Override @Override
public void run() { public void run() {
if (future.isCancelled()) { if (future != null && future.isCancelled()) {
return; return;
} }
if (lifecycle.stoppedOrClosed()) { if (lifecycle.stoppedOrClosed()) {