diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/fsdataset/impl/FsDatasetImpl.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/fsdataset/impl/FsDatasetImpl.java index d4375cdfd73..095bc8f0730 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/fsdataset/impl/FsDatasetImpl.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/fsdataset/impl/FsDatasetImpl.java @@ -1086,8 +1086,10 @@ class FsDatasetImpl implements FsDatasetSpi { // calculate and write the last crc checksum.calculateChunkedSums(data, 0, offset, crcs, 0); metaOut.write(crcs, 0, 4); + metaOut.close(); + metaOut = null; } finally { - IOUtils.cleanup(null, metaOut); + IOUtils.closeStream(metaOut); } } diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/FSImageTestUtil.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/FSImageTestUtil.java index 1256eb1f42d..7be645f36e1 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/FSImageTestUtil.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/FSImageTestUtil.java @@ -108,6 +108,8 @@ public abstract class FSImageTestUtil { try { raf.seek(IMAGE_TXID_POS); raf.writeLong(0); + raf.close(); + raf = null; } finally { IOUtils.closeStream(raf); } @@ -542,9 +544,12 @@ public abstract class FSImageTestUtil { out = new FileOutputStream(versionFile); props.store(out, null); + out.close(); + out = null; } finally { - IOUtils.cleanup(null, fis, out); + IOUtils.closeStream(fis); + IOUtils.closeStream(out); } } diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/tools/offlineImageViewer/TestOfflineImageViewer.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/tools/offlineImageViewer/TestOfflineImageViewer.java index 51112658405..7574cbf4df0 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/tools/offlineImageViewer/TestOfflineImageViewer.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/tools/offlineImageViewer/TestOfflineImageViewer.java @@ -340,9 +340,11 @@ public class TestOfflineImageViewer { in = new FileInputStream(src); out = new FileOutputStream(dest); in.getChannel().transferTo(0, MAX_BYTES, out.getChannel()); + out.close(); + out = null; } finally { - IOUtils.cleanup(null, in); - IOUtils.cleanup(null, out); + IOUtils.closeStream(in); + IOUtils.closeStream(out); } }