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 7dc22dbe0c
commit 5b44b0c9ed
1 changed files with 6 additions and 4 deletions

View File

@ -73,6 +73,8 @@ public class RMContextImpl implements RMContext {
private RMApplicationHistoryWriter rmApplicationHistoryWriter;
private SystemMetricsPublisher systemMetricsPublisher;
private final Object haServiceStateLock = new Object();
/**
* Default constructor. To be used in conjunction with setter methods for
* individual fields.
@ -237,9 +239,9 @@ void setHAEnabled(boolean isHAEnabled) {
this.isHAEnabled = isHAEnabled;
}
void setHAServiceState(HAServiceState haServiceState) {
synchronized (haServiceState) {
this.haServiceState = haServiceState;
void setHAServiceState(HAServiceState serviceState) {
synchronized (haServiceStateLock) {
this.haServiceState = serviceState;
}
}
@ -335,7 +337,7 @@ public boolean isHAEnabled() {
@Override
public HAServiceState getHAServiceState() {
synchronized (haServiceState) {
synchronized (haServiceStateLock) {
return haServiceState;
}
}