diff --git a/hadoop-common-project/hadoop-common/CHANGES.txt b/hadoop-common-project/hadoop-common/CHANGES.txt index 81708bfcbc3..c9fde56652b 100644 --- a/hadoop-common-project/hadoop-common/CHANGES.txt +++ b/hadoop-common-project/hadoop-common/CHANGES.txt @@ -354,6 +354,8 @@ Release 2.8.0 - UNRELEASED HADOOP-12600. FileContext and AbstractFileSystem should be annotated as a Stable interface. (cnauroth) + HADOOP-12618. Fix NPE in TestSequenceFile. (Brahma Reddy Battula via umamahesh) + OPTIMIZATIONS HADOOP-11785. Reduce the number of listStatus operation in distcp diff --git a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/TestSequenceFile.java b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/TestSequenceFile.java index e12792843de..4cb4e130692 100644 --- a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/TestSequenceFile.java +++ b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/TestSequenceFile.java @@ -130,6 +130,7 @@ public void compressedSeqFileTest(CompressionCodec codec) throws Exception { } } + @SuppressWarnings("deprecation") private void writeTest(FileSystem fs, int count, int seed, Path file, CompressionType compressionType, CompressionCodec codec) throws IOException { @@ -150,6 +151,7 @@ private void writeTest(FileSystem fs, int count, int seed, Path file, writer.close(); } + @SuppressWarnings("deprecation") private void readTest(FileSystem fs, int count, int seed, Path file) throws IOException { LOG.debug("reading " + count + " records"); @@ -216,6 +218,7 @@ private void sortTest(FileSystem fs, int count, int megabytes, LOG.info("done sorting " + count + " debug"); } + @SuppressWarnings("deprecation") private void checkSort(FileSystem fs, int count, int seed, Path file) throws IOException { LOG.info("sorting " + count + " records in memory for debug"); @@ -253,6 +256,7 @@ private void checkSort(FileSystem fs, int count, int seed, Path file) LOG.debug("sucessfully checked " + count + " records"); } + @SuppressWarnings("deprecation") private void mergeTest(FileSystem fs, int count, int seed, Path file, CompressionType compressionType, boolean fast, int factor, int megabytes) @@ -375,6 +379,7 @@ public void testSequenceFileMetadata() throws Exception { } + @SuppressWarnings("deprecation") private SequenceFile.Metadata readMetadata(FileSystem fs, Path file) throws IOException { LOG.info("reading file: " + file.toString()); @@ -384,6 +389,7 @@ private SequenceFile.Metadata readMetadata(FileSystem fs, Path file) return meta; } + @SuppressWarnings("deprecation") private void writeMetadataTest(FileSystem fs, int count, int seed, Path file, CompressionType compressionType, CompressionCodec codec, SequenceFile.Metadata metadata) throws IOException { @@ -413,6 +419,7 @@ private void sortMetadataTest(FileSystem fs, Path unsortedFile, Path sortedFile, sorter.sort(new Path[] { unsortedFile }, sortedFile, false); } + @SuppressWarnings("deprecation") @Test public void testClose() throws IOException { Configuration conf = new Configuration(); @@ -470,6 +477,7 @@ public void testClose() throws IOException { * Test that makes sure the FileSystem passed to createWriter * @throws Exception */ + @SuppressWarnings("deprecation") @Test public void testCreateUsesFsArg() throws Exception { FileSystem fs = FileSystem.getLocal(conf); @@ -499,6 +507,7 @@ public boolean isClosed() { } } + @SuppressWarnings("deprecation") @Test public void testCloseForErroneousSequenceFile() throws IOException { @@ -555,6 +564,7 @@ public void testInitZeroLengthSequenceFile() throws IOException { * already created * @throws IOException */ + @SuppressWarnings("deprecation") @Test public void testCreateWriterOnExistingFile() throws IOException { Configuration conf = new Configuration(); @@ -568,6 +578,7 @@ public void testCreateWriterOnExistingFile() throws IOException { CompressionType.NONE, null, new Metadata()); } + @SuppressWarnings("deprecation") @Test public void testRecursiveSeqFileCreate() throws IOException { FileSystem fs = FileSystem.getLocal(conf); @@ -661,7 +672,7 @@ public static void main(String[] args) throws Exception { Path file = null; int seed = new Random().nextInt(); - String usage = "Usage: SequenceFile " + + String usage = "Usage: testsequencefile " + "[-count N] " + "[-seed #] [-check] [-compressType ] " + "-codec " + @@ -751,7 +762,9 @@ public static void main(String[] args) throws Exception { test.checkSort(fs, count, seed, file); } } finally { - fs.close(); + if (fs != null) { + fs.close(); + } } } }