diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/EncryptionZoneManager.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/EncryptionZoneManager.java index e29d4206c50..ad5869b1526 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/EncryptionZoneManager.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/EncryptionZoneManager.java @@ -417,7 +417,7 @@ public class EncryptionZoneManager { int index = 0; for (Map.Entry entry : encryptionZones .entrySet()) { - ret[index] = entry.getValue().getKeyName(); + ret[index++] = entry.getValue().getKeyName(); } return ret; } diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSDirEncryptionZoneOp.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSDirEncryptionZoneOp.java index 2997179e810..2319741c2e3 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSDirEncryptionZoneOp.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSDirEncryptionZoneOp.java @@ -370,6 +370,9 @@ final class FSDirEncryptionZoneOp { } else { NameNode.LOG.debug("Failed to warm up EDEKs.", ioe); } + } catch (Exception e) { + NameNode.LOG.error("Cannot warm up EDEKs.", e); + throw e; } try { Thread.sleep(retryInterval); diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestEncryptionZonesWithKMS.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestEncryptionZonesWithKMS.java index b29a108e9fc..959e724b58f 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestEncryptionZonesWithKMS.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestEncryptionZonesWithKMS.java @@ -100,9 +100,14 @@ public class TestEncryptionZonesWithKMS extends TestEncryptionZones { @Test(timeout = 120000) public void testWarmupEDEKCacheOnStartup() throws Exception { - final Path zonePath = new Path("/TestEncryptionZone"); + Path zonePath = new Path("/TestEncryptionZone"); fsWrapper.mkdir(zonePath, FsPermission.getDirDefault(), false); dfsAdmin.createEncryptionZone(zonePath, TEST_KEY, NO_TRASH); + final String anotherKey = "k2"; + zonePath = new Path("/TestEncryptionZone2"); + DFSTestUtil.createKey(anotherKey, cluster, conf); + fsWrapper.mkdir(zonePath, FsPermission.getDirDefault(), false); + dfsAdmin.createEncryptionZone(zonePath, anotherKey, NO_TRASH); @SuppressWarnings("unchecked") KMSClientProvider spy = (KMSClientProvider) Whitebox