From c0733db768f158eaeecf769381c7b9e9701183c1 Mon Sep 17 00:00:00 2001 From: Arpit Agarwal Date: Thu, 17 Dec 2015 13:43:27 -0800 Subject: [PATCH] HDFS-9515. NPE when MiniDFSCluster#shutdown is invoked on uninitialized reference. (Contributed by Wei-Chiu Chuang) --- hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt | 3 +++ .../bkjournal/TestBootstrapStandbyWithBKJM.java | 1 + .../org/apache/hadoop/TestRefreshCallQueue.java | 1 + .../java/org/apache/hadoop/cli/TestAclCLI.java | 2 ++ .../apache/hadoop/cli/TestCacheAdminCLI.java | 2 ++ .../apache/hadoop/cli/TestCryptoAdminCLI.java | 2 ++ .../org/apache/hadoop/cli/TestDeleteCLI.java | 2 ++ .../java/org/apache/hadoop/cli/TestHDFSCLI.java | 2 ++ .../org/apache/hadoop/cli/TestXAttrCLI.java | 2 ++ .../apache/hadoop/fs/TestFcHdfsCreateMkdir.java | 4 +++- .../apache/hadoop/fs/TestFcHdfsPermission.java | 4 +++- .../apache/hadoop/fs/TestFcHdfsSetUMask.java | 4 +++- .../org/apache/hadoop/fs/TestSymlinkHdfs.java | 4 +++- .../hadoop/fs/contract/hdfs/HDFSContract.java | 1 + .../hadoop/fs/shell/TestHdfsTextCommand.java | 2 ++ .../fs/viewfs/TestViewFileSystemHdfs.java | 4 +++- .../fs/viewfs/TestViewFileSystemWithAcls.java | 4 +++- .../fs/viewfs/TestViewFileSystemWithXAttrs.java | 4 +++- .../hadoop/fs/viewfs/TestViewFsAtHdfsRoot.java | 4 +++- .../apache/hadoop/fs/viewfs/TestViewFsHdfs.java | 4 +++- .../hadoop/fs/viewfs/TestViewFsWithAcls.java | 4 +++- .../hadoop/fs/viewfs/TestViewFsWithXAttrs.java | 4 +++- .../org/apache/hadoop/hdfs/FileAppendTest4.java | 4 +++- .../apache/hadoop/hdfs/TestAbandonBlock.java | 10 ++++++++-- .../hadoop/hdfs/TestBlocksScheduledCounter.java | 2 ++ .../hadoop/hdfs/TestClientReportBadBlock.java | 10 ++++++++-- .../hadoop/hdfs/TestDFSClientExcludedNodes.java | 1 + .../hadoop/hdfs/TestDFSClientFailover.java | 1 + .../hadoop/hdfs/TestDFSClientSocketSize.java | 1 + .../org/apache/hadoop/hdfs/TestDFSFinalize.java | 5 ++++- .../apache/hadoop/hdfs/TestDFSOutputStream.java | 4 +++- .../apache/hadoop/hdfs/TestDFSPermission.java | 1 + .../org/apache/hadoop/hdfs/TestDFSRollback.java | 5 ++++- .../hadoop/hdfs/TestDFSStartupVersions.java | 5 ++++- .../hdfs/TestDFSStorageStateRecovery.java | 5 ++++- .../hadoop/hdfs/TestDataTransferKeepalive.java | 5 ++++- .../apache/hadoop/hdfs/TestDecommission.java | 1 + .../apache/hadoop/hdfs/TestEncryptionZones.java | 1 + .../hadoop/hdfs/TestEncryptionZonesWithHA.java | 1 + .../hadoop/hdfs/TestFileConcurrentReader.java | 6 ++++-- .../org/apache/hadoop/hdfs/TestFileStatus.java | 8 ++++++-- .../apache/hadoop/hdfs/TestGetFileChecksum.java | 1 + .../hadoop/hdfs/TestHDFSFileSystemContract.java | 6 ++++-- .../org/apache/hadoop/hdfs/TestHdfsAdmin.java | 1 + .../apache/hadoop/hdfs/TestLeaseRecovery.java | 1 + .../apache/hadoop/hdfs/TestLeaseRecovery2.java | 6 ++++-- .../apache/hadoop/hdfs/TestListFilesInDFS.java | 6 ++++-- .../hadoop/hdfs/TestListFilesInFileContext.java | 4 +++- .../org/apache/hadoop/hdfs/TestPipelines.java | 5 ++++- .../hadoop/hdfs/TestReservedRawPaths.java | 1 + .../org/apache/hadoop/hdfs/TestSafeMode.java | 2 ++ .../org/apache/hadoop/hdfs/TestWriteRead.java | 5 ++++- .../datatransfer/sasl/TestSaslDataTransfer.java | 1 + .../hdfs/qjournal/TestSecureNNWithQJM.java | 2 ++ .../client/TestQuorumJournalManager.java | 1 + .../qjournal/server/TestJournalNodeMXBean.java | 1 + .../hdfs/security/TestDelegationToken.java | 1 + .../blockmanagement/TestBlockStatsMXBean.java | 1 + .../TestComputeInvalidateWork.java | 1 + .../TestPendingInvalidateBlock.java | 1 + .../server/datanode/BlockReportTestBase.java | 2 ++ .../hdfs/server/datanode/TestDataNodeExit.java | 4 +++- .../datanode/TestDataNodeVolumeFailure.java | 3 +++ .../TestDataNodeVolumeFailureReporting.java | 1 + .../TestDataNodeVolumeFailureToleration.java | 1 + .../hdfs/server/datanode/TestDiskError.java | 5 ++++- .../server/datanode/TestFsDatasetCache.java | 2 ++ .../datanode/TestIncrementalBrVariations.java | 11 +++++++---- .../hdfs/server/namenode/TestAclConfigFlag.java | 1 + .../hdfs/server/namenode/TestAddBlock.java | 1 + .../hdfs/server/namenode/TestAddBlockRetry.java | 1 + .../hdfs/server/namenode/TestAuditLogs.java | 10 ++++++++-- .../hdfs/server/namenode/TestBackupNode.java | 4 +++- ...stBlockPlacementPolicyRackFaultTolerant.java | 1 + .../server/namenode/TestCacheDirectives.java | 1 + .../TestCommitBlockWithInvalidGenStamp.java | 1 + .../hdfs/server/namenode/TestDeadDatanode.java | 5 ++++- .../TestDefaultBlockPlacementPolicy.java | 1 + .../namenode/TestDiskspaceQuotaUpdate.java | 1 + .../server/namenode/TestEditLogAutoroll.java | 2 ++ .../namenode/TestEditLogJournalFailures.java | 5 ++++- .../hdfs/server/namenode/TestFSDirectory.java | 1 + .../server/namenode/TestFSImageWithAcl.java | 4 +++- .../namenode/TestFSImageWithSnapshot.java | 1 + .../server/namenode/TestFSImageWithXAttr.java | 4 +++- .../hdfs/server/namenode/TestFileTruncate.java | 10 ++++++++-- .../hdfs/server/namenode/TestHDFSConcat.java | 2 ++ .../namenode/TestINodeAttributeProvider.java | 1 + .../hdfs/server/namenode/TestMalformedURLs.java | 1 + .../namenode/TestMetadataVersionOutput.java | 1 + .../TestNameNodeMetadataConsistency.java | 1 + .../namenode/TestNameNodeRetryCacheMetrics.java | 1 + .../namenode/TestNameNodeRpcServerMethods.java | 4 +++- .../server/namenode/TestNamenodeRetryCache.java | 5 ++++- .../server/namenode/TestQuotaByStorageType.java | 1 + .../server/namenode/TestXAttrConfigFlag.java | 1 + .../namenode/ha/TestBootstrapStandby.java | 1 + .../ha/TestBootstrapStandbyWithQJM.java | 2 ++ .../hdfs/server/namenode/ha/TestDNFencing.java | 1 + .../namenode/ha/TestDelegationTokensWithHA.java | 1 + .../ha/TestFailoverWithBlockTokensEnabled.java | 1 + .../namenode/ha/TestFailureToReadEdits.java | 3 +++ .../server/namenode/ha/TestGetGroupsWithHA.java | 1 + .../hdfs/server/namenode/ha/TestHASafeMode.java | 1 + .../namenode/ha/TestInitializeSharedEdits.java | 1 + .../server/namenode/ha/TestNNHealthCheck.java | 1 + .../server/namenode/ha/TestQuotasWithHA.java | 1 + .../namenode/ha/TestRetryCacheWithHA.java | 1 + .../namenode/ha/TestStandbyCheckpoints.java | 1 + .../server/namenode/ha/TestXAttrsWithHA.java | 1 + .../TestNNMetricFilesInGetListingOps.java | 5 ++++- .../namenode/metrics/TestNameNodeMetrics.java | 5 ++++- .../snapshot/TestFileContextSnapshot.java | 1 + .../TestGetContentSummaryWithSnapshot.java | 1 + ...tINodeFileUnderConstructionWithSnapshot.java | 1 + .../namenode/snapshot/TestNestedSnapshots.java | 1 + .../snapshot/TestOpenFilesWithSnapshot.java | 2 ++ .../snapshot/TestRenameWithSnapshots.java | 1 + .../snapshot/TestSetQuotaWithSnapshot.java | 1 + .../server/namenode/snapshot/TestSnapshot.java | 1 + .../snapshot/TestSnapshotBlocksMap.java | 1 + .../namenode/snapshot/TestSnapshotDeletion.java | 1 + .../snapshot/TestSnapshotDiffReport.java | 1 + .../namenode/snapshot/TestSnapshotListing.java | 1 + .../namenode/snapshot/TestSnapshotMetrics.java | 1 + .../namenode/snapshot/TestSnapshotRename.java | 1 + .../snapshot/TestSnapshotReplication.java | 1 + .../snapshot/TestSnapshottableDirListing.java | 1 + .../hdfs/tools/TestDFSHAAdminMiniCluster.java | 5 ++++- .../hdfs/tools/TestDFSZKFailoverController.java | 8 +++++++- .../apache/hadoop/hdfs/tools/TestGetGroups.java | 5 ++++- .../hdfs/tools/TestStoragePolicyCommands.java | 2 ++ .../hadoop/hdfs/web/TestHttpsFileSystem.java | 4 +++- .../TestWebHdfsWithAuthenticationFilter.java | 8 ++++++-- .../security/TestRefreshUserMappings.java | 2 ++ .../org/apache/hadoop/tools/TestJMXGet.java | 17 ++++++++++------- .../org/apache/hadoop/tracing/TestTracing.java | 5 ++++- 137 files changed, 320 insertions(+), 68 deletions(-) diff --git a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt index c6a9ead9d10..844f867d959 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt +++ b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt @@ -1645,6 +1645,9 @@ Release 2.8.0 - UNRELEASED HDFS-9570. Minor typos, grammar, and case sensitivity cleanup in HdfsPermissionsGuide.md's (Travis Campbell via aw) + HDFS-9515. NPE when MiniDFSCluster#shutdown is invoked on uninitialized + reference. (Wei-Chiu Chuang via Arpit Agarwal) + Release 2.7.3 - UNRELEASED INCOMPATIBLE CHANGES diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/contrib/bkjournal/src/test/java/org/apache/hadoop/contrib/bkjournal/TestBootstrapStandbyWithBKJM.java b/hadoop-hdfs-project/hadoop-hdfs/src/contrib/bkjournal/src/test/java/org/apache/hadoop/contrib/bkjournal/TestBootstrapStandbyWithBKJM.java index ded9e0e99cb..1c3d650a758 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/contrib/bkjournal/src/test/java/org/apache/hadoop/contrib/bkjournal/TestBootstrapStandbyWithBKJM.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/contrib/bkjournal/src/test/java/org/apache/hadoop/contrib/bkjournal/TestBootstrapStandbyWithBKJM.java @@ -63,6 +63,7 @@ public class TestBootstrapStandbyWithBKJM { public void teardown() { if (cluster != null) { cluster.shutdown(); + cluster = null; } } diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/TestRefreshCallQueue.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/TestRefreshCallQueue.java index f66f9b6105f..1be2752fe0a 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/TestRefreshCallQueue.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/TestRefreshCallQueue.java @@ -86,6 +86,7 @@ public class TestRefreshCallQueue { public void tearDown() throws Exception { if(cluster!=null) { cluster.shutdown(); + cluster = null; } } diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/cli/TestAclCLI.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/cli/TestAclCLI.java index a6f8651b355..061d328a52c 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/cli/TestAclCLI.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/cli/TestAclCLI.java @@ -49,9 +49,11 @@ public class TestAclCLI extends CLITestHelperDFS { super.tearDown(); if (fs != null) { fs.close(); + fs = null; } if (cluster != null) { cluster.shutdown(); + cluster = null; } } diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/cli/TestCacheAdminCLI.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/cli/TestCacheAdminCLI.java index ddb11b6cf0f..28321cb6131 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/cli/TestCacheAdminCLI.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/cli/TestCacheAdminCLI.java @@ -76,9 +76,11 @@ public class TestCacheAdminCLI extends CLITestHelper { public void tearDown() throws Exception { if (fs != null) { fs.close(); + fs = null; } if (dfsCluster != null) { dfsCluster.shutdown(); + dfsCluster = null; } Thread.sleep(2000); super.tearDown(); diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/cli/TestCryptoAdminCLI.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/cli/TestCryptoAdminCLI.java index 44e662fac97..bd5349d82d6 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/cli/TestCryptoAdminCLI.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/cli/TestCryptoAdminCLI.java @@ -86,9 +86,11 @@ public class TestCryptoAdminCLI extends CLITestHelperDFS { public void tearDown() throws Exception { if (fs != null) { fs.close(); + fs = null; } if (dfsCluster != null) { dfsCluster.shutdown(); + dfsCluster = null; } Thread.sleep(2000); super.tearDown(); diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/cli/TestDeleteCLI.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/cli/TestDeleteCLI.java index 04328f52800..4c27f79e16a 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/cli/TestDeleteCLI.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/cli/TestDeleteCLI.java @@ -58,9 +58,11 @@ public class TestDeleteCLI extends CLITestHelperDFS { public void tearDown() throws Exception { if (fs != null) { fs.close(); + fs = null; } if (dfsCluster != null) { dfsCluster.shutdown(); + dfsCluster = null; } Thread.sleep(2000); super.tearDown(); diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/cli/TestHDFSCLI.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/cli/TestHDFSCLI.java index 36307262874..e0e78941c73 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/cli/TestHDFSCLI.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/cli/TestHDFSCLI.java @@ -77,9 +77,11 @@ public class TestHDFSCLI extends CLITestHelperDFS { public void tearDown() throws Exception { if (fs != null) { fs.close(); + fs = null; } if (dfsCluster != null) { dfsCluster.shutdown(); + dfsCluster = null; } Thread.sleep(2000); super.tearDown(); diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/cli/TestXAttrCLI.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/cli/TestXAttrCLI.java index 45c7909c17c..d83baf3a971 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/cli/TestXAttrCLI.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/cli/TestXAttrCLI.java @@ -67,9 +67,11 @@ public class TestXAttrCLI extends CLITestHelperDFS { public void tearDown() throws Exception { if (fs != null) { fs.close(); + fs = null; } if (dfsCluster != null) { dfsCluster.shutdown(); + dfsCluster = null; } Thread.sleep(2000); super.tearDown(); diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/fs/TestFcHdfsCreateMkdir.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/fs/TestFcHdfsCreateMkdir.java index 40dbc4e88c9..0d3e6ff8379 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/fs/TestFcHdfsCreateMkdir.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/fs/TestFcHdfsCreateMkdir.java @@ -58,7 +58,9 @@ public class TestFcHdfsCreateMkdir extends @AfterClass public static void ClusterShutdownAtEnd() throws Exception { - cluster.shutdown(); + if (cluster != null) { + cluster.shutdown(); + } } @Override diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/fs/TestFcHdfsPermission.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/fs/TestFcHdfsPermission.java index 4f72e4e2ba7..4e0e40e8bc8 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/fs/TestFcHdfsPermission.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/fs/TestFcHdfsPermission.java @@ -66,7 +66,9 @@ public class TestFcHdfsPermission extends FileContextPermissionBase { @AfterClass public static void ClusterShutdownAtEnd() throws Exception { - cluster.shutdown(); + if (cluster != null) { + cluster.shutdown(); + } } @Override diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/fs/TestFcHdfsSetUMask.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/fs/TestFcHdfsSetUMask.java index 34fbe7f4f1d..09163472ca0 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/fs/TestFcHdfsSetUMask.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/fs/TestFcHdfsSetUMask.java @@ -96,7 +96,9 @@ public class TestFcHdfsSetUMask { @AfterClass public static void ClusterShutdownAtEnd() throws Exception { - cluster.shutdown(); + if (cluster != null) { + cluster.shutdown(); + } } { diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/fs/TestSymlinkHdfs.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/fs/TestSymlinkHdfs.java index 7f7cd86a988..3b89960d195 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/fs/TestSymlinkHdfs.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/fs/TestSymlinkHdfs.java @@ -98,7 +98,9 @@ abstract public class TestSymlinkHdfs extends SymlinkBaseTest { @AfterClass public static void afterClassTeardown() throws Exception { - cluster.shutdown(); + if (cluster != null) { + cluster.shutdown(); + } } @Test(timeout=10000) diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/fs/contract/hdfs/HDFSContract.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/fs/contract/hdfs/HDFSContract.java index 258703af5b7..74b9a35adfc 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/fs/contract/hdfs/HDFSContract.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/fs/contract/hdfs/HDFSContract.java @@ -62,6 +62,7 @@ public class HDFSContract extends AbstractFSContract { public static void destroyCluster() throws IOException { if (cluster != null) { cluster.shutdown(); + cluster = null; } } diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/fs/shell/TestHdfsTextCommand.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/fs/shell/TestHdfsTextCommand.java index b20040d9cec..9b563291051 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/fs/shell/TestHdfsTextCommand.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/fs/shell/TestHdfsTextCommand.java @@ -60,9 +60,11 @@ public class TestHdfsTextCommand { public void tearDown() throws IOException{ if(fs != null){ fs.close(); + fs = null; } if(cluster != null){ cluster.shutdown(); + cluster = null; } } diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/fs/viewfs/TestViewFileSystemHdfs.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/fs/viewfs/TestViewFileSystemHdfs.java index 24dd7a34d25..92213172784 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/fs/viewfs/TestViewFileSystemHdfs.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/fs/viewfs/TestViewFileSystemHdfs.java @@ -88,7 +88,9 @@ public class TestViewFileSystemHdfs extends ViewFileSystemBaseTest { @AfterClass public static void ClusterShutdownAtEnd() throws Exception { - cluster.shutdown(); + if (cluster != null) { + cluster.shutdown(); + } } @Override diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/fs/viewfs/TestViewFileSystemWithAcls.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/fs/viewfs/TestViewFileSystemWithAcls.java index 68dd7f2239f..a3e56570863 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/fs/viewfs/TestViewFileSystemWithAcls.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/fs/viewfs/TestViewFileSystemWithAcls.java @@ -76,7 +76,9 @@ public class TestViewFileSystemWithAcls { @AfterClass public static void ClusterShutdownAtEnd() throws Exception { - cluster.shutdown(); + if (cluster != null) { + cluster.shutdown(); + } } @Before diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/fs/viewfs/TestViewFileSystemWithXAttrs.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/fs/viewfs/TestViewFileSystemWithXAttrs.java index 227548de99d..b487188c4e1 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/fs/viewfs/TestViewFileSystemWithXAttrs.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/fs/viewfs/TestViewFileSystemWithXAttrs.java @@ -71,7 +71,9 @@ public class TestViewFileSystemWithXAttrs { @AfterClass public static void ClusterShutdownAtEnd() throws Exception { - cluster.shutdown(); + if (cluster != null) { + cluster.shutdown(); + } } @Before diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/fs/viewfs/TestViewFsAtHdfsRoot.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/fs/viewfs/TestViewFsAtHdfsRoot.java index 9fb3a5b5cc7..88664651883 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/fs/viewfs/TestViewFsAtHdfsRoot.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/fs/viewfs/TestViewFsAtHdfsRoot.java @@ -64,7 +64,9 @@ public class TestViewFsAtHdfsRoot extends ViewFsBaseTest { @AfterClass public static void ClusterShutdownAtEnd() throws Exception { - cluster.shutdown(); + if (cluster != null) { + cluster.shutdown(); + } } @Override diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/fs/viewfs/TestViewFsHdfs.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/fs/viewfs/TestViewFsHdfs.java index 96a395cfa34..fda667251b8 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/fs/viewfs/TestViewFsHdfs.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/fs/viewfs/TestViewFsHdfs.java @@ -64,7 +64,9 @@ public class TestViewFsHdfs extends ViewFsBaseTest { @AfterClass public static void ClusterShutdownAtEnd() throws Exception { - cluster.shutdown(); + if (cluster != null) { + cluster.shutdown(); + } } @Override diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/fs/viewfs/TestViewFsWithAcls.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/fs/viewfs/TestViewFsWithAcls.java index 70918e9d2b5..e7e664857c8 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/fs/viewfs/TestViewFsWithAcls.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/fs/viewfs/TestViewFsWithAcls.java @@ -76,7 +76,9 @@ public class TestViewFsWithAcls { @AfterClass public static void ClusterShutdownAtEnd() throws Exception { - cluster.shutdown(); + if (cluster != null) { + cluster.shutdown(); + } } @Before diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/fs/viewfs/TestViewFsWithXAttrs.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/fs/viewfs/TestViewFsWithXAttrs.java index 431f851406b..9a4223a86fe 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/fs/viewfs/TestViewFsWithXAttrs.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/fs/viewfs/TestViewFsWithXAttrs.java @@ -70,7 +70,9 @@ public class TestViewFsWithXAttrs { @AfterClass public static void ClusterShutdownAtEnd() throws Exception { - cluster.shutdown(); + if (cluster != null) { + cluster.shutdown(); + } } @Before diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/FileAppendTest4.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/FileAppendTest4.java index 6b9c138f66b..9e7b598b9bd 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/FileAppendTest4.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/FileAppendTest4.java @@ -68,7 +68,9 @@ public class FileAppendTest4 { @AfterClass public static void tearDown() { - cluster.shutdown(); + if (cluster != null) { + cluster.shutdown(); + } } /** diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestAbandonBlock.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestAbandonBlock.java index 22a471e759b..301f6a7d730 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestAbandonBlock.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestAbandonBlock.java @@ -56,8 +56,14 @@ public class TestAbandonBlock { @After public void tearDown() throws Exception { - fs.close(); - cluster.shutdown(); + if (fs != null) { + fs.close(); + fs = null; + } + if (cluster != null) { + cluster.shutdown(); + cluster = null; + } } @Test diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestBlocksScheduledCounter.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestBlocksScheduledCounter.java index a66cd1d8b58..b9432197489 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestBlocksScheduledCounter.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestBlocksScheduledCounter.java @@ -43,9 +43,11 @@ public class TestBlocksScheduledCounter { public void tearDown() throws IOException { if (fs != null) { fs.close(); + fs = null; } if(cluster!=null){ cluster.shutdown(); + cluster = null; } } diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestClientReportBadBlock.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestClientReportBadBlock.java index 6b2eb3c2e03..ce2e79b73e4 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestClientReportBadBlock.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestClientReportBadBlock.java @@ -82,8 +82,14 @@ public class TestClientReportBadBlock { @After public void shutDownCluster() throws IOException { - dfs.close(); - cluster.shutdown(); + if (dfs != null) { + dfs.close(); + dfs = null; + } + if (cluster != null) { + cluster.shutdown(); + cluster = null; + } } /* diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestDFSClientExcludedNodes.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestDFSClientExcludedNodes.java index c253f475df5..59cc1540716 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestDFSClientExcludedNodes.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestDFSClientExcludedNodes.java @@ -54,6 +54,7 @@ public class TestDFSClientExcludedNodes { public void tearDown() { if (cluster != null) { cluster.shutdown(); + cluster = null; } } diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestDFSClientFailover.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestDFSClientFailover.java index 60ffe30a74d..75635193eb2 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestDFSClientFailover.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestDFSClientFailover.java @@ -88,6 +88,7 @@ public class TestDFSClientFailover { public void tearDownCluster() throws IOException { if (cluster != null) { cluster.shutdown(); + cluster = null; } } diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestDFSClientSocketSize.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestDFSClientSocketSize.java index aaeaa0181b9..23765763d36 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestDFSClientSocketSize.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestDFSClientSocketSize.java @@ -82,6 +82,7 @@ public class TestDFSClientSocketSize { if (cluster != null) { LOG.info("Shutting down MiniDFSCluster."); cluster.shutdown(); + cluster = null; } } diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestDFSFinalize.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestDFSFinalize.java index 39d3c96f6d6..d0df9fecf59 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestDFSFinalize.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestDFSFinalize.java @@ -188,7 +188,10 @@ public class TestDFSFinalize { @After public void tearDown() throws Exception { LOG.info("Shutting down MiniDFSCluster"); - if (cluster != null) cluster.shutdown(); + if (cluster != null) { + cluster.shutdown(); + cluster = null; + } } public static void main(String[] args) throws Exception { diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestDFSOutputStream.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestDFSOutputStream.java index 821d259100f..a404ac8174f 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestDFSOutputStream.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestDFSOutputStream.java @@ -150,6 +150,8 @@ public class TestDFSOutputStream { @AfterClass public static void tearDown() { - cluster.shutdown(); + if (cluster != null) { + cluster.shutdown(); + } } } diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestDFSPermission.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestDFSPermission.java index 80b2eb44122..8f2f0a04e87 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestDFSPermission.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestDFSPermission.java @@ -123,6 +123,7 @@ public class TestDFSPermission { public void tearDown() throws IOException { if (cluster != null) { cluster.shutdown(); + cluster = null; } } diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestDFSRollback.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestDFSRollback.java index 3fe562608ec..25eb5b685db 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestDFSRollback.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestDFSRollback.java @@ -346,7 +346,10 @@ public class TestDFSRollback { @After public void tearDown() throws Exception { LOG.info("Shutting down MiniDFSCluster"); - if (cluster != null) cluster.shutdown(); + if (cluster != null) { + cluster.shutdown(); + cluster = null; + } } public static void main(String[] args) throws Exception { diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestDFSStartupVersions.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestDFSStartupVersions.java index 3a27be6104e..d2022234b88 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestDFSStartupVersions.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestDFSStartupVersions.java @@ -282,7 +282,10 @@ public class TestDFSStartupVersions { @After public void tearDown() throws Exception { LOG.info("Shutting down MiniDFSCluster"); - if (cluster != null) cluster.shutdown(); + if (cluster != null) { + cluster.shutdown(); + cluster = null; + } } public static void main(String[] args) throws Exception { diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestDFSStorageStateRecovery.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestDFSStorageStateRecovery.java index fe49dab93aa..3f3ff7c0b4c 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestDFSStorageStateRecovery.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestDFSStorageStateRecovery.java @@ -452,6 +452,9 @@ public class TestDFSStorageStateRecovery { @After public void tearDown() throws Exception { LOG.info("Shutting down MiniDFSCluster"); - if (cluster != null) cluster.shutdown(); + if (cluster != null) { + cluster.shutdown(); + cluster = null; + } } } \ No newline at end of file diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestDataTransferKeepalive.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestDataTransferKeepalive.java index dbe2f1e5d17..9e3ddcfbc9a 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestDataTransferKeepalive.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestDataTransferKeepalive.java @@ -69,7 +69,10 @@ public class TestDataTransferKeepalive { @After public void teardown() { - cluster.shutdown(); + if (cluster != null) { + cluster.shutdown(); + cluster = null; + } } /** diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestDecommission.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestDecommission.java index 396e50c50aa..1d5ebbfbf95 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestDecommission.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestDecommission.java @@ -126,6 +126,7 @@ public class TestDecommission { cleanupFile(localFileSys, dir); if (cluster != null) { cluster.shutdown(); + cluster = null; } } diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestEncryptionZones.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestEncryptionZones.java index 18637f3edf5..de696b8a559 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestEncryptionZones.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestEncryptionZones.java @@ -170,6 +170,7 @@ public class TestEncryptionZones { public void teardown() { if (cluster != null) { cluster.shutdown(); + cluster = null; } EncryptionFaultInjector.instance = new EncryptionFaultInjector(); } diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestEncryptionZonesWithHA.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestEncryptionZonesWithHA.java index e61a02b45e6..476d024c7d6 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestEncryptionZonesWithHA.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestEncryptionZonesWithHA.java @@ -87,6 +87,7 @@ public class TestEncryptionZonesWithHA { public void shutdownCluster() throws IOException { if (cluster != null) { cluster.shutdown(); + cluster = null; } } diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestFileConcurrentReader.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestFileConcurrentReader.java index cd0daf7eb11..e0a0d3be2ed 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestFileConcurrentReader.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestFileConcurrentReader.java @@ -84,8 +84,10 @@ public class TestFileConcurrentReader { @After public void tearDown() throws Exception { - cluster.shutdown(); - cluster = null; + if (cluster != null) { + cluster.shutdown(); + cluster = null; + } } private void init(Configuration conf) throws IOException { diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestFileStatus.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestFileStatus.java index e3dcd8c83dc..ad13bf21d66 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestFileStatus.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestFileStatus.java @@ -82,8 +82,12 @@ public class TestFileStatus { @AfterClass public static void testTearDown() throws Exception { - fs.close(); - cluster.shutdown(); + if (fs != null) { + fs.close(); + } + if (cluster != null) { + cluster.shutdown(); + } } private static void writeFile(FileSystem fileSys, Path name, int repl, diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestGetFileChecksum.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestGetFileChecksum.java index 814261f7fe7..cf61e8451bf 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestGetFileChecksum.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestGetFileChecksum.java @@ -52,6 +52,7 @@ public class TestGetFileChecksum { public void tearDown() throws Exception { if (cluster != null) { cluster.shutdown(); + cluster = null; } } diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestHDFSFileSystemContract.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestHDFSFileSystemContract.java index f19386b4edd..c1bf6f2f28f 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestHDFSFileSystemContract.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestHDFSFileSystemContract.java @@ -45,8 +45,10 @@ public class TestHDFSFileSystemContract extends FileSystemContractBaseTest { @Override protected void tearDown() throws Exception { super.tearDown(); - cluster.shutdown(); - cluster = null; + if (cluster != null) { + cluster.shutdown(); + cluster = null; + } } @Override diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestHdfsAdmin.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestHdfsAdmin.java index 245652abde2..0f5bdf5c21d 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestHdfsAdmin.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestHdfsAdmin.java @@ -47,6 +47,7 @@ public class TestHdfsAdmin { public void shutDownCluster() { if (cluster != null) { cluster.shutdown(); + cluster = null; } } diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestLeaseRecovery.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestLeaseRecovery.java index 4ae130df3d2..d62194c16a2 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestLeaseRecovery.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestLeaseRecovery.java @@ -57,6 +57,7 @@ public class TestLeaseRecovery { public void shutdown() throws IOException { if (cluster != null) { cluster.shutdown(); + cluster = null; } } diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestLeaseRecovery2.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestLeaseRecovery2.java index 8c389ec0450..13e864441d6 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestLeaseRecovery2.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestLeaseRecovery2.java @@ -101,8 +101,10 @@ public class TestLeaseRecovery2 { */ @AfterClass public static void tearDown() throws IOException { - IOUtils.closeStream(dfs); - if (cluster != null) {cluster.shutdown();} + if (cluster != null) { + IOUtils.closeStream(dfs); + cluster.shutdown(); + } } /** diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestListFilesInDFS.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestListFilesInDFS.java index 5936d8447dc..53b21d0b514 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestListFilesInDFS.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestListFilesInDFS.java @@ -46,8 +46,10 @@ public class TestListFilesInDFS extends TestListFiles { @AfterClass public static void testShutdown() throws Exception { - fs.close(); - cluster.shutdown(); + if (cluster != null) { + fs.close(); + cluster.shutdown(); + } } protected static Path getTestDir() { diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestListFilesInFileContext.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestListFilesInFileContext.java index 4b0bac94bdf..1e424177e95 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestListFilesInFileContext.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestListFilesInFileContext.java @@ -83,7 +83,9 @@ public class TestListFilesInFileContext { @AfterClass public static void testShutdown() throws Exception { - cluster.shutdown(); + if (cluster != null) { + cluster.shutdown(); + } } /** Test when input path is a file */ diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestPipelines.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestPipelines.java index c9831b0e017..5804d35fef7 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestPipelines.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestPipelines.java @@ -65,11 +65,14 @@ public class TestPipelines { @After public void shutDownCluster() throws IOException { - if (fs != null) + if (fs != null) { fs.close(); + fs = null; + } if (cluster != null) { cluster.shutdownDataNodes(); cluster.shutdown(); + cluster = null; } } diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestReservedRawPaths.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestReservedRawPaths.java index 82cef944324..84cfd80d287 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestReservedRawPaths.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestReservedRawPaths.java @@ -91,6 +91,7 @@ public class TestReservedRawPaths { public void teardown() { if (cluster != null) { cluster.shutdown(); + cluster = null; } } diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestSafeMode.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestSafeMode.java index 2485b32c54d..13ca1480e5a 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestSafeMode.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestSafeMode.java @@ -90,9 +90,11 @@ public class TestSafeMode { public void tearDown() throws IOException { if (fs != null) { fs.close(); + fs = null; } if (cluster != null) { cluster.shutdown(); + cluster = null; } } diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestWriteRead.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestWriteRead.java index 47a78bcc454..623dafff8b9 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestWriteRead.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestWriteRead.java @@ -86,7 +86,10 @@ public class TestWriteRead { @After public void shutdown() { - cluster.shutdown(); + if (cluster != null) { + cluster.shutdown(); + cluster = null; + } } // Equivalence of @Before for cluster mode testing. diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/protocol/datatransfer/sasl/TestSaslDataTransfer.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/protocol/datatransfer/sasl/TestSaslDataTransfer.java index 0cbf266aa3e..2d4eb0d2b43 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/protocol/datatransfer/sasl/TestSaslDataTransfer.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/protocol/datatransfer/sasl/TestSaslDataTransfer.java @@ -67,6 +67,7 @@ public class TestSaslDataTransfer extends SaslDataTransferTestCase { IOUtils.cleanup(null, fs); if (cluster != null) { cluster.shutdown(); + cluster = null; } } diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/qjournal/TestSecureNNWithQJM.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/qjournal/TestSecureNNWithQJM.java index 166f18e5a29..197759edf58 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/qjournal/TestSecureNNWithQJM.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/qjournal/TestSecureNNWithQJM.java @@ -154,9 +154,11 @@ public class TestSecureNNWithQJM { IOUtils.cleanup(null, fs); if (cluster != null) { cluster.shutdown(); + cluster = null; } if (mjc != null) { mjc.shutdown(); + mjc = null; } } diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/qjournal/client/TestQuorumJournalManager.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/qjournal/client/TestQuorumJournalManager.java index b9a0924c537..3ba573c919a 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/qjournal/client/TestQuorumJournalManager.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/qjournal/client/TestQuorumJournalManager.java @@ -114,6 +114,7 @@ public class TestQuorumJournalManager { if (cluster != null) { cluster.shutdown(); + cluster = null; } } diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/qjournal/server/TestJournalNodeMXBean.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/qjournal/server/TestJournalNodeMXBean.java index 498ef71bf80..45b245a64b2 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/qjournal/server/TestJournalNodeMXBean.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/qjournal/server/TestJournalNodeMXBean.java @@ -61,6 +61,7 @@ public class TestJournalNodeMXBean { public void cleanup() throws IOException { if (jCluster != null) { jCluster.shutdown(); + jCluster = null; } } diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/security/TestDelegationToken.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/security/TestDelegationToken.java index 3f1df4e2d49..4cab46000af 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/security/TestDelegationToken.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/security/TestDelegationToken.java @@ -86,6 +86,7 @@ public class TestDelegationToken { public void tearDown() throws Exception { if(cluster!=null) { cluster.shutdown(); + cluster = null; } } diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/blockmanagement/TestBlockStatsMXBean.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/blockmanagement/TestBlockStatsMXBean.java index 2fe8768bab4..f5b56414bf2 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/blockmanagement/TestBlockStatsMXBean.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/blockmanagement/TestBlockStatsMXBean.java @@ -67,6 +67,7 @@ public class TestBlockStatsMXBean { public void tearDown() { if (cluster != null) { cluster.shutdown(); + cluster = null; } } diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/blockmanagement/TestComputeInvalidateWork.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/blockmanagement/TestComputeInvalidateWork.java index 5b08f5302f0..07455cf3a06 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/blockmanagement/TestComputeInvalidateWork.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/blockmanagement/TestComputeInvalidateWork.java @@ -70,6 +70,7 @@ public class TestComputeInvalidateWork { public void teardown() throws Exception { if (cluster != null) { cluster.shutdown(); + cluster = null; } } diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/blockmanagement/TestPendingInvalidateBlock.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/blockmanagement/TestPendingInvalidateBlock.java index 60e0f7c7586..a588a73150e 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/blockmanagement/TestPendingInvalidateBlock.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/blockmanagement/TestPendingInvalidateBlock.java @@ -74,6 +74,7 @@ public class TestPendingInvalidateBlock { public void tearDown() throws Exception { if (cluster != null) { cluster.shutdown(); + cluster = null; } } diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/datanode/BlockReportTestBase.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/datanode/BlockReportTestBase.java index 0a57005ab69..4279f96a001 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/datanode/BlockReportTestBase.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/datanode/BlockReportTestBase.java @@ -115,10 +115,12 @@ public abstract class BlockReportTestBase { public void shutDownCluster() throws IOException { if (fs != null) { fs.close(); + fs = null; } if (cluster != null) { cluster.shutdownDataNodes(); cluster.shutdown(); + cluster = null; } } diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/datanode/TestDataNodeExit.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/datanode/TestDataNodeExit.java index 7a15b8556dd..918ad83bbd4 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/datanode/TestDataNodeExit.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/datanode/TestDataNodeExit.java @@ -59,8 +59,10 @@ public class TestDataNodeExit { @After public void tearDown() throws Exception { - if (cluster != null) + if (cluster != null) { cluster.shutdown(); + cluster = null; + } } private void stopBPServiceThreads(int numStopThreads, DataNode dn) diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/datanode/TestDataNodeVolumeFailure.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/datanode/TestDataNodeVolumeFailure.java index 2c4fcc5454a..90e000bb3bc 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/datanode/TestDataNodeVolumeFailure.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/datanode/TestDataNodeVolumeFailure.java @@ -116,12 +116,15 @@ public class TestDataNodeVolumeFailure { public void tearDown() throws Exception { if(data_fail != null) { FileUtil.setWritable(data_fail, true); + data_fail = null; } if(failedDir != null) { FileUtil.setWritable(failedDir, true); + failedDir = null; } if(cluster != null) { cluster.shutdown(); + cluster = null; } } diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/datanode/TestDataNodeVolumeFailureReporting.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/datanode/TestDataNodeVolumeFailureReporting.java index 5a58fe46be0..d25a8a2edf4 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/datanode/TestDataNodeVolumeFailureReporting.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/datanode/TestDataNodeVolumeFailureReporting.java @@ -89,6 +89,7 @@ public class TestDataNodeVolumeFailureReporting { IOUtils.cleanup(LOG, fs); if (cluster != null) { cluster.shutdown(); + cluster = null; } } diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/datanode/TestDataNodeVolumeFailureToleration.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/datanode/TestDataNodeVolumeFailureToleration.java index 32a439d1b48..1eb8bcaf77d 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/datanode/TestDataNodeVolumeFailureToleration.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/datanode/TestDataNodeVolumeFailureToleration.java @@ -78,6 +78,7 @@ public class TestDataNodeVolumeFailureToleration { public void tearDown() throws Exception { if (cluster != null) { cluster.shutdown(); + cluster = null; } } diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/datanode/TestDiskError.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/datanode/TestDiskError.java index 55a668bc61d..000277a8416 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/datanode/TestDiskError.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/datanode/TestDiskError.java @@ -71,7 +71,10 @@ public class TestDiskError { @After public void tearDown() throws Exception { - cluster.shutdown(); + if (cluster != null) { + cluster.shutdown(); + cluster = null; + } } /** diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/datanode/TestFsDatasetCache.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/datanode/TestFsDatasetCache.java index cb4022ea910..77b0c447897 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/datanode/TestFsDatasetCache.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/datanode/TestFsDatasetCache.java @@ -149,9 +149,11 @@ public class TestFsDatasetCache { DFSTestUtil.verifyExpectedCacheUsage(0, 0, fsd); if (fs != null) { fs.close(); + fs = null; } if (cluster != null) { cluster.shutdown(); + cluster = null; } // Restore the original CacheManipulator NativeIO.POSIX.setCacheManipulator(prevCacheManipulator); diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/datanode/TestIncrementalBrVariations.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/datanode/TestIncrementalBrVariations.java index 0801701ba8e..e9d51e93e19 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/datanode/TestIncrementalBrVariations.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/datanode/TestIncrementalBrVariations.java @@ -101,10 +101,13 @@ public class TestIncrementalBrVariations { @After public void shutDownCluster() throws IOException { - client.close(); - fs.close(); - cluster.shutdownDataNodes(); - cluster.shutdown(); + if (cluster != null) { + client.close(); + fs.close(); + cluster.shutdownDataNodes(); + cluster.shutdown(); + cluster = null; + } } /** diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestAclConfigFlag.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestAclConfigFlag.java index afb7dc528ce..36539e59c99 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestAclConfigFlag.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestAclConfigFlag.java @@ -58,6 +58,7 @@ public class TestAclConfigFlag { IOUtils.cleanup(null, fs); if (cluster != null) { cluster.shutdown(); + cluster = null; } } diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestAddBlock.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestAddBlock.java index 301ee25ad6b..9e9890f1031 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestAddBlock.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestAddBlock.java @@ -60,6 +60,7 @@ public class TestAddBlock { public void tearDown() { if (cluster != null) { cluster.shutdown(); + cluster = null; } } diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestAddBlockRetry.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestAddBlockRetry.java index c92e79b76f6..a8cd5b9a825 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestAddBlockRetry.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestAddBlockRetry.java @@ -66,6 +66,7 @@ public class TestAddBlockRetry { public void tearDown() throws Exception { if (cluster != null) { cluster.shutdown(); + cluster = null; } } diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestAuditLogs.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestAuditLogs.java index 1f26659a527..de22af7702a 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestAuditLogs.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestAuditLogs.java @@ -140,8 +140,14 @@ public class TestAuditLogs { @After public void teardownCluster() throws Exception { util.cleanup(fs, "/srcdat"); - fs.close(); - cluster.shutdown(); + if (fs != null) { + fs.close(); + fs = null; + } + if (cluster != null) { + cluster.shutdown(); + cluster = null; + } } /** test that allowed operation puts proper entry in audit log */ diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestBackupNode.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestBackupNode.java index 9f31857c8b2..e8338e5f6c1 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestBackupNode.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestBackupNode.java @@ -477,7 +477,9 @@ public class TestBackupNode { assertTrue(e.getLocalizedMessage(), false); } finally { fileSys.close(); - cluster.shutdown(); + if (cluster != null) { + cluster.shutdown(); + } } } diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestBlockPlacementPolicyRackFaultTolerant.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestBlockPlacementPolicyRackFaultTolerant.java index ca9da77218f..9f844d7fc7e 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestBlockPlacementPolicyRackFaultTolerant.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestBlockPlacementPolicyRackFaultTolerant.java @@ -83,6 +83,7 @@ public class TestBlockPlacementPolicyRackFaultTolerant { public void teardown() { if (cluster != null) { cluster.shutdown(); + cluster = null; } } diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestCacheDirectives.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestCacheDirectives.java index e2267c63b6a..d6f526ba9c0 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestCacheDirectives.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestCacheDirectives.java @@ -159,6 +159,7 @@ public class TestCacheDirectives { waitForCachedBlocks(namenode, 0, 0, "teardown"); if (cluster != null) { cluster.shutdown(); + cluster = null; } // Restore the original CacheManipulator NativeIO.POSIX.setCacheManipulator(prevCacheManipulator); diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestCommitBlockWithInvalidGenStamp.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestCommitBlockWithInvalidGenStamp.java index 30ea54738c1..6684308aa62 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestCommitBlockWithInvalidGenStamp.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestCommitBlockWithInvalidGenStamp.java @@ -58,6 +58,7 @@ public class TestCommitBlockWithInvalidGenStamp { public void tearDown() { if (cluster != null) { cluster.shutdown(); + cluster = null; } } diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestDeadDatanode.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestDeadDatanode.java index bfd026cdbe0..442873d8106 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestDeadDatanode.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestDeadDatanode.java @@ -62,7 +62,10 @@ public class TestDeadDatanode { @After public void cleanup() { - cluster.shutdown(); + if (cluster != null) { + cluster.shutdown(); + cluster = null; + } } /** diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestDefaultBlockPlacementPolicy.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestDefaultBlockPlacementPolicy.java index 5709cee8be7..a54040b2e8d 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestDefaultBlockPlacementPolicy.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestDefaultBlockPlacementPolicy.java @@ -71,6 +71,7 @@ public class TestDefaultBlockPlacementPolicy { public void teardown() { if (cluster != null) { cluster.shutdown(); + cluster = null; } } diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestDiskspaceQuotaUpdate.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestDiskspaceQuotaUpdate.java index cf6463836e8..d459db09b2e 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestDiskspaceQuotaUpdate.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestDiskspaceQuotaUpdate.java @@ -71,6 +71,7 @@ public class TestDiskspaceQuotaUpdate { public void tearDown() throws Exception { if (cluster != null) { cluster.shutdown(); + cluster = null; } } diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestEditLogAutoroll.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestEditLogAutoroll.java index 3a0ae5c5f2a..f22ee2fcc24 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestEditLogAutoroll.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestEditLogAutoroll.java @@ -97,9 +97,11 @@ public class TestEditLogAutoroll { public void tearDown() throws Exception { if (fs != null) { fs.close(); + fs = null; } if (cluster != null) { cluster.shutdown(); + cluster = null; } } diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestEditLogJournalFailures.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestEditLogJournalFailures.java index 610a4a2fd4c..51dfc3e993d 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestEditLogJournalFailures.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestEditLogJournalFailures.java @@ -70,11 +70,14 @@ public class TestEditLogJournalFailures { @After public void shutDownMiniCluster() throws IOException { - if (fs != null) + if (fs != null) { fs.close(); + fs = null; + } if (cluster != null) { try { cluster.shutdown(); + cluster = null; } catch (ExitException ee) { // Ignore ExitExceptions as the tests may result in the // NameNode doing an immediate shutdown. diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestFSDirectory.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestFSDirectory.java index 00248b123be..8ee15910515 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestFSDirectory.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestFSDirectory.java @@ -109,6 +109,7 @@ public class TestFSDirectory { public void tearDown() throws Exception { if (cluster != null) { cluster.shutdown(); + cluster = null; } } diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestFSImageWithAcl.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestFSImageWithAcl.java index 690fec6aaeb..48d3dea81c3 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestFSImageWithAcl.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestFSImageWithAcl.java @@ -55,7 +55,9 @@ public class TestFSImageWithAcl { @AfterClass public static void tearDown() { - cluster.shutdown(); + if (cluster != null) { + cluster.shutdown(); + } } private void testAcl(boolean persistNamespace) throws IOException { diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestFSImageWithSnapshot.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestFSImageWithSnapshot.java index e23fbf0dd89..1904bbc122e 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestFSImageWithSnapshot.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestFSImageWithSnapshot.java @@ -89,6 +89,7 @@ public class TestFSImageWithSnapshot { public void tearDown() throws Exception { if (cluster != null) { cluster.shutdown(); + cluster = null; } } diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestFSImageWithXAttr.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestFSImageWithXAttr.java index bb6642f6155..4cef3214e9b 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestFSImageWithXAttr.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestFSImageWithXAttr.java @@ -62,7 +62,9 @@ public class TestFSImageWithXAttr { @AfterClass public static void tearDown() { - cluster.shutdown(); + if (cluster != null) { + cluster.shutdown(); + } } private void testXAttr(boolean persistNamespace) throws IOException { diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestFileTruncate.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestFileTruncate.java index 7dbf548865f..6755c2610b9 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestFileTruncate.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestFileTruncate.java @@ -109,8 +109,14 @@ public class TestFileTruncate { @After public void tearDown() throws IOException { - if(fs != null) fs.close(); - if(cluster != null) cluster.shutdown(); + if(fs != null) { + fs.close(); + fs = null; + } + if(cluster != null) { + cluster.shutdown(); + cluster = null; + } } /** diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestHDFSConcat.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestHDFSConcat.java index 6dc0782ab47..b5e0efe0649 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestHDFSConcat.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestHDFSConcat.java @@ -84,10 +84,12 @@ public class TestHDFSConcat { public void shutDownCluster() throws IOException { if(dfs != null) { dfs.close(); + dfs = null; } if(cluster != null) { cluster.shutdownDataNodes(); cluster.shutdown(); + cluster = null; } } diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestINodeAttributeProvider.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestINodeAttributeProvider.java index c5f428bea4b..ffdc5356ac2 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestINodeAttributeProvider.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestINodeAttributeProvider.java @@ -186,6 +186,7 @@ public class TestINodeAttributeProvider { CALLED.clear(); if (miniDFS != null) { miniDFS.shutdown(); + miniDFS = null; } Assert.assertTrue(CALLED.contains("stop")); } diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestMalformedURLs.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestMalformedURLs.java index b85e5ee447c..0c71445b0eb 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestMalformedURLs.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestMalformedURLs.java @@ -54,6 +54,7 @@ public class TestMalformedURLs { public void tearDown() throws Exception { if (cluster != null) { cluster.shutdown(); + cluster = null; } } } diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestMetadataVersionOutput.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestMetadataVersionOutput.java index d426de57636..dc8f70a5b5b 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestMetadataVersionOutput.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestMetadataVersionOutput.java @@ -45,6 +45,7 @@ public class TestMetadataVersionOutput { public void tearDown() throws Exception { if (dfsCluster != null) { dfsCluster.shutdown(); + dfsCluster = null; } Thread.sleep(2000); } diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestNameNodeMetadataConsistency.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestNameNodeMetadataConsistency.java index 917119416d1..d4fb0d17cc5 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestNameNodeMetadataConsistency.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestNameNodeMetadataConsistency.java @@ -63,6 +63,7 @@ public class TestNameNodeMetadataConsistency { public void cleanup() { if (cluster != null) { cluster.shutdown(); + cluster = null; } } diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestNameNodeRetryCacheMetrics.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestNameNodeRetryCacheMetrics.java index 97158108848..fb3a84083cd 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestNameNodeRetryCacheMetrics.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestNameNodeRetryCacheMetrics.java @@ -80,6 +80,7 @@ public class TestNameNodeRetryCacheMetrics { public void cleanup() throws IOException { if (cluster != null) { cluster.shutdown(); + cluster = null; } } diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestNameNodeRpcServerMethods.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestNameNodeRpcServerMethods.java index 80d97224d6d..a32e2188e88 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestNameNodeRpcServerMethods.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestNameNodeRpcServerMethods.java @@ -55,8 +55,10 @@ public class TestNameNodeRpcServerMethods { */ @After public void cleanup() throws IOException { - if (cluster != null) + if (cluster != null) { cluster.shutdown(); + cluster = null; + } } @Test diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestNamenodeRetryCache.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestNamenodeRetryCache.java index 2e6b4a336df..767562cf9ce 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestNamenodeRetryCache.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestNamenodeRetryCache.java @@ -105,7 +105,10 @@ public class TestNamenodeRetryCache { * @throws AccessControlException */ @After public void cleanup() throws IOException { - cluster.shutdown(); + if (cluster != null) { + cluster.shutdown(); + cluster = null; + } } /** Set the current Server RPC call */ diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestQuotaByStorageType.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestQuotaByStorageType.java index f56c5a2d062..ee02fd0f9f8 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestQuotaByStorageType.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestQuotaByStorageType.java @@ -74,6 +74,7 @@ public class TestQuotaByStorageType { public void tearDown() throws Exception { if (cluster != null) { cluster.shutdown(); + cluster = null; } } diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestXAttrConfigFlag.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestXAttrConfigFlag.java index e4fb4bbad9b..5064a0339d2 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestXAttrConfigFlag.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestXAttrConfigFlag.java @@ -51,6 +51,7 @@ public class TestXAttrConfigFlag { IOUtils.cleanup(null, fs); if (cluster != null) { cluster.shutdown(); + cluster = null; } } diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/ha/TestBootstrapStandby.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/ha/TestBootstrapStandby.java index 148ec98e4d7..6bcfb496cc6 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/ha/TestBootstrapStandby.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/ha/TestBootstrapStandby.java @@ -80,6 +80,7 @@ public class TestBootstrapStandby { public void shutdownCluster() { if (cluster != null) { cluster.shutdown(); + cluster = null; } } diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/ha/TestBootstrapStandbyWithQJM.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/ha/TestBootstrapStandbyWithQJM.java index ca8f563c577..6c8c2007513 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/ha/TestBootstrapStandbyWithQJM.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/ha/TestBootstrapStandbyWithQJM.java @@ -79,9 +79,11 @@ public class TestBootstrapStandbyWithQJM { public void cleanup() throws IOException { if (cluster != null) { cluster.shutdown(); + cluster = null; } if (jCluster != null) { jCluster.shutdown(); + jCluster = null; } } diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/ha/TestDNFencing.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/ha/TestDNFencing.java index 4260d94664d..96822d625b1 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/ha/TestDNFencing.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/ha/TestDNFencing.java @@ -118,6 +118,7 @@ public class TestDNFencing { banner("Shutting down cluster. NN2 metadata:"); doMetasave(nn2); cluster.shutdown(); + cluster = null; } } diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/ha/TestDelegationTokensWithHA.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/ha/TestDelegationTokensWithHA.java index 2daa9f87181..16b27d87851 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/ha/TestDelegationTokensWithHA.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/ha/TestDelegationTokensWithHA.java @@ -107,6 +107,7 @@ public class TestDelegationTokensWithHA { public void shutdownCluster() throws IOException { if (cluster != null) { cluster.shutdown(); + cluster = null; } } diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/ha/TestFailoverWithBlockTokensEnabled.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/ha/TestFailoverWithBlockTokensEnabled.java index 151e7d3aec8..43a94a15d74 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/ha/TestFailoverWithBlockTokensEnabled.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/ha/TestFailoverWithBlockTokensEnabled.java @@ -76,6 +76,7 @@ public class TestFailoverWithBlockTokensEnabled { public void shutDownCluster() { if (cluster != null) { cluster.shutdown(); + cluster = null; } } diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/ha/TestFailureToReadEdits.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/ha/TestFailureToReadEdits.java index f5a72cae00e..f82b6164fca 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/ha/TestFailureToReadEdits.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/ha/TestFailureToReadEdits.java @@ -130,15 +130,18 @@ public class TestFailureToReadEdits { public void tearDownCluster() throws Exception { if (fs != null) { fs.close(); + fs = null; } if (clusterType == TestType.SHARED_DIR_HA) { if (cluster != null) { cluster.shutdown(); + cluster = null; } } else { if (miniQjmHaCluster != null) { miniQjmHaCluster.shutdown(); + miniQjmHaCluster = null; } } } diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/ha/TestGetGroupsWithHA.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/ha/TestGetGroupsWithHA.java index e548817b6a7..c3c22759d96 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/ha/TestGetGroupsWithHA.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/ha/TestGetGroupsWithHA.java @@ -46,6 +46,7 @@ public class TestGetGroupsWithHA extends GetGroupsTestBase { public void tearDownNameNode() { if (cluster != null) { cluster.shutdown(); + cluster = null; } } diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/ha/TestHASafeMode.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/ha/TestHASafeMode.java index 21de9606971..4b1d27d5b90 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/ha/TestHASafeMode.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/ha/TestHASafeMode.java @@ -112,6 +112,7 @@ public class TestHASafeMode { public void shutdownCluster() { if (cluster != null) { cluster.shutdown(); + cluster = null; } } diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/ha/TestInitializeSharedEdits.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/ha/TestInitializeSharedEdits.java index 272e5436434..856ed8fbc86 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/ha/TestInitializeSharedEdits.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/ha/TestInitializeSharedEdits.java @@ -78,6 +78,7 @@ public class TestInitializeSharedEdits { public void shutdownCluster() throws IOException { if (cluster != null) { cluster.shutdown(); + cluster = null; } } diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/ha/TestNNHealthCheck.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/ha/TestNNHealthCheck.java index 6519588ce51..22d4ef41afc 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/ha/TestNNHealthCheck.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/ha/TestNNHealthCheck.java @@ -53,6 +53,7 @@ public class TestNNHealthCheck { public void shutdown() { if (cluster != null) { cluster.shutdown(); + cluster = null; } } diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/ha/TestQuotasWithHA.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/ha/TestQuotasWithHA.java index db67d95bce9..e768306cfa5 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/ha/TestQuotasWithHA.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/ha/TestQuotasWithHA.java @@ -80,6 +80,7 @@ public class TestQuotasWithHA { public void shutdownCluster() throws IOException { if (cluster != null) { cluster.shutdown(); + cluster = null; } } 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 4af9c75f776..ae355795fba 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 @@ -147,6 +147,7 @@ public class TestRetryCacheWithHA { public void cleanup() throws Exception { if (cluster != null) { cluster.shutdown(); + cluster = null; } } diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/ha/TestStandbyCheckpoints.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/ha/TestStandbyCheckpoints.java index 33af0e21979..e0c55633b33 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/ha/TestStandbyCheckpoints.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/ha/TestStandbyCheckpoints.java @@ -131,6 +131,7 @@ public class TestStandbyCheckpoints { public void shutdownCluster() throws IOException { if (cluster != null) { cluster.shutdown(); + cluster = null; } } diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/ha/TestXAttrsWithHA.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/ha/TestXAttrsWithHA.java index db92238a3e1..bb44d05e2c6 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/ha/TestXAttrsWithHA.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/ha/TestXAttrsWithHA.java @@ -82,6 +82,7 @@ public class TestXAttrsWithHA { public void shutdownCluster() throws IOException { if (cluster != null) { cluster.shutdown(); + cluster = null; } } diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/metrics/TestNNMetricFilesInGetListingOps.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/metrics/TestNNMetricFilesInGetListingOps.java index 47a893dfd2c..110615d9098 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/metrics/TestNNMetricFilesInGetListingOps.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/metrics/TestNNMetricFilesInGetListingOps.java @@ -62,7 +62,10 @@ public class TestNNMetricFilesInGetListingOps { @After public void tearDown() throws Exception { - cluster.shutdown(); + if (cluster != null) { + cluster.shutdown(); + cluster = null; + } } /** create a file with a length of fileLen */ diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/metrics/TestNameNodeMetrics.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/metrics/TestNameNodeMetrics.java index 20d9aaf78a9..e21b00d7dab 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/metrics/TestNameNodeMetrics.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/metrics/TestNameNodeMetrics.java @@ -124,7 +124,10 @@ public class TestNameNodeMetrics { MetricsRecordBuilder rb = getMetrics(source); assertQuantileGauges("GetGroups1s", rb); } - cluster.shutdown(); + if (cluster != null) { + cluster.shutdown(); + cluster = null; + } } /** create a file with a length of fileLen */ diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/snapshot/TestFileContextSnapshot.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/snapshot/TestFileContextSnapshot.java index dcabed7be38..a6cd1dd9b5a 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/snapshot/TestFileContextSnapshot.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/snapshot/TestFileContextSnapshot.java @@ -67,6 +67,7 @@ public class TestFileContextSnapshot { public void tearDown() throws Exception { if (cluster != null) { cluster.shutdown(); + cluster = null; } } diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/snapshot/TestGetContentSummaryWithSnapshot.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/snapshot/TestGetContentSummaryWithSnapshot.java index 21f2db52c50..dc6f584a2b8 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/snapshot/TestGetContentSummaryWithSnapshot.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/snapshot/TestGetContentSummaryWithSnapshot.java @@ -70,6 +70,7 @@ public class TestGetContentSummaryWithSnapshot { public void tearDown() throws Exception { if (cluster != null) { cluster.shutdown(); + cluster = null; } } diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/snapshot/TestINodeFileUnderConstructionWithSnapshot.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/snapshot/TestINodeFileUnderConstructionWithSnapshot.java index 16044c3eda1..65b2f8c3f93 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/snapshot/TestINodeFileUnderConstructionWithSnapshot.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/snapshot/TestINodeFileUnderConstructionWithSnapshot.java @@ -91,6 +91,7 @@ public class TestINodeFileUnderConstructionWithSnapshot { public void tearDown() throws Exception { if (cluster != null) { cluster.shutdown(); + cluster = null; } } diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/snapshot/TestNestedSnapshots.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/snapshot/TestNestedSnapshots.java index d565dad0db8..5b7ed41f42e 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/snapshot/TestNestedSnapshots.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/snapshot/TestNestedSnapshots.java @@ -78,6 +78,7 @@ public class TestNestedSnapshots { public void tearDown() throws Exception { if (cluster != null) { cluster.shutdown(); + cluster = null; } } diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/snapshot/TestOpenFilesWithSnapshot.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/snapshot/TestOpenFilesWithSnapshot.java index f0c5482659e..694d15e63f3 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/snapshot/TestOpenFilesWithSnapshot.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/snapshot/TestOpenFilesWithSnapshot.java @@ -52,9 +52,11 @@ public class TestOpenFilesWithSnapshot { public void teardown() throws IOException { if (fs != null) { fs.close(); + fs = null; } if (cluster != null) { cluster.shutdown(); + cluster = null; } } diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/snapshot/TestRenameWithSnapshots.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/snapshot/TestRenameWithSnapshots.java index ab97a3d1f83..827feb6a2a8 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/snapshot/TestRenameWithSnapshots.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/snapshot/TestRenameWithSnapshots.java @@ -122,6 +122,7 @@ public class TestRenameWithSnapshots { public void tearDown() throws Exception { if (cluster != null) { cluster.shutdown(); + cluster = null; } } diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/snapshot/TestSetQuotaWithSnapshot.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/snapshot/TestSetQuotaWithSnapshot.java index 89e7416a4a9..c5ac26ed95a 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/snapshot/TestSetQuotaWithSnapshot.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/snapshot/TestSetQuotaWithSnapshot.java @@ -76,6 +76,7 @@ public class TestSetQuotaWithSnapshot { public void tearDown() throws Exception { if (cluster != null) { cluster.shutdown(); + cluster = null; } } diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/snapshot/TestSnapshot.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/snapshot/TestSnapshot.java index 3e12cfc53c1..150d294f449 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/snapshot/TestSnapshot.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/snapshot/TestSnapshot.java @@ -131,6 +131,7 @@ public class TestSnapshot { public void tearDown() throws Exception { if (cluster != null) { cluster.shutdown(); + cluster = null; } } diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/snapshot/TestSnapshotBlocksMap.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/snapshot/TestSnapshotBlocksMap.java index dad1eeb3457..3f06d3d9936 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/snapshot/TestSnapshotBlocksMap.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/snapshot/TestSnapshotBlocksMap.java @@ -84,6 +84,7 @@ public class TestSnapshotBlocksMap { public void tearDown() throws Exception { if (cluster != null) { cluster.shutdown(); + cluster = null; } } diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/snapshot/TestSnapshotDeletion.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/snapshot/TestSnapshotDeletion.java index b81291a9d60..bf462da2f0f 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/snapshot/TestSnapshotDeletion.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/snapshot/TestSnapshotDeletion.java @@ -106,6 +106,7 @@ public class TestSnapshotDeletion { public void tearDown() throws Exception { if (cluster != null) { cluster.shutdown(); + cluster = null; } } diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/snapshot/TestSnapshotDiffReport.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/snapshot/TestSnapshotDiffReport.java index 786f9249f69..453afacddac 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/snapshot/TestSnapshotDiffReport.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/snapshot/TestSnapshotDiffReport.java @@ -71,6 +71,7 @@ public class TestSnapshotDiffReport { public void tearDown() throws Exception { if (cluster != null) { cluster.shutdown(); + cluster = null; } } diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/snapshot/TestSnapshotListing.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/snapshot/TestSnapshotListing.java index 2639d445ac6..03a2ff4e64e 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/snapshot/TestSnapshotListing.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/snapshot/TestSnapshotListing.java @@ -61,6 +61,7 @@ public class TestSnapshotListing { public void tearDown() throws Exception { if (cluster != null) { cluster.shutdown(); + cluster = null; } } diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/snapshot/TestSnapshotMetrics.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/snapshot/TestSnapshotMetrics.java index 1b8f43743f5..f64caff75bc 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/snapshot/TestSnapshotMetrics.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/snapshot/TestSnapshotMetrics.java @@ -69,6 +69,7 @@ public class TestSnapshotMetrics { public void tearDown() throws Exception { if (cluster != null) { cluster.shutdown(); + cluster = null; } } diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/snapshot/TestSnapshotRename.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/snapshot/TestSnapshotRename.java index 731b97baf6b..8c8fca71e82 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/snapshot/TestSnapshotRename.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/snapshot/TestSnapshotRename.java @@ -82,6 +82,7 @@ public class TestSnapshotRename { public void tearDown() throws Exception { if (cluster != null) { cluster.shutdown(); + cluster = null; } } diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/snapshot/TestSnapshotReplication.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/snapshot/TestSnapshotReplication.java index 30f6fee4db7..d073228a700 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/snapshot/TestSnapshotReplication.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/snapshot/TestSnapshotReplication.java @@ -75,6 +75,7 @@ public class TestSnapshotReplication { public void tearDown() throws Exception { if (cluster != null) { cluster.shutdown(); + cluster = null; } } diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/snapshot/TestSnapshottableDirListing.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/snapshot/TestSnapshottableDirListing.java index 89888060741..5611eb925a6 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/snapshot/TestSnapshottableDirListing.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/snapshot/TestSnapshottableDirListing.java @@ -67,6 +67,7 @@ public class TestSnapshottableDirListing { public void tearDown() throws Exception { if (cluster != null) { cluster.shutdown(); + cluster = null; } } diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/tools/TestDFSHAAdminMiniCluster.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/tools/TestDFSHAAdminMiniCluster.java index 06f9ccbefea..a21a31d9e0f 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/tools/TestDFSHAAdminMiniCluster.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/tools/TestDFSHAAdminMiniCluster.java @@ -82,7 +82,10 @@ public class TestDFSHAAdminMiniCluster { @After public void shutdown() throws Exception { - cluster.shutdown(); + if (cluster != null) { + cluster.shutdown(); + cluster = null; + } } @Test diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/tools/TestDFSZKFailoverController.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/tools/TestDFSZKFailoverController.java index 3e1c96f84df..94cccedc02f 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/tools/TestDFSZKFailoverController.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/tools/TestDFSZKFailoverController.java @@ -111,16 +111,22 @@ public class TestDFSZKFailoverController extends ClientBaseWithFixes { @After public void shutdown() throws Exception { - cluster.shutdown(); + if (cluster != null) { + cluster.shutdown(); + cluster = null; + } if (thr1 != null) { thr1.interrupt(); + thr1 = null; } if (thr2 != null) { thr2.interrupt(); + thr2 = null; } if (ctx != null) { ctx.stop(); + ctx = null; } } diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/tools/TestGetGroups.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/tools/TestGetGroups.java index d02ec9620c2..3d9631dfe12 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/tools/TestGetGroups.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/tools/TestGetGroups.java @@ -42,7 +42,10 @@ public class TestGetGroups extends GetGroupsTestBase { @After public void tearDownNameNode() { - cluster.shutdown(); + if (cluster != null) { + cluster.shutdown(); + cluster = null; + } } @Override diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/tools/TestStoragePolicyCommands.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/tools/TestStoragePolicyCommands.java index cb249e6cc06..ec0bb665de4 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/tools/TestStoragePolicyCommands.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/tools/TestStoragePolicyCommands.java @@ -54,9 +54,11 @@ public class TestStoragePolicyCommands { public void clusterShutdown() throws IOException{ if(fs != null) { fs.close(); + fs = null; } if(cluster != null) { cluster.shutdown(); + cluster = null; } } diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/web/TestHttpsFileSystem.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/web/TestHttpsFileSystem.java index 3afe2119881..04c1e0241bc 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/web/TestHttpsFileSystem.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/web/TestHttpsFileSystem.java @@ -82,7 +82,9 @@ public class TestHttpsFileSystem { @AfterClass public static void tearDown() throws Exception { - cluster.shutdown(); + if (cluster != null) { + cluster.shutdown(); + } FileUtil.fullyDelete(new File(BASEDIR)); KeyStoreTestUtil.cleanupSSLConfig(keystoresDir, sslConfDir); } diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/web/TestWebHdfsWithAuthenticationFilter.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/web/TestWebHdfsWithAuthenticationFilter.java index 09c78728a9e..f21fde46224 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/web/TestWebHdfsWithAuthenticationFilter.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/web/TestWebHdfsWithAuthenticationFilter.java @@ -84,8 +84,12 @@ public class TestWebHdfsWithAuthenticationFilter { @AfterClass public static void tearDown() throws IOException { - fs.close(); - cluster.shutdown(); + if (fs != null) { + fs.close(); + } + if (cluster != null) { + cluster.shutdown(); + } } @Test diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/security/TestRefreshUserMappings.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/security/TestRefreshUserMappings.java index ca67245371b..c76033c4a56 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/security/TestRefreshUserMappings.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/security/TestRefreshUserMappings.java @@ -99,10 +99,12 @@ public class TestRefreshUserMappings { public void tearDown() throws Exception { if(cluster!=null) { cluster.shutdown(); + cluster = null; } if(tempResource!=null) { File f = new File(tempResource); f.delete(); + tempResource = null; } } diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/tools/TestJMXGet.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/tools/TestJMXGet.java index d9a3b7928bf..7049a0db1cf 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/tools/TestJMXGet.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/tools/TestJMXGet.java @@ -86,13 +86,16 @@ public class TestJMXGet { */ @After public void tearDown() throws Exception { - if(cluster.isClusterUp()) - cluster.shutdown(); - - File data_dir = new File(cluster.getDataDirectory()); - if(data_dir.exists() && !FileUtil.fullyDelete(data_dir)) { - throw new IOException("Could not delete hdfs directory in tearDown '" - + data_dir + "'"); + if (cluster != null) { + if (cluster.isClusterUp()) { + cluster.shutdown(); + } + File data_dir = new File(cluster.getDataDirectory()); + if (data_dir.exists() && !FileUtil.fullyDelete(data_dir)) { + throw new IOException( + "Could not delete hdfs directory in tearDown '" + data_dir + "'"); + } + cluster = null; } } diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/tracing/TestTracing.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/tracing/TestTracing.java index 7d7144148fc..bdad46a4e6f 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/tracing/TestTracing.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/tracing/TestTracing.java @@ -222,7 +222,10 @@ public class TestTracing { @After public void shutDown() throws IOException { - cluster.shutdown(); + if (cluster != null) { + cluster.shutdown(); + cluster = null; + } FsTracer.clear(); } }