HADOOP-11122. Fix findbugs in ZK DelegationTokenSecretManagers. (Arun Suresh via kasha)

This commit is contained in:
Karthik Kambatla 2014-10-22 14:26:27 -07:00
parent 7b0f9bb258
commit 70719e5c62
3 changed files with 16 additions and 15 deletions

View File

@ -994,6 +994,9 @@ Release 2.6.0 - UNRELEASED
HADOOP-11175. Fix several issues of hadoop security configuration in user
doc. (Yi Liu via cnauroth)
HADOOP-11122. Fix findbugs in ZK DelegationTokenSecretManagers.
(Arun Suresh via kasha)
Release 2.5.1 - 2014-09-05
INCOMPATIBLE CHANGES

View File

@ -163,11 +163,6 @@ protected void storeNewMasterKey(DelegationKey key) throws IOException {
return;
}
// for ZK based secretManager
protected void updateMasterKey(DelegationKey key) throws IOException{
return;
}
// RM
protected void removeStoredMasterKey(DelegationKey key) {
return;
@ -191,7 +186,7 @@ protected void updateStoredToken(TokenIdent ident, long renewDate) throws IOExce
* For subclasses externalizing the storage, for example Zookeeper
* based implementations
*/
protected int getDelegationTokenSeqNum() {
protected synchronized int getDelegationTokenSeqNum() {
return delegationTokenSequenceNumber;
}
@ -199,7 +194,7 @@ protected int getDelegationTokenSeqNum() {
* For subclasses externalizing the storage, for example Zookeeper
* based implementations
*/
protected int incrementDelegationTokenSeqNum() {
protected synchronized int incrementDelegationTokenSeqNum() {
return ++delegationTokenSequenceNumber;
}
@ -207,7 +202,7 @@ protected int incrementDelegationTokenSeqNum() {
* For subclasses externalizing the storage, for example Zookeeper
* based implementations
*/
protected void setDelegationTokenSeqNum(int seqNum) {
protected synchronized void setDelegationTokenSeqNum(int seqNum) {
delegationTokenSequenceNumber = seqNum;
}
@ -234,7 +229,6 @@ protected void storeDelegationKey(DelegationKey key) throws IOException {
*/
protected void updateDelegationKey(DelegationKey key) throws IOException {
allKeys.put(key.getKeyId(), key);
updateMasterKey(key);
}
/**

View File

@ -276,7 +276,7 @@ private String getKrb5LoginModuleName() {
}
@Override
public void startThreads() throws IOException {
public synchronized void startThreads() throws IOException {
if (!isExternalClient) {
try {
zkClient.start();
@ -402,7 +402,7 @@ private void processTokenRemoved(byte[] data) throws IOException {
}
@Override
public void stopThreads() {
public synchronized void stopThreads() {
try {
if (!isExternalClient && (zkClient != null)) {
zkClient.close();
@ -434,12 +434,12 @@ private void createPersistentNode(String nodePath) throws Exception {
}
@Override
protected int getDelegationTokenSeqNum() {
protected synchronized int getDelegationTokenSeqNum() {
return seqCounter.getCount();
}
@Override
protected int incrementDelegationTokenSeqNum() {
protected synchronized int incrementDelegationTokenSeqNum() {
try {
while (!seqCounter.trySetCount(seqCounter.getCount() + 1)) {
}
@ -450,8 +450,12 @@ protected int incrementDelegationTokenSeqNum() {
}
@Override
protected void setDelegationTokenSeqNum(int seqNum) {
delegationTokenSequenceNumber = seqNum;
protected synchronized void setDelegationTokenSeqNum(int seqNum) {
try {
seqCounter.setCount(seqNum);
} catch (Exception e) {
throw new RuntimeException("Could not set shared counter !!", e);
}
}
@Override