From 383e1c5f737f84fad658e5c7aed48be81c207f38 Mon Sep 17 00:00:00 2001 From: Vinayakumar B Date: Tue, 6 Jan 2015 09:15:23 +0530 Subject: [PATCH] HADOOP-11459. Fix recent findbugs in ActiveStandbyElector, NetUtils and ShellBasedIdMapping (Contributed by Vinayakumar B) (cherry picked from commit 9803ae374f69942aec82ec6eeeb9722523a1ade0) --- hadoop-common-project/hadoop-common/CHANGES.txt | 5 ++++- .../main/java/org/apache/hadoop/ha/ActiveStandbyElector.java | 4 +++- .../src/main/java/org/apache/hadoop/net/NetUtils.java | 2 +- .../java/org/apache/hadoop/security/ShellBasedIdMapping.java | 2 +- 4 files changed, 9 insertions(+), 4 deletions(-) diff --git a/hadoop-common-project/hadoop-common/CHANGES.txt b/hadoop-common-project/hadoop-common/CHANGES.txt index 7a57ef03d6b..f0a1aaeedd3 100644 --- a/hadoop-common-project/hadoop-common/CHANGES.txt +++ b/hadoop-common-project/hadoop-common/CHANGES.txt @@ -318,7 +318,10 @@ Release 2.7.0 - UNRELEASED HADOOP-11446. S3AOutputStream should use shared thread pool to avoid OutOfMemoryError. (Ted Yu via stevel) - + + HADOOP-11459. Fix recent findbugs in ActiveStandbyElector, NetUtils + and ShellBasedIdMapping (vinayakumarb) + Release 2.6.0 - 2014-11-18 INCOMPATIBLE CHANGES diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/ha/ActiveStandbyElector.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/ha/ActiveStandbyElector.java index 123f119f709..947baa93e1e 100644 --- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/ha/ActiveStandbyElector.java +++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/ha/ActiveStandbyElector.java @@ -1064,7 +1064,9 @@ public class ActiveStandbyElector implements StatCallback, StringCallback { public void process(WatchedEvent event) { hasReceivedEvent.countDown(); try { - hasSetZooKeeper.await(zkSessionTimeout, TimeUnit.MILLISECONDS); + if (!hasSetZooKeeper.await(zkSessionTimeout, TimeUnit.MILLISECONDS)) { + LOG.debug("Event received with stale zk"); + } ActiveStandbyElector.this.processWatchEvent( zk, event); } catch (Throwable t) { diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/net/NetUtils.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/net/NetUtils.java index ffee4022678..ef1092bb2f7 100644 --- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/net/NetUtils.java +++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/net/NetUtils.java @@ -288,7 +288,7 @@ public class NetUtils { try { fqHost = SecurityUtil.getByName(host).getHostName(); // slight race condition, but won't hurt - canonicalizedHostCache.put(host, fqHost); + canonicalizedHostCache.putIfAbsent(host, fqHost); } catch (UnknownHostException e) { fqHost = host; } diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/security/ShellBasedIdMapping.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/security/ShellBasedIdMapping.java index 428e8353ed5..28ab2484229 100644 --- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/security/ShellBasedIdMapping.java +++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/security/ShellBasedIdMapping.java @@ -290,7 +290,7 @@ public class ShellBasedIdMapping implements IdMappingServiceProvider { return true; } - private void initStaticMapping() throws IOException { + private synchronized void initStaticMapping() throws IOException { staticMapping = new StaticMapping( new HashMap(), new HashMap()); if (staticMappingFile.exists()) {