YARN-5921. Incorrect synchronization in RMContextImpl#setHAServiceState/getHAServiceState. Contributed by Varun Saxena

(cherry picked from commit f3b8ff54ab)
This commit is contained in:
Naganarasimha 2016-12-06 06:53:38 +05:30
parent 2fdae7324b
commit 54c5880cf7
1 changed files with 6 additions and 4 deletions

View File

@ -79,6 +79,8 @@ public class RMContextImpl implements RMContext {
private QueueLimitCalculator queueLimitCalculator; private QueueLimitCalculator queueLimitCalculator;
private final Object haServiceStateLock = new Object();
/** /**
* Default constructor. To be used in conjunction with setter methods for * Default constructor. To be used in conjunction with setter methods for
* individual fields. * individual fields.
@ -253,9 +255,9 @@ public class RMContextImpl implements RMContext {
this.isHAEnabled = isHAEnabled; this.isHAEnabled = isHAEnabled;
} }
void setHAServiceState(HAServiceState haServiceState) { void setHAServiceState(HAServiceState serviceState) {
synchronized (haServiceState) { synchronized (haServiceStateLock) {
this.haServiceState = haServiceState; this.haServiceState = serviceState;
} }
} }
@ -351,7 +353,7 @@ public class RMContextImpl implements RMContext {
@Override @Override
public HAServiceState getHAServiceState() { public HAServiceState getHAServiceState() {
synchronized (haServiceState) { synchronized (haServiceStateLock) {
return haServiceState; return haServiceState;
} }
} }