From f9c0221623ee5849453f7ec9021d1697e9677805 Mon Sep 17 00:00:00 2001 From: Akira Ajisaka Date: Thu, 27 Sep 2018 11:44:42 +0900 Subject: [PATCH] HDFS-13932. [JDK 11] Casts to BlockStoragePolicy[] in unit tests raise ClassCastExceptions. Contributed by Andrew Purtell. --- .../apache/hadoop/fs/http/client/BaseTestHttpFSWith.java | 7 +------ .../test/java/org/apache/hadoop/hdfs/web/TestWebHDFS.java | 8 ++------ 2 files changed, 3 insertions(+), 12 deletions(-) diff --git a/hadoop-hdfs-project/hadoop-hdfs-httpfs/src/test/java/org/apache/hadoop/fs/http/client/BaseTestHttpFSWith.java b/hadoop-hdfs-project/hadoop-hdfs-httpfs/src/test/java/org/apache/hadoop/fs/http/client/BaseTestHttpFSWith.java index 0ffb62cc3d..c7dc6f8d7c 100644 --- a/hadoop-hdfs-project/hadoop-hdfs-httpfs/src/test/java/org/apache/hadoop/fs/http/client/BaseTestHttpFSWith.java +++ b/hadoop-hdfs-project/hadoop-hdfs-httpfs/src/test/java/org/apache/hadoop/fs/http/client/BaseTestHttpFSWith.java @@ -38,7 +38,6 @@ import org.apache.hadoop.hdfs.DFSConfigKeys; import org.apache.hadoop.hdfs.DFSTestUtil; import org.apache.hadoop.hdfs.DistributedFileSystem; -import org.apache.hadoop.hdfs.protocol.BlockStoragePolicy; import org.apache.hadoop.hdfs.protocol.HdfsConstants; import org.apache.hadoop.hdfs.protocol.SnapshotException; import org.apache.hadoop.hdfs.web.WebHdfsFileSystem; @@ -1029,13 +1028,9 @@ private void testStoragePolicy() throws Exception { Path path = new Path(getProxiedFSTestDir(), "policy.txt"); FileSystem httpfs = getHttpFSFileSystem(); // test getAllStoragePolicies - BlockStoragePolicy[] dfsPolicies = (BlockStoragePolicy[]) fs - .getAllStoragePolicies().toArray(); - BlockStoragePolicy[] httpPolicies = (BlockStoragePolicy[]) httpfs - .getAllStoragePolicies().toArray(); Assert.assertArrayEquals( "Policy array returned from the DFS and HttpFS should be equals", - dfsPolicies, httpPolicies); + fs.getAllStoragePolicies().toArray(), httpfs.getAllStoragePolicies().toArray()); // test get/set/unset policies DFSTestUtil.createFile(fs, path, 0, (short) 1, 0L); diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/web/TestWebHDFS.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/web/TestWebHDFS.java index a766de6995..d7ed46b442 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/web/TestWebHDFS.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/web/TestWebHDFS.java @@ -81,7 +81,6 @@ import org.apache.hadoop.hdfs.TestDFSClientRetries; import org.apache.hadoop.hdfs.TestFileCreation; import org.apache.hadoop.hdfs.client.HdfsClientConfigKeys; -import org.apache.hadoop.hdfs.protocol.BlockStoragePolicy; import org.apache.hadoop.hdfs.protocol.ErasureCodingPolicy; import org.apache.hadoop.hdfs.protocol.SystemErasureCodingPolicies; import org.apache.hadoop.hdfs.protocol.HdfsConstants; @@ -1405,11 +1404,8 @@ public void testStoragePolicy() throws Exception { conf, WebHdfsConstants.WEBHDFS_SCHEME); // test getAllStoragePolicies - BlockStoragePolicy[] dfsPolicies = (BlockStoragePolicy[]) dfs - .getAllStoragePolicies().toArray(); - BlockStoragePolicy[] webHdfsPolicies = (BlockStoragePolicy[]) webHdfs - .getAllStoragePolicies().toArray(); - Assert.assertTrue(Arrays.equals(dfsPolicies, webHdfsPolicies)); + Assert.assertTrue(Arrays.equals(dfs.getAllStoragePolicies().toArray(), + webHdfs.getAllStoragePolicies().toArray())); // test get/set/unset policies DFSTestUtil.createFile(dfs, path, 0, (short) 1, 0L);