From 65a55f2294cc94300b27bdcbbe7f828cd233d018 Mon Sep 17 00:00:00 2001 From: Aaron Myers Date: Thu, 3 Oct 2013 00:38:00 +0000 Subject: [PATCH] HDFS-5289. Race condition in TestRetryCacheWithHA#testCreateSymlink causes spurious test failure. Contributed by Aaron T. Myers. git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1528693 13f79535-47bb-0310-9956-ffa450edef68 --- hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt | 3 +++ .../server/namenode/ha/TestRetryCacheWithHA.java | 13 +++++++++---- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt index 29b9be665d..f38e426011 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt +++ b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt @@ -388,6 +388,9 @@ Release 2.1.2 - UNRELEASED HDFS-5279. Guard against NullPointerException in NameNode JSP pages before initialization of FSNamesystem. (cnauroth) + HDFS-5289. Race condition in TestRetryCacheWithHA#testCreateSymlink causes + spurious test failure. (atm) + Release 2.1.1-beta - 2013-09-23 INCOMPATIBLE CHANGES diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/ha/TestRetryCacheWithHA.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/ha/TestRetryCacheWithHA.java index dff44a0c89..82deab5938 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/ha/TestRetryCacheWithHA.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/ha/TestRetryCacheWithHA.java @@ -20,6 +20,7 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; +import java.io.FileNotFoundException; import java.io.IOException; import java.lang.reflect.InvocationHandler; import java.lang.reflect.Method; @@ -646,10 +647,14 @@ void invoke() throws Exception { @Override boolean checkNamenodeBeforeReturn() throws Exception { Path linkPath = new Path(link); - FileStatus linkStatus = dfs.getFileLinkStatus(linkPath); + FileStatus linkStatus = null; for (int i = 0; i < CHECKTIMES && linkStatus == null; i++) { - Thread.sleep(1000); - linkStatus = dfs.getFileLinkStatus(linkPath); + try { + linkStatus = dfs.getFileLinkStatus(linkPath); + } catch (FileNotFoundException fnf) { + // Ignoring, this can be legitimate. + Thread.sleep(1000); + } } return linkStatus != null; } @@ -857,4 +862,4 @@ public void run() { + results.get(op.name)); } } -} \ No newline at end of file +}