This is an automated email from the ASF dual-hosted git repository. ggregory pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/commons-io.git
The following commit(s) were added to refs/heads/master by this push: new 639f71f Remove trailing white spaces. Use final. 639f71f is described below commit 639f71fa28dfc985b71bc8a7d8bca977d2e76e3f Author: Gary Gregory <gardgreg...@gmail.com> AuthorDate: Fri Aug 14 23:04:49 2020 -0400 Remove trailing white spaces. Use final. --- src/main/java/org/apache/commons/io/Charsets.java | 2 +- src/main/java/org/apache/commons/io/FileUtils.java | 4 +-- src/main/java/org/apache/commons/io/IOUtils.java | 6 ++-- .../commons/io/file/AccumulatorPathVisitor.java | 12 ++++---- .../commons/io/file/CopyDirectoryVisitor.java | 6 ++-- .../java/org/apache/commons/io/file/Counters.java | 12 ++++---- .../commons/io/file/CountingPathVisitor.java | 4 +-- .../org/apache/commons/io/function/IOConsumer.java | 4 +-- .../org/apache/commons/io/function/IOFunction.java | 20 +++++++------- .../commons/io/input/CharSequenceReader.java | 2 +- .../commons/io/input/ReversedLinesFileReader.java | 4 +-- .../org/apache/commons/io/FileSystemTestCase.java | 2 +- .../org/apache/commons/io/FileUtilsTestCase.java | 6 ++-- .../apache/commons/io/IOExceptionListTestCase.java | 6 ++-- .../org/apache/commons/io/IOUtilsTestCase.java | 8 +++--- .../apache/commons/io/LineIteratorTestCase.java | 8 +++--- .../apache/commons/io/file/CounterAssertions.java | 2 +- .../commons/io/input/CharSequenceReaderTest.java | 2 +- .../io/input/CharacterFilterReaderTest.java | 4 +-- .../ReversedLinesFileReaderTestParamBlockSize.java | 32 +++++++++++----------- .../ReversedLinesFileReaderTestParamFile.java | 2 +- .../commons/io/input/SequenceReaderTest.java | 8 +++--- .../org/apache/commons/io/input/TailerTest.java | 2 +- .../io/output/DeferredFileOutputStreamTest.java | 18 ++++++------ .../io/output/FileWriterWithEncodingTest.java | 8 +++--- 25 files changed, 92 insertions(+), 92 deletions(-) diff --git a/src/main/java/org/apache/commons/io/Charsets.java b/src/main/java/org/apache/commons/io/Charsets.java index 56b572b..ecd408b 100644 --- a/src/main/java/org/apache/commons/io/Charsets.java +++ b/src/main/java/org/apache/commons/io/Charsets.java @@ -62,7 +62,7 @@ public class Charsets { private static final SortedMap<String, Charset> STANDARD_CHARSET_MAP; static { - SortedMap<String, Charset> standardCharsetMap = new TreeMap<>(String.CASE_INSENSITIVE_ORDER); + final SortedMap<String, Charset> standardCharsetMap = new TreeMap<>(String.CASE_INSENSITIVE_ORDER); standardCharsetMap.put(StandardCharsets.ISO_8859_1.name(), StandardCharsets.ISO_8859_1); standardCharsetMap.put(StandardCharsets.US_ASCII.name(), StandardCharsets.US_ASCII); standardCharsetMap.put(StandardCharsets.UTF_16.name(), StandardCharsets.UTF_16); diff --git a/src/main/java/org/apache/commons/io/FileUtils.java b/src/main/java/org/apache/commons/io/FileUtils.java index 1d1fbe1..d23ac5c 100644 --- a/src/main/java/org/apache/commons/io/FileUtils.java +++ b/src/main/java/org/apache/commons/io/FileUtils.java @@ -1385,7 +1385,7 @@ public class FileUtils { * @throws IllegalArgumentException "Negative size" if the file is truncated so that the size is less than the * position */ - private static void doCopyFile(final File srcFile, final File destFile, final boolean preserveFileDate, CopyOption... copyOptions) + private static void doCopyFile(final File srcFile, final File destFile, final boolean preserveFileDate, final CopyOption... copyOptions) throws IOException { if (destFile.exists() && destFile.isDirectory()) { throw new IOException("Destination '" + destFile + "' exists but is a directory"); @@ -1440,7 +1440,7 @@ public class FileUtils { final Counters.PathCounters deleteCounters; try { deleteCounters = PathUtils.delete(file.toPath()); - } catch (IOException e) { + } catch (final IOException e) { throw new IOException("Unable to delete file: " + file, e); } diff --git a/src/main/java/org/apache/commons/io/IOUtils.java b/src/main/java/org/apache/commons/io/IOUtils.java index 118a414..216ee7f 100644 --- a/src/main/java/org/apache/commons/io/IOUtils.java +++ b/src/main/java/org/apache/commons/io/IOUtils.java @@ -356,7 +356,7 @@ public class IOUtils { if (closeable != null) { try { closeable.close(); - } catch (IOException e) { + } catch (final IOException e) { if (consumer != null) { consumer.accept(e); } @@ -386,7 +386,7 @@ public class IOUtils { */ public static void close(final Closeable... closeables) throws IOException { if (closeables != null) { - for (Closeable closeable : closeables) { + for (final Closeable closeable : closeables) { close(closeable); } } @@ -404,7 +404,7 @@ public class IOUtils { if (closeable != null) { try { closeable.close(); - } catch (IOException e) { + } catch (final IOException e) { if (consumer != null) { consumer.accept(e); } diff --git a/src/main/java/org/apache/commons/io/file/AccumulatorPathVisitor.java b/src/main/java/org/apache/commons/io/file/AccumulatorPathVisitor.java index c65232f..2215b2a 100644 --- a/src/main/java/org/apache/commons/io/file/AccumulatorPathVisitor.java +++ b/src/main/java/org/apache/commons/io/file/AccumulatorPathVisitor.java @@ -66,12 +66,12 @@ public class AccumulatorPathVisitor extends CountingPathVisitor { * * @param pathCounter How to count path visits. */ - public AccumulatorPathVisitor(PathCounters pathCounter) { + public AccumulatorPathVisitor(final PathCounters pathCounter) { super(pathCounter); } @Override - public boolean equals(Object obj) { + public boolean equals(final Object obj) { if (this == obj) { return true; } @@ -81,7 +81,7 @@ public class AccumulatorPathVisitor extends CountingPathVisitor { if (!(obj instanceof AccumulatorPathVisitor)) { return false; } - AccumulatorPathVisitor other = (AccumulatorPathVisitor) obj; + final AccumulatorPathVisitor other = (AccumulatorPathVisitor) obj; return Objects.equals(dirList, other.dirList) && Objects.equals(fileList, other.fileList); } @@ -120,7 +120,7 @@ public class AccumulatorPathVisitor extends CountingPathVisitor { * @param comparator How to sort, null uses default sorting. * @return A new list */ - public List<Path> relativizeDirectories(final Path parent, boolean sort, Comparator<? super Path> comparator) { + public List<Path> relativizeDirectories(final Path parent, final boolean sort, final Comparator<? super Path> comparator) { return PathUtils.relativize(getDirList(), parent, sort, comparator); } @@ -133,12 +133,12 @@ public class AccumulatorPathVisitor extends CountingPathVisitor { * @param comparator How to sort, null uses default sorting. * @return A new list */ - public List<Path> relativizeFiles(final Path parent, boolean sort, Comparator<? super Path> comparator) { + public List<Path> relativizeFiles(final Path parent, final boolean sort, final Comparator<? super Path> comparator) { return PathUtils.relativize(getFileList(), parent, sort, comparator); } @Override - public FileVisitResult visitFile(Path file, BasicFileAttributes attributes) throws IOException { + public FileVisitResult visitFile(final Path file, final BasicFileAttributes attributes) throws IOException { ((Files.isDirectory(file)) ? dirList : fileList).add(file.normalize()); return super.visitFile(file, attributes); } diff --git a/src/main/java/org/apache/commons/io/file/CopyDirectoryVisitor.java b/src/main/java/org/apache/commons/io/file/CopyDirectoryVisitor.java index 8006362..7e46bbb 100644 --- a/src/main/java/org/apache/commons/io/file/CopyDirectoryVisitor.java +++ b/src/main/java/org/apache/commons/io/file/CopyDirectoryVisitor.java @@ -69,7 +69,7 @@ public class CopyDirectoryVisitor extends CountingPathVisitor { /** * Gets the copy options. - * + * * @return the copy options. * @since 2.8.0 */ @@ -79,7 +79,7 @@ public class CopyDirectoryVisitor extends CountingPathVisitor { /** * Gets the source directory. - * + * * @return the source directory. * @since 2.8.0 */ @@ -89,7 +89,7 @@ public class CopyDirectoryVisitor extends CountingPathVisitor { /** * Gets the target directory. - * + * * @return the target directory. * @since 2.8.0 */ diff --git a/src/main/java/org/apache/commons/io/file/Counters.java b/src/main/java/org/apache/commons/io/file/Counters.java index 44329b6..2bb8da1 100644 --- a/src/main/java/org/apache/commons/io/file/Counters.java +++ b/src/main/java/org/apache/commons/io/file/Counters.java @@ -52,14 +52,14 @@ public class Counters { } @Override - public boolean equals(Object obj) { + public boolean equals(final Object obj) { if (this == obj) { return true; } if (!(obj instanceof AbstractPathCounters)) { return false; } - AbstractPathCounters other = (AbstractPathCounters) obj; + final AbstractPathCounters other = (AbstractPathCounters) obj; return Objects.equals(byteCounter, other.byteCounter) && Objects.equals(directoryCounter, other.directoryCounter) && Objects.equals(fileCounter, other.fileCounter); @@ -112,14 +112,14 @@ public class Counters { } @Override - public boolean equals(Object obj) { + public boolean equals(final Object obj) { if (this == obj) { return true; } if (!(obj instanceof Counter)) { return false; } - Counter other = (Counter) obj; + final Counter other = (Counter) obj; return Objects.equals(value, other.getBigInteger()); } @@ -222,14 +222,14 @@ public class Counters { } @Override - public boolean equals(Object obj) { + public boolean equals(final Object obj) { if (this == obj) { return true; } if (!(obj instanceof Counter)) { return false; } - Counter other = (Counter) obj; + final Counter other = (Counter) obj; return value == other.get(); } diff --git a/src/main/java/org/apache/commons/io/file/CountingPathVisitor.java b/src/main/java/org/apache/commons/io/file/CountingPathVisitor.java index cdda3b2..ccd0fb1 100644 --- a/src/main/java/org/apache/commons/io/file/CountingPathVisitor.java +++ b/src/main/java/org/apache/commons/io/file/CountingPathVisitor.java @@ -66,14 +66,14 @@ public class CountingPathVisitor extends SimplePathVisitor { } @Override - public boolean equals(Object obj) { + public boolean equals(final Object obj) { if (this == obj) { return true; } if (!(obj instanceof CountingPathVisitor)) { return false; } - CountingPathVisitor other = (CountingPathVisitor) obj; + final CountingPathVisitor other = (CountingPathVisitor) obj; return Objects.equals(pathCounters, other.pathCounters); } diff --git a/src/main/java/org/apache/commons/io/function/IOConsumer.java b/src/main/java/org/apache/commons/io/function/IOConsumer.java index 8474533..12d4ed9 100644 --- a/src/main/java/org/apache/commons/io/function/IOConsumer.java +++ b/src/main/java/org/apache/commons/io/function/IOConsumer.java @@ -48,9 +48,9 @@ public interface IOConsumer<T> { * operation * @throws NullPointerException if {@code after} is null */ - default IOConsumer<T> andThen(IOConsumer<? super T> after) { + default IOConsumer<T> andThen(final IOConsumer<? super T> after) { Objects.requireNonNull(after); - return (T t) -> { + return (final T t) -> { accept(t); after.accept(t); }; diff --git a/src/main/java/org/apache/commons/io/function/IOFunction.java b/src/main/java/org/apache/commons/io/function/IOFunction.java index 332e346..7089003 100644 --- a/src/main/java/org/apache/commons/io/function/IOFunction.java +++ b/src/main/java/org/apache/commons/io/function/IOFunction.java @@ -60,7 +60,7 @@ public interface IOFunction<T, R> { */ default <V> IOFunction<V, R> compose(final IOFunction<? super V, ? extends T> before) { Objects.requireNonNull(before); - return (V v) -> apply(before.apply(v)); + return (final V v) -> apply(before.apply(v)); } /** @@ -80,7 +80,7 @@ public interface IOFunction<T, R> { */ default <V> IOFunction<V, R> compose(final Function<? super V, ? extends T> before) { Objects.requireNonNull(before); - return (V v) -> apply(before.apply(v)); + return (final V v) -> apply(before.apply(v)); } /** @@ -134,9 +134,9 @@ public interface IOFunction<T, R> { * * @see #compose(IOFunction) */ - default <V> IOFunction<T, V> andThen(IOFunction<? super R, ? extends V> after) { + default <V> IOFunction<T, V> andThen(final IOFunction<? super R, ? extends V> after) { Objects.requireNonNull(after); - return (T t) -> after.apply(apply(t)); + return (final T t) -> after.apply(apply(t)); } /** @@ -154,9 +154,9 @@ public interface IOFunction<T, R> { * * @see #compose(IOFunction) */ - default <V> IOFunction<T, V> andThen(Function<? super R, ? extends V> after) { + default <V> IOFunction<T, V> andThen(final Function<? super R, ? extends V> after) { Objects.requireNonNull(after); - return (T t) -> after.apply(apply(t)); + return (final T t) -> after.apply(apply(t)); } /** @@ -172,9 +172,9 @@ public interface IOFunction<T, R> { * * @see #compose(IOFunction) */ - default IOConsumer<T> andThen(IOConsumer<? super R> after) { + default IOConsumer<T> andThen(final IOConsumer<? super R> after) { Objects.requireNonNull(after); - return (T t) -> after.accept(apply(t)); + return (final T t) -> after.accept(apply(t)); } /** @@ -190,9 +190,9 @@ public interface IOFunction<T, R> { * * @see #compose(IOFunction) */ - default IOConsumer<T> andThen(Consumer<? super R> after) { + default IOConsumer<T> andThen(final Consumer<? super R> after) { Objects.requireNonNull(after); - return (T t) -> after.accept(apply(t)); + return (final T t) -> after.accept(apply(t)); } /** diff --git a/src/main/java/org/apache/commons/io/input/CharSequenceReader.java b/src/main/java/org/apache/commons/io/input/CharSequenceReader.java index 1c356ba..7a7fcd3 100644 --- a/src/main/java/org/apache/commons/io/input/CharSequenceReader.java +++ b/src/main/java/org/apache/commons/io/input/CharSequenceReader.java @@ -298,7 +298,7 @@ public class CharSequenceReader extends Reader implements Serializable { */ @Override public String toString() { - CharSequence subSequence = charSequence.subSequence(start(), end()); + final CharSequence subSequence = charSequence.subSequence(start(), end()); return subSequence.toString(); } } diff --git a/src/main/java/org/apache/commons/io/input/ReversedLinesFileReader.java b/src/main/java/org/apache/commons/io/input/ReversedLinesFileReader.java index 881c968..d5f3fdd 100644 --- a/src/main/java/org/apache/commons/io/input/ReversedLinesFileReader.java +++ b/src/main/java/org/apache/commons/io/input/ReversedLinesFileReader.java @@ -228,7 +228,7 @@ public class ReversedLinesFileReader implements Closeable { /** * Returns the lines of the file from bottom to top. - * + * * @return the next line or null if the start of the file is reached * @throws IOException if an I/O error occurs */ @@ -268,7 +268,7 @@ public class ReversedLinesFileReader implements Closeable { * @throws IOException if an I/O error occurs * @since 2.8.0 */ - public List<String> readLines(int lineCount) throws IOException { + public List<String> readLines(final int lineCount) throws IOException { if (lineCount < 0) { throw new IllegalArgumentException("lineCount < 0"); } diff --git a/src/test/java/org/apache/commons/io/FileSystemTestCase.java b/src/test/java/org/apache/commons/io/FileSystemTestCase.java index 6325cbf..4a7a7bb 100644 --- a/src/test/java/org/apache/commons/io/FileSystemTestCase.java +++ b/src/test/java/org/apache/commons/io/FileSystemTestCase.java @@ -26,7 +26,7 @@ import org.junit.jupiter.api.Test; public class FileSystemTestCase { - + @Test public void testGetCurrent() { if (SystemUtils.IS_OS_WINDOWS) { diff --git a/src/test/java/org/apache/commons/io/FileUtilsTestCase.java b/src/test/java/org/apache/commons/io/FileUtilsTestCase.java index 8778b67..e6c0a39 100644 --- a/src/test/java/org/apache/commons/io/FileUtilsTestCase.java +++ b/src/test/java/org/apache/commons/io/FileUtilsTestCase.java @@ -1693,7 +1693,7 @@ public class FileUtilsTestCase { assertEquals(testFile1Size, destination.length(), "Check Full copy"); assertEquals(testFile1.lastModified(), destination.lastModified(), "Check last modified date preserved"); - assertThrows(IOException.class, + assertThrows(IOException.class, () -> FileUtils.copyFileToDirectory(destination, directory), "Should not be able to copy a file into the same directory as itself"); } @@ -3088,7 +3088,7 @@ public class FileUtilsTestCase { } } - private void backDateFile10Minutes(File testFile) throws IOException { + private void backDateFile10Minutes(final File testFile) throws IOException { final long mins10 = 1000 * 60 * 10; final long lastModified1 = getLastModifiedMillis(testFile); assertTrue(setLastModifiedMillis(testFile, lastModified1 - mins10)); @@ -3096,7 +3096,7 @@ public class FileUtilsTestCase { assertNotEquals(getLastModifiedMillis(testFile), lastModified1, "Should have changed source date"); } - private boolean setLastModifiedMillis(File testFile, final long millis) { + private boolean setLastModifiedMillis(final File testFile, final long millis) { return testFile.setLastModified(millis); // try { // Files.setLastModifiedTime(testFile.toPath(), FileTime.fromMillis(millis)); diff --git a/src/test/java/org/apache/commons/io/IOExceptionListTestCase.java b/src/test/java/org/apache/commons/io/IOExceptionListTestCase.java index b016c6e..ebe0b2d 100644 --- a/src/test/java/org/apache/commons/io/IOExceptionListTestCase.java +++ b/src/test/java/org/apache/commons/io/IOExceptionListTestCase.java @@ -58,10 +58,10 @@ public class IOExceptionListTestCase { final EOFException cause = new EOFException(); final List<EOFException> list = Collections.singletonList(cause); final IOExceptionList sqlExceptionList = new IOExceptionList(list); - StringWriter sw = new StringWriter(); - PrintWriter pw = new PrintWriter(sw); + final StringWriter sw = new StringWriter(); + final PrintWriter pw = new PrintWriter(sw); sqlExceptionList.printStackTrace(pw); - String st = sw.toString(); + final String st = sw.toString(); assertTrue(st.startsWith("org.apache.commons.io.IOExceptionList: 1 exceptions: [java.io.EOFException]")); assertTrue(st.contains("Caused by: java.io.EOFException")); } diff --git a/src/test/java/org/apache/commons/io/IOUtilsTestCase.java b/src/test/java/org/apache/commons/io/IOUtilsTestCase.java index d3449e4..eb67611 100644 --- a/src/test/java/org/apache/commons/io/IOUtilsTestCase.java +++ b/src/test/java/org/apache/commons/io/IOUtilsTestCase.java @@ -148,8 +148,8 @@ public class IOUtilsTestCase { @Test public void testCloseMulti() { - Closeable nulCloseable = null; - Closeable[] closeables = {null, null}; + final Closeable nulCloseable = null; + final Closeable[] closeables = {null, null}; assertDoesNotThrow(() -> IOUtils.close(nulCloseable, nulCloseable)); assertDoesNotThrow(() -> IOUtils.close(closeables)); assertDoesNotThrow(() -> IOUtils.close((Closeable[]) null)); @@ -160,7 +160,7 @@ public class IOUtilsTestCase { @Test public void testCloseConsumer() { - Closeable nulCloseable = null; + final Closeable nulCloseable = null; assertDoesNotThrow(() -> IOUtils.close(nulCloseable, null)); // null consumer assertDoesNotThrow(() -> IOUtils.close(new StringReader("s"), null)); // null consumer assertDoesNotThrow(() -> IOUtils.close(new ThrowOnCloseReader(new StringReader("s")), null)); // null consumer @@ -195,7 +195,7 @@ public class IOUtilsTestCase { assertDoesNotThrow(() -> { IOUtils.closeQuietly((Closeable) () -> { throw new IOException(); - }); + }); }); } diff --git a/src/test/java/org/apache/commons/io/LineIteratorTestCase.java b/src/test/java/org/apache/commons/io/LineIteratorTestCase.java index 6847f9a..4d6dad4 100644 --- a/src/test/java/org/apache/commons/io/LineIteratorTestCase.java +++ b/src/test/java/org/apache/commons/io/LineIteratorTestCase.java @@ -57,7 +57,7 @@ public class LineIteratorTestCase { } finally { try { IOUtils.close(iterator); - } catch (IOException ignored) { + } catch (final IOException ignored) { // Ignored } } @@ -114,7 +114,7 @@ public class LineIteratorTestCase { assertThrows(IllegalArgumentException.class, () -> { try ( LineIterator li = new LineIterator(null); - ) { } + ) { } }); } @@ -249,7 +249,7 @@ public class LineIteratorTestCase { assertThrows(IllegalStateException.class, () -> { li.hasNext(); }); - } + } } @Test @@ -421,7 +421,7 @@ public class LineIteratorTestCase { } finally { try { IOUtils.close(iterator); - } catch (IOException ignored) { + } catch (final IOException ignored) { // Ignored } } diff --git a/src/test/java/org/apache/commons/io/file/CounterAssertions.java b/src/test/java/org/apache/commons/io/file/CounterAssertions.java index 5544e88..ff27231 100644 --- a/src/test/java/org/apache/commons/io/file/CounterAssertions.java +++ b/src/test/java/org/apache/commons/io/file/CounterAssertions.java @@ -26,7 +26,7 @@ import org.apache.commons.io.file.Counters.PathCounters; class CounterAssertions { - static void assertCounter(final long expected, final Counter actual, String message) { + static void assertCounter(final long expected, final Counter actual, final String message) { assertEquals(expected, actual.get(), message); assertEquals(Long.valueOf(expected), actual.getLong(), message); assertEquals(BigInteger.valueOf(expected), actual.getBigInteger(), message); diff --git a/src/test/java/org/apache/commons/io/input/CharSequenceReaderTest.java b/src/test/java/org/apache/commons/io/input/CharSequenceReaderTest.java index bc88578..2afabe9 100644 --- a/src/test/java/org/apache/commons/io/input/CharSequenceReaderTest.java +++ b/src/test/java/org/apache/commons/io/input/CharSequenceReaderTest.java @@ -285,7 +285,7 @@ public class CharSequenceReaderTest { assertEquals(-1, reader.read()); } - ByteArrayOutputStream baos = new ByteArrayOutputStream(); + final ByteArrayOutputStream baos = new ByteArrayOutputStream(); try (ObjectOutputStream oos = new ObjectOutputStream(baos)) { final CharSequenceReader reader = new CharSequenceReader("xFooBarx", 1, 7); oos.writeObject(reader); diff --git a/src/test/java/org/apache/commons/io/input/CharacterFilterReaderTest.java b/src/test/java/org/apache/commons/io/input/CharacterFilterReaderTest.java index 42de02e..80a4f45 100644 --- a/src/test/java/org/apache/commons/io/input/CharacterFilterReaderTest.java +++ b/src/test/java/org/apache/commons/io/input/CharacterFilterReaderTest.java @@ -76,8 +76,8 @@ public class CharacterFilterReaderTest { public void testReadIntoBuffer() throws IOException { final StringReader input = new StringReader("ababcabcd"); try (CharacterFilterReader reader = new CharacterFilterReader(input, 'b')) { - char[] buff = new char[9]; - int charCount = reader.read(buff); + final char[] buff = new char[9]; + final int charCount = reader.read(buff); assertEquals(6, charCount); assertEquals("aacacd", new String(buff, 0, charCount)); } diff --git a/src/test/java/org/apache/commons/io/input/ReversedLinesFileReaderTestParamBlockSize.java b/src/test/java/org/apache/commons/io/input/ReversedLinesFileReaderTestParamBlockSize.java index 823f0d3..fd84598 100644 --- a/src/test/java/org/apache/commons/io/input/ReversedLinesFileReaderTestParamBlockSize.java +++ b/src/test/java/org/apache/commons/io/input/ReversedLinesFileReaderTestParamBlockSize.java @@ -79,7 +79,7 @@ public class ReversedLinesFileReaderTestParamBlockSize { @ParameterizedTest(name = "BlockSize={0}") @MethodSource("blockSizes") - public void testIsoFileDefaults(int testParamBlockSize) throws URISyntaxException, IOException { + public void testIsoFileDefaults(final int testParamBlockSize) throws URISyntaxException, IOException { final File testFileIso = new File(this.getClass().getResource("/test-file-iso8859-1.bin").toURI()); reversedLinesFileReader = new ReversedLinesFileReader(testFileIso, testParamBlockSize, ISO_8859_1); assertFileWithShrinkingTestLines(reversedLinesFileReader); @@ -87,7 +87,7 @@ public class ReversedLinesFileReaderTestParamBlockSize { @ParameterizedTest(name = "BlockSize={0}") @MethodSource("blockSizes") - public void testUTF8FileWindowsBreaks(int testParamBlockSize) throws URISyntaxException, IOException { + public void testUTF8FileWindowsBreaks(final int testParamBlockSize) throws URISyntaxException, IOException { final File testFileIso = new File(this.getClass().getResource("/test-file-utf8-win-linebr.bin").toURI()); reversedLinesFileReader = new ReversedLinesFileReader(testFileIso, testParamBlockSize, UTF_8); assertFileWithShrinkingTestLines(reversedLinesFileReader); @@ -95,7 +95,7 @@ public class ReversedLinesFileReaderTestParamBlockSize { @ParameterizedTest(name = "BlockSize={0}") @MethodSource("blockSizes") - public void testUTF8FileCRBreaks(int testParamBlockSize) throws URISyntaxException, IOException { + public void testUTF8FileCRBreaks(final int testParamBlockSize) throws URISyntaxException, IOException { final File testFileIso = new File(this.getClass().getResource("/test-file-utf8-cr-only.bin").toURI()); reversedLinesFileReader = new ReversedLinesFileReader(testFileIso, testParamBlockSize, UTF_8); assertFileWithShrinkingTestLines(reversedLinesFileReader); @@ -103,7 +103,7 @@ public class ReversedLinesFileReaderTestParamBlockSize { @ParameterizedTest(name = "BlockSize={0}") @MethodSource("blockSizes") - public void testUTF8File(int testParamBlockSize) throws URISyntaxException, IOException { + public void testUTF8File(final int testParamBlockSize) throws URISyntaxException, IOException { final File testFileIso = new File(this.getClass().getResource("/test-file-utf8.bin").toURI()); reversedLinesFileReader = new ReversedLinesFileReader(testFileIso, testParamBlockSize, UTF_8); assertFileWithShrinkingTestLines(reversedLinesFileReader); @@ -111,7 +111,7 @@ public class ReversedLinesFileReaderTestParamBlockSize { @ParameterizedTest(name = "BlockSize={0}") @MethodSource("blockSizes") - public void testEmptyFile(int testParamBlockSize) throws URISyntaxException, IOException { + public void testEmptyFile(final int testParamBlockSize) throws URISyntaxException, IOException { final File testFileEmpty = new File(this.getClass().getResource("/test-file-empty.bin").toURI()); reversedLinesFileReader = new ReversedLinesFileReader(testFileEmpty, testParamBlockSize, UTF_8); assertNull(reversedLinesFileReader.readLine()); @@ -119,7 +119,7 @@ public class ReversedLinesFileReaderTestParamBlockSize { @ParameterizedTest(name = "BlockSize={0}") @MethodSource("blockSizes") - public void testUTF16BEFile(int testParamBlockSize) throws URISyntaxException, IOException { + public void testUTF16BEFile(final int testParamBlockSize) throws URISyntaxException, IOException { final File testFileUTF16BE = new File(this.getClass().getResource("/test-file-utf16be.bin").toURI()); reversedLinesFileReader = new ReversedLinesFileReader(testFileUTF16BE, testParamBlockSize, "UTF-16BE"); assertFileWithShrinkingTestLines(reversedLinesFileReader); @@ -127,7 +127,7 @@ public class ReversedLinesFileReaderTestParamBlockSize { @ParameterizedTest(name = "BlockSize={0}") @MethodSource("blockSizes") - public void testUTF16LEFile(int testParamBlockSize) throws URISyntaxException, IOException { + public void testUTF16LEFile(final int testParamBlockSize) throws URISyntaxException, IOException { final File testFileUTF16LE = new File(this.getClass().getResource("/test-file-utf16le.bin").toURI()); reversedLinesFileReader = new ReversedLinesFileReader(testFileUTF16LE, testParamBlockSize, "UTF-16LE"); assertFileWithShrinkingTestLines(reversedLinesFileReader); @@ -135,7 +135,7 @@ public class ReversedLinesFileReaderTestParamBlockSize { @ParameterizedTest(name = "BlockSize={0}") @MethodSource("blockSizes") - public void testShiftJISFile(int testParamBlockSize) throws URISyntaxException, IOException { + public void testShiftJISFile(final int testParamBlockSize) throws URISyntaxException, IOException { final File testFileShiftJIS = new File(this.getClass().getResource("/test-file-shiftjis.bin").toURI()); reversedLinesFileReader = new ReversedLinesFileReader(testFileShiftJIS, testParamBlockSize, "Shift_JIS"); assertEqualsAndNoLineBreaks(TEST_LINE_SHIFT_JIS2, reversedLinesFileReader.readLine()); @@ -144,7 +144,7 @@ public class ReversedLinesFileReaderTestParamBlockSize { @ParameterizedTest(name = "BlockSize={0}") @MethodSource("blockSizes") - public void testWindows31jFile(int testParamBlockSize) throws URISyntaxException, IOException { + public void testWindows31jFile(final int testParamBlockSize) throws URISyntaxException, IOException { final File testFileWindows31J = new File(this.getClass().getResource("/test-file-windows-31j.bin").toURI()); reversedLinesFileReader = new ReversedLinesFileReader(testFileWindows31J, testParamBlockSize, "windows-31j"); assertEqualsAndNoLineBreaks(TEST_LINE_WINDOWS_31J_2, reversedLinesFileReader.readLine()); @@ -153,7 +153,7 @@ public class ReversedLinesFileReaderTestParamBlockSize { @ParameterizedTest(name = "BlockSize={0}") @MethodSource("blockSizes") - public void testGBK(int testParamBlockSize) throws URISyntaxException, IOException { + public void testGBK(final int testParamBlockSize) throws URISyntaxException, IOException { final File testFileGBK = new File(this.getClass().getResource("/test-file-gbk.bin").toURI()); reversedLinesFileReader = new ReversedLinesFileReader(testFileGBK, testParamBlockSize, "GBK"); assertEqualsAndNoLineBreaks(TEST_LINE_GBK_2, reversedLinesFileReader.readLine()); @@ -162,7 +162,7 @@ public class ReversedLinesFileReaderTestParamBlockSize { @ParameterizedTest(name = "BlockSize={0}") @MethodSource("blockSizes") - public void testxWindows949File(int testParamBlockSize) throws URISyntaxException, IOException { + public void testxWindows949File(final int testParamBlockSize) throws URISyntaxException, IOException { final File testFilexWindows949 = new File(this.getClass().getResource("/test-file-x-windows-949.bin").toURI()); reversedLinesFileReader = new ReversedLinesFileReader(testFilexWindows949, testParamBlockSize, "x-windows-949"); assertEqualsAndNoLineBreaks(TEST_LINE_X_WINDOWS_949_2, reversedLinesFileReader.readLine()); @@ -171,7 +171,7 @@ public class ReversedLinesFileReaderTestParamBlockSize { @ParameterizedTest(name = "BlockSize={0}") @MethodSource("blockSizes") - public void testxWindows950File(int testParamBlockSize) throws URISyntaxException, IOException { + public void testxWindows950File(final int testParamBlockSize) throws URISyntaxException, IOException { final File testFilexWindows950 = new File(this.getClass().getResource("/test-file-x-windows-950.bin").toURI()); reversedLinesFileReader = new ReversedLinesFileReader(testFilexWindows950, testParamBlockSize, "x-windows-950"); assertEqualsAndNoLineBreaks(TEST_LINE_X_WINDOWS_950_2, reversedLinesFileReader.readLine()); @@ -189,7 +189,7 @@ public class ReversedLinesFileReaderTestParamBlockSize { @ParameterizedTest(name = "BlockSize={0}") @MethodSource("blockSizes") - public void testUTF8FileWindowsBreaksSmallBlockSize2VerifyBlockSpanningNewLines(int testParamBlockSize) throws URISyntaxException, IOException { + public void testUTF8FileWindowsBreaksSmallBlockSize2VerifyBlockSpanningNewLines(final int testParamBlockSize) throws URISyntaxException, IOException { final File testFileUtf8 = new File(this.getClass().getResource("/test-file-utf8-win-linebr.bin").toURI()); reversedLinesFileReader = new ReversedLinesFileReader(testFileUtf8, testParamBlockSize, UTF_8); assertFileWithShrinkingTestLines(reversedLinesFileReader); @@ -197,7 +197,7 @@ public class ReversedLinesFileReaderTestParamBlockSize { @ParameterizedTest(name = "BlockSize={0}") @MethodSource("blockSizes") - public void testIsoFileManyWindowsBreaksSmallBlockSize2VerifyBlockSpanningNewLines(int testParamBlockSize) throws URISyntaxException, IOException { + public void testIsoFileManyWindowsBreaksSmallBlockSize2VerifyBlockSpanningNewLines(final int testParamBlockSize) throws URISyntaxException, IOException { final File testFileIso = new File(this.getClass().getResource("/test-file-iso8859-1-shortlines-win-linebr.bin").toURI()); reversedLinesFileReader = new ReversedLinesFileReader(testFileIso, testParamBlockSize, ISO_8859_1); @@ -211,7 +211,7 @@ public class ReversedLinesFileReaderTestParamBlockSize { @ParameterizedTest(name = "BlockSize={0}") @MethodSource("blockSizes") - public void testUnsupportedEncodingUTF16(int testParamBlockSize) throws URISyntaxException { + public void testUnsupportedEncodingUTF16(final int testParamBlockSize) throws URISyntaxException { final File testFileEmpty = new File(this.getClass().getResource("/test-file-empty.bin").toURI()); assertThrows(UnsupportedEncodingException.class, () -> new ReversedLinesFileReader(testFileEmpty, testParamBlockSize, "UTF-16").close()); @@ -219,7 +219,7 @@ public class ReversedLinesFileReaderTestParamBlockSize { @ParameterizedTest(name = "BlockSize={0}") @MethodSource("blockSizes") - public void testUnsupportedEncodingBig5(int testParamBlockSize) throws URISyntaxException { + public void testUnsupportedEncodingBig5(final int testParamBlockSize) throws URISyntaxException { final File testFileEncodingBig5 = new File(this.getClass().getResource("/test-file-empty.bin").toURI()); assertThrows(UnsupportedEncodingException.class, () -> new ReversedLinesFileReader(testFileEncodingBig5, testParamBlockSize, "Big5").close()); diff --git a/src/test/java/org/apache/commons/io/input/ReversedLinesFileReaderTestParamFile.java b/src/test/java/org/apache/commons/io/input/ReversedLinesFileReaderTestParamFile.java index b770a38..57a925d 100644 --- a/src/test/java/org/apache/commons/io/input/ReversedLinesFileReaderTestParamFile.java +++ b/src/test/java/org/apache/commons/io/input/ReversedLinesFileReaderTestParamFile.java @@ -72,7 +72,7 @@ public class ReversedLinesFileReaderTestParamFile { file = Files.copy(file, fileSystem.getPath("/" + fileName)); } - Charset encoding = Charset.forName(encodingName); + final Charset encoding = Charset.forName(encodingName); try (ReversedLinesFileReader reversedLinesFileReader = blockSize == null ? new ReversedLinesFileReader(file, encoding) : new ReversedLinesFileReader(file, blockSize, encoding)) { diff --git a/src/test/java/org/apache/commons/io/input/SequenceReaderTest.java b/src/test/java/org/apache/commons/io/input/SequenceReaderTest.java index 7a73a34..041b03b 100644 --- a/src/test/java/org/apache/commons/io/input/SequenceReaderTest.java +++ b/src/test/java/org/apache/commons/io/input/SequenceReaderTest.java @@ -124,7 +124,7 @@ public class SequenceReaderTest { @Test public void testReadCollection() throws IOException { - Collection<Reader> readers = new ArrayList<>(); + final Collection<Reader> readers = new ArrayList<>(); readers.add(new StringReader("F")); readers.add(new StringReader("B")); try (final Reader reader = new SequenceReader(readers)) { @@ -136,10 +136,10 @@ public class SequenceReaderTest { @Test public void testReadIterable() throws IOException { - Collection<Reader> readers = new ArrayList<>(); + final Collection<Reader> readers = new ArrayList<>(); readers.add(new StringReader("F")); readers.add(new StringReader("B")); - Iterable<Reader> iterable = readers; + final Iterable<Reader> iterable = readers; try (final Reader reader = new SequenceReader(iterable)) { assertEquals('F', reader.read()); assertEquals('B', reader.read()); @@ -173,7 +173,7 @@ public class SequenceReaderTest { @Test public void testReadList() throws IOException { - List<Reader> readers = new ArrayList<>(); + final List<Reader> readers = new ArrayList<>(); readers.add(new StringReader("F")); readers.add(new StringReader("B")); try (final Reader reader = new SequenceReader(readers)) { diff --git a/src/test/java/org/apache/commons/io/input/TailerTest.java b/src/test/java/org/apache/commons/io/input/TailerTest.java index 9ad67fd..a77ef48 100644 --- a/src/test/java/org/apache/commons/io/input/TailerTest.java +++ b/src/test/java/org/apache/commons/io/input/TailerTest.java @@ -318,7 +318,7 @@ public class TailerTest { } finally { try { IOUtils.close(reader); - } catch (IOException ignored) { + } catch (final IOException ignored) { // ignored } } diff --git a/src/test/java/org/apache/commons/io/output/DeferredFileOutputStreamTest.java b/src/test/java/org/apache/commons/io/output/DeferredFileOutputStreamTest.java index 178423e..2353bf4 100644 --- a/src/test/java/org/apache/commons/io/output/DeferredFileOutputStreamTest.java +++ b/src/test/java/org/apache/commons/io/output/DeferredFileOutputStreamTest.java @@ -59,7 +59,7 @@ public class DeferredFileOutputStreamTest { */ @ParameterizedTest(name = "initialBufferSize = {0}") @MethodSource("data") - public void testBelowThreshold(int initialBufferSize) { + public void testBelowThreshold(final int initialBufferSize) { final DeferredFileOutputStream dfos = new DeferredFileOutputStream(testBytes.length + 42, initialBufferSize, null); try { @@ -81,7 +81,7 @@ public class DeferredFileOutputStreamTest { */ @ParameterizedTest(name = "initialBufferSize = {0}") @MethodSource("data") - public void testAtThreshold(int initialBufferSize) { + public void testAtThreshold(final int initialBufferSize) { final DeferredFileOutputStream dfos = new DeferredFileOutputStream(testBytes.length, initialBufferSize, null); try { dfos.write(testBytes, 0, testBytes.length); @@ -102,7 +102,7 @@ public class DeferredFileOutputStreamTest { */ @ParameterizedTest(name = "initialBufferSize = {0}") @MethodSource("data") - public void testAboveThreshold(int initialBufferSize) { + public void testAboveThreshold(final int initialBufferSize) { final File testFile = new File("testAboveThreshold.dat"); // Ensure that the test starts from a clean base. @@ -131,7 +131,7 @@ public class DeferredFileOutputStreamTest { */ @ParameterizedTest(name = "initialBufferSize = {0}") @MethodSource("data") - public void testThresholdReached(int initialBufferSize) { + public void testThresholdReached(final int initialBufferSize) { final File testFile = new File("testThresholdReached.dat"); // Ensure that the test starts from a clean base. @@ -163,7 +163,7 @@ public class DeferredFileOutputStreamTest { */ @ParameterizedTest(name = "initialBufferSize = {0}") @MethodSource("data") - public void testWriteToSmall(int initialBufferSize) { + public void testWriteToSmall(final int initialBufferSize) { final File testFile = new File("testWriteToMem.dat"); final ByteArrayOutputStream baos = new ByteArrayOutputStream(initialBufferSize); // Ensure that the test starts from a clean base. @@ -200,7 +200,7 @@ public class DeferredFileOutputStreamTest { */ @ParameterizedTest(name = "initialBufferSize = {0}") @MethodSource("data") - public void testWriteToLarge(int initialBufferSize) { + public void testWriteToLarge(final int initialBufferSize) { final File testFile = new File("testWriteToFile.dat"); final ByteArrayOutputStream baos = new ByteArrayOutputStream(initialBufferSize); // Ensure that the test starts from a clean base. @@ -236,7 +236,7 @@ public class DeferredFileOutputStreamTest { */ @ParameterizedTest(name = "initialBufferSize = {0}") @MethodSource("data") - public void testTempFileBelowThreshold(int initialBufferSize) { + public void testTempFileBelowThreshold(final int initialBufferSize) { final String prefix = "commons-io-test"; final String suffix = ".out"; @@ -259,7 +259,7 @@ public class DeferredFileOutputStreamTest { */ @ParameterizedTest(name = "initialBufferSize = {0}") @MethodSource("data") - public void testTempFileAboveThreshold(int initialBufferSize) { + public void testTempFileAboveThreshold(final int initialBufferSize) { final String prefix = "commons-io-test"; final String suffix = ".out"; @@ -292,7 +292,7 @@ public class DeferredFileOutputStreamTest { */ @ParameterizedTest(name = "initialBufferSize = {0}") @MethodSource("data") - public void testTempFileAboveThresholdPrefixOnly(int initialBufferSize) { + public void testTempFileAboveThresholdPrefixOnly(final int initialBufferSize) { final String prefix = "commons-io-test"; final String suffix = null; diff --git a/src/test/java/org/apache/commons/io/output/FileWriterWithEncodingTest.java b/src/test/java/org/apache/commons/io/output/FileWriterWithEncodingTest.java index 5a1d2e5..50b6b40 100644 --- a/src/test/java/org/apache/commons/io/output/FileWriterWithEncodingTest.java +++ b/src/test/java/org/apache/commons/io/output/FileWriterWithEncodingTest.java @@ -174,7 +174,7 @@ public class FileWriterWithEncodingTest { assertThrows(IOException.class, () -> { try ( Writer writer = new FileWriterWithEncoding(file1, "BAD-ENCODE"); - ){ } + ){ } }); assertFalse(file1.exists()); } @@ -185,7 +185,7 @@ public class FileWriterWithEncodingTest { assertThrows(IOException.class, () -> { try ( Writer writer = new FileWriterWithEncoding(temporaryFolder, defaultEncoding); - ){ } + ){ } }); assertFalse(file1.exists()); } @@ -196,7 +196,7 @@ public class FileWriterWithEncodingTest { assertThrows(NullPointerException.class, () -> { try ( Writer writer = new FileWriterWithEncoding((File) null, defaultEncoding); - ){ } + ){ } }); assertFalse(file1.exists()); } @@ -207,7 +207,7 @@ public class FileWriterWithEncodingTest { assertThrows(NullPointerException.class, () -> { try ( Writer writer = new FileWriterWithEncoding((String) null, defaultEncoding); - ){ } + ){ } }); assertFalse(file1.exists()); }