diff --git a/hadoop-client-modules/hadoop-client-integration-tests/src/test/java/org/apache/hadoop/example/ITUseMiniCluster.java b/hadoop-client-modules/hadoop-client-integration-tests/src/test/java/org/apache/hadoop/example/ITUseMiniCluster.java index 3f560d0c83..5fcbe13c97 100644 --- a/hadoop-client-modules/hadoop-client-integration-tests/src/test/java/org/apache/hadoop/example/ITUseMiniCluster.java +++ b/hadoop-client-modules/hadoop-client-integration-tests/src/test/java/org/apache/hadoop/example/ITUseMiniCluster.java @@ -82,7 +82,7 @@ public void clusterDown() { @Test public void useHdfsFileSystem() throws IOException { - try (final FileSystem fs = cluster.getFileSystem()) { + try (FileSystem fs = cluster.getFileSystem()) { simpleReadAfterWrite(fs); } } @@ -94,10 +94,10 @@ public void simpleReadAfterWrite(final FileSystem fs) throws IOException { throw new IOException("Mkdirs failed to create " + TEST_PATH); } - try (final FSDataOutputStream out = fs.create(path)) { + try (FSDataOutputStream out = fs.create(path)) { out.writeUTF(TEXT); } - try (final FSDataInputStream in = fs.open(path)) { + try (FSDataInputStream in = fs.open(path)) { final String result = in.readUTF(); Assert.assertEquals("Didn't read back text we wrote.", TEXT, result); } @@ -105,7 +105,7 @@ public void simpleReadAfterWrite(final FileSystem fs) throws IOException { @Test public void useWebHDFS() throws IOException, URISyntaxException { - try (final FileSystem fs = WebHdfsTestUtil.getWebHdfsFileSystem( + try (FileSystem fs = WebHdfsTestUtil.getWebHdfsFileSystem( cluster.getConfiguration(0), WebHdfsConstants.WEBHDFS_SCHEME)) { simpleReadAfterWrite(fs); } diff --git a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/ipc/TestIPC.java b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/ipc/TestIPC.java index 611000d8cf..1d47473533 100644 --- a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/ipc/TestIPC.java +++ b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/ipc/TestIPC.java @@ -1425,7 +1425,7 @@ public void testSecureVersionMismatch() throws IOException { } private void checkVersionMismatch() throws IOException { - try (final ServerSocket listenSocket = new ServerSocket()) { + try (ServerSocket listenSocket = new ServerSocket()) { listenSocket.bind(null); InetSocketAddress addr = (InetSocketAddress) listenSocket.getLocalSocketAddress(); diff --git a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/metrics2/lib/TestRollingAverages.java b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/metrics2/lib/TestRollingAverages.java index 44202e788e..6ea3d26ecc 100644 --- a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/metrics2/lib/TestRollingAverages.java +++ b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/metrics2/lib/TestRollingAverages.java @@ -42,7 +42,7 @@ public class TestRollingAverages { public void testRollingAveragesEmptyRollover() throws Exception { final MetricsRecordBuilder rb = mockMetricsRecordBuilder(); /* 5s interval and 2 windows */ - try (final RollingAverages rollingAverages = + try (RollingAverages rollingAverages = new RollingAverages(5000, 2)) { /* Check it initially */ rollingAverages.snapshot(rb, true); diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestMiniDFSCluster.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestMiniDFSCluster.java index 3d4cc72859..d631b68ddf 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestMiniDFSCluster.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestMiniDFSCluster.java @@ -254,7 +254,7 @@ public void testClusterSetDatanodeDifferentStorageType() throws IOException { @Test public void testClusterNoStorageTypeSetForDatanodes() throws IOException { final Configuration conf = new HdfsConfiguration(); - try (final MiniDFSCluster cluster = new MiniDFSCluster.Builder(conf) + try (MiniDFSCluster cluster = new MiniDFSCluster.Builder(conf) .numDataNodes(3).build()) { cluster.waitActive(); ArrayList dataNodes = cluster.getDataNodes(); diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/balancer/TestBalancer.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/balancer/TestBalancer.java index dd28914b1e..016a233279 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/balancer/TestBalancer.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/balancer/TestBalancer.java @@ -1847,7 +1847,7 @@ public void testMinBlockSizeAndSourceNodes() throws Exception { for(int i = 0; i < lengths.length; i++) { final long size = lengths[i]; final Path p = new Path("/file" + i + "_size" + size); - try(final OutputStream out = dfs.create(p)) { + try(OutputStream out = dfs.create(p)) { for(int j = 0; j < size; j++) { out.write(j); } diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/datanode/TestDataNodeFaultInjector.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/datanode/TestDataNodeFaultInjector.java index fe654292b9..1507844ae3 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/datanode/TestDataNodeFaultInjector.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/datanode/TestDataNodeFaultInjector.java @@ -153,7 +153,7 @@ private void verifyFaultInjectionDelayPipeline( cluster.waitActive(); final FileSystem fs = cluster.getFileSystem(); - try (final FSDataOutputStream out = fs + try (FSDataOutputStream out = fs .create(new Path(baseDir, "test.data"), (short) 2)) { out.write(0x31); out.hflush(); diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/test/java/org/apache/hadoop/yarn/client/api/impl/TestYarnClient.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/test/java/org/apache/hadoop/yarn/client/api/impl/TestYarnClient.java index 9adc1872c4..7d7272a581 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/test/java/org/apache/hadoop/yarn/client/api/impl/TestYarnClient.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/test/java/org/apache/hadoop/yarn/client/api/impl/TestYarnClient.java @@ -303,7 +303,7 @@ public void testSubmitApplicationInterrupted() throws IOException { int pollIntervalMs = 1000; conf.setLong(YarnConfiguration.YARN_CLIENT_APP_SUBMISSION_POLL_INTERVAL_MS, pollIntervalMs); - try (final YarnClient client = new MockYarnClient()) { + try (YarnClient client = new MockYarnClient()) { client.init(conf); client.start(); // Submit the application and then interrupt it while its waiting