Repository: hadoop Updated Branches: refs/heads/branch-2 6ee0fe70c -> cb4679261 refs/heads/trunk f9139ac8f -> 5e4434f62
HADOOP-14709. Fix checkstyle warnings in ContractTestUtils. Contributed by Thomas Marquardt. Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/cb467926 Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/cb467926 Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/cb467926 Branch: refs/heads/branch-2 Commit: cb4679261097e729b433a523e3a65779fdc83841 Parents: 6ee0fe7 Author: Steve Loughran <[email protected]> Authored: Wed Aug 2 12:46:30 2017 +0100 Committer: Steve Loughran <[email protected]> Committed: Wed Aug 2 12:46:30 2017 +0100 ---------------------------------------------------------------------- .../hadoop/fs/contract/ContractTestUtils.java | 35 +++++++++++--------- 1 file changed, 20 insertions(+), 15 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/hadoop/blob/cb467926/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/contract/ContractTestUtils.java ---------------------------------------------------------------------- diff --git a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/contract/ContractTestUtils.java b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/contract/ContractTestUtils.java index 26529f8..ab8136a 100644 --- a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/contract/ContractTestUtils.java +++ b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/contract/ContractTestUtils.java @@ -70,7 +70,8 @@ public class ContractTestUtils extends Assert { * Assert that a property in the property set matches the expected value. * @param props property set * @param key property name - * @param expected expected value. If null, the property must not be in the set + * @param expected expected value. If null, the property must not be in the + * set */ public static void assertPropertyEquals(Properties props, String key, @@ -232,7 +233,7 @@ public class ContractTestUtils extends Assert { assertTrue("not a file " + statText, stat.isFile()); assertEquals("wrong length " + statText, original.length, stat.getLen()); byte[] bytes = readDataset(fs, path, original.length); - compareByteArrays(original,bytes,original.length); + compareByteArrays(original, bytes, original.length); } /** @@ -251,7 +252,7 @@ public class ContractTestUtils extends Assert { stm.readFully(out); byte[] expected = Arrays.copyOfRange(fileContents, seekOff, seekOff + toRead); - compareByteArrays(expected, out,toRead); + compareByteArrays(expected, out, toRead); } /** @@ -268,11 +269,11 @@ public class ContractTestUtils extends Assert { assertEquals("Number of bytes read != number written", len, received.length); int errors = 0; - int first_error_byte = -1; + int firstErrorByte = -1; for (int i = 0; i < len; i++) { if (original[i] != received[i]) { if (errors == 0) { - first_error_byte = i; + firstErrorByte = i; } errors++; } @@ -285,8 +286,8 @@ public class ContractTestUtils extends Assert { // the range either side of the first error to print // this is a purely arbitrary number, to aid user debugging final int overlap = 10; - for (int i = Math.max(0, first_error_byte - overlap); - i < Math.min(first_error_byte + overlap, len); + for (int i = Math.max(0, firstErrorByte - overlap); + i < Math.min(firstErrorByte + overlap, len); i++) { byte actual = received[i]; byte expected = original[i]; @@ -479,7 +480,7 @@ public class ContractTestUtils extends Assert { public static void downgrade(String message, Throwable failure) { LOG.warn("Downgrading test " + message, failure); AssumptionViolatedException ave = - new AssumptionViolatedException(failure, null); + new AssumptionViolatedException(failure, null); throw ave; } @@ -523,9 +524,9 @@ public class ContractTestUtils extends Assert { int expected) throws IOException { FileStatus status = fs.getFileStatus(path); assertEquals( - "Wrong file length of file " + path + " status: " + status, - expected, - status.getLen()); + "Wrong file length of file " + path + " status: " + status, + expected, + status.getLen()); } /** @@ -684,7 +685,8 @@ public class ContractTestUtils extends Assert { */ public static String ls(FileSystem fileSystem, Path path) throws IOException { if (path == null) { - //surfaces when someone calls getParent() on something at the top of the path + // surfaces when someone calls getParent() on something at the top of the + // path return "/"; } FileStatus[] stats; @@ -866,7 +868,7 @@ public class ContractTestUtils extends Assert { } /** - * Test for the host being an OSX machine + * Test for the host being an OSX machine. * @return true if the JVM thinks that is running on OSX */ public static boolean isOSX() { @@ -889,8 +891,9 @@ public class ContractTestUtils extends Assert { break; } } - if (mismatch) + if (mismatch) { break; + } } assertFalse("File content of file is not as expected at offset " + idx, mismatch); @@ -1000,7 +1003,9 @@ public class ContractTestUtils extends Assert { * @throws IOException * thrown if an I/O error occurs while writing or reading the test file */ - public static void createAndVerifyFile(FileSystem fs, Path parent, final long fileSize) + public static void createAndVerifyFile(FileSystem fs, + Path parent, + final long fileSize) throws IOException { int testBufferSize = fs.getConf() .getInt(IO_CHUNK_BUFFER_SIZE, DEFAULT_IO_CHUNK_BUFFER_SIZE); --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
