HDFS-10809. getNumEncryptionZones causes NPE in branch-2.7. Contributed by Vinitha Reddy Gankidi.

This commit is contained in:
Zhe Zhang 2016-08-30 11:46:52 -07:00
parent d499a8cccf
commit 85a067fd6b
2 changed files with 5 additions and 2 deletions

View File

@ -390,7 +390,8 @@ public class EncryptionZoneManager {
* @return number of encryption zones.
*/
public int getNumEncryptionZones() {
return encryptionZones.size();
return hasCreatedEncryptionZone() ?
encryptionZones.size() : 0;
}
/**

View File

@ -217,7 +217,9 @@ public class TestEncryptionZones {
public void testBasicOperations() throws Exception {
int numZones = 0;
/* Number of EZs should be 0 if no EZ is created */
assertEquals("Unexpected number of encryption zones!", numZones,
cluster.getNamesystem().getNumEncryptionZones());
/* Test failure of create EZ on a directory that doesn't exist. */
final Path zoneParent = new Path("/zones");
final Path zone1 = new Path(zoneParent, "zone1");