Repository: commons-io Updated Branches: refs/heads/master 36940b641 -> 56f2a7589
Consistently use the final modifier with local variables. Project: http://git-wip-us.apache.org/repos/asf/commons-io/repo Commit: http://git-wip-us.apache.org/repos/asf/commons-io/commit/56f2a758 Tree: http://git-wip-us.apache.org/repos/asf/commons-io/tree/56f2a758 Diff: http://git-wip-us.apache.org/repos/asf/commons-io/diff/56f2a758 Branch: refs/heads/master Commit: 56f2a758983611adea7308e90ae9934c973efa72 Parents: 36940b6 Author: Gary Gregory <ggreg...@apache.org> Authored: Thu Sep 28 15:03:07 2017 -0600 Committer: Gary Gregory <ggreg...@apache.org> Committed: Thu Sep 28 15:03:07 2017 -0600 ---------------------------------------------------------------------- .../java/org/apache/commons/io/FileUtils.java | 8 ++--- .../org/apache/commons/io/FilenameUtils.java | 6 ++-- src/main/java/org/apache/commons/io/IOCase.java | 2 +- .../java/org/apache/commons/io/IOUtils.java | 4 +-- .../org/apache/commons/io/ThreadMonitor.java | 2 +- .../apache/commons/io/input/BOMInputStream.java | 2 +- .../io/input/ClassLoaderObjectInputStream.java | 2 +- .../commons/io/input/ObservableInputStream.java | 18 +++++----- .../org/apache/commons/io/input/Tailer.java | 2 +- .../io/input/UnixLineEndingInputStream.java | 4 +-- .../io/input/WindowsLineEndingInputStream.java | 4 +-- .../io/output/ByteArrayOutputStream.java | 2 +- .../commons/io/output/ChunkedOutputStream.java | 2 +- .../apache/commons/io/output/ChunkedWriter.java | 2 +- .../io/output/DeferredFileOutputStream.java | 2 +- .../commons/io/output/WriterOutputStream.java | 8 ++--- .../ValidatingObjectInputStream.java | 12 +++---- .../org/apache/commons/io/DemuxTestCase.java | 4 +-- .../io/DirectoryWalkerTestCaseJava4.java | 4 +-- .../commons/io/FileSystemUtilsTestCase.java | 4 +-- .../io/FileUtilsDirectoryContainsTestCase.java | 2 +- .../apache/commons/io/FileUtilsTestCase.java | 8 ++--- .../commons/io/FileUtilsWaitForTestCase.java | 4 +-- .../commons/io/FilenameUtilsTestCase.java | 14 ++++---- .../org/apache/commons/io/IOUtilsTestCase.java | 36 ++++++++++---------- .../io/filefilter/AndFileFilterTestCase.java | 2 +- .../ConditionalFileFilterAbstractTestCase.java | 2 +- .../io/filefilter/OrFileFilterTestCase.java | 2 +- .../commons/io/input/BOMInputStreamTest.java | 10 +++--- .../commons/io/input/BoundedReaderTest.java | 28 +++++++-------- .../io/input/CharSequenceInputStreamTest.java | 4 +-- .../input/ClassLoaderObjectInputStreamTest.java | 2 +- .../input/InfiniteCircularInputStreamTest.java | 14 ++++---- .../io/input/ObservableInputStreamTest.java | 2 +- .../org/apache/commons/io/input/TailerTest.java | 4 +-- .../io/input/UnixLineEndingInputStreamTest.java | 6 ++-- .../input/WindowsLineEndingInputStreamTest.java | 6 ++-- ...lStreamReaderUtilitiesCompatibilityTest.java | 2 +- .../io/output/AppendableOutputStreamTest.java | 2 +- .../output/ByteArrayOutputStreamTestCase.java | 12 +++---- .../io/output/ChunkedOutputStreamTest.java | 10 +++--- .../commons/io/output/ChunkedWriterTest.java | 10 +++--- .../io/output/FileWriterWithEncodingTest.java | 6 ++-- .../commons/io/output/ProxyWriterTest.java | 20 +++++------ .../io/output/ThresholdingOutputStreamTest.java | 2 +- .../io/output/WriterOutputStreamTest.java | 4 +-- .../commons/io/serialization/ClosingBase.java | 4 +-- .../RegexpClassNameMatcherTest.java | 6 ++-- .../ValidatingObjectInputStreamTest.java | 2 +- .../WildcardClassNameMatcherTest.java | 6 ++-- .../apache/commons/io/testtools/TestUtils.java | 4 +-- 51 files changed, 165 insertions(+), 165 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/commons-io/blob/56f2a758/src/main/java/org/apache/commons/io/FileUtils.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/commons/io/FileUtils.java b/src/main/java/org/apache/commons/io/FileUtils.java index 116e44b..00bf356 100644 --- a/src/main/java/org/apache/commons/io/FileUtils.java +++ b/src/main/java/org/apache/commons/io/FileUtils.java @@ -1595,7 +1595,7 @@ public class FileUtils { if (srcs == null) { throw new NullPointerException("Sources must not be null"); } - for (File src : srcs) { + for (final File src : srcs) { copyFileToDirectory(src, destDir); } } @@ -1766,11 +1766,11 @@ public class FileUtils { * @throws NullPointerException if the file is {@code null} */ public static boolean waitFor(final File file, final int seconds) { - long finishAt = System.currentTimeMillis() + (seconds * 1000L); + final long finishAt = System.currentTimeMillis() + (seconds * 1000L); boolean wasInterrupted = false; try { while (!file.exists()) { - long remaining = finishAt - System.currentTimeMillis(); + final long remaining = finishAt - System.currentTimeMillis(); if (remaining < 0){ return false; } @@ -1849,7 +1849,7 @@ public class FileUtils { */ public static byte[] readFileToByteArray(final File file) throws IOException { try (InputStream in = openInputStream(file)) { - long fileLength = file.length(); + final long fileLength = file.length(); // file.length() may return 0 for system-dependent entities, treat 0 as unknown length - see IO-453 return fileLength > 0 ? IOUtils.toByteArray(in, fileLength) : IOUtils.toByteArray(in); } http://git-wip-us.apache.org/repos/asf/commons-io/blob/56f2a758/src/main/java/org/apache/commons/io/FilenameUtils.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/commons/io/FilenameUtils.java b/src/main/java/org/apache/commons/io/FilenameUtils.java index 718a374..9cddebb 100644 --- a/src/main/java/org/apache/commons/io/FilenameUtils.java +++ b/src/main/java/org/apache/commons/io/FilenameUtils.java @@ -772,7 +772,7 @@ public class FilenameUtils { failIfNullBytePresent(filename + UNIX_SEPARATOR); return filename + UNIX_SEPARATOR; } - String path = filename.substring(0, len); + final String path = filename.substring(0, len); failIfNullBytePresent(path); return path; } @@ -852,7 +852,7 @@ public class FilenameUtils { if (prefix >= filename.length() || index < 0 || prefix >= endIndex) { return ""; } - String path = filename.substring(prefix, endIndex); + final String path = filename.substring(prefix, endIndex); failIfNullBytePresent(path); return path; } @@ -983,7 +983,7 @@ public class FilenameUtils { * @param path the path to check */ private static void failIfNullBytePresent(final String path) { - int len = path.length(); + final int len = path.length(); for (int i = 0; i < len; i++) { if (path.charAt(i) == 0) { throw new IllegalArgumentException("Null byte present in file/path name. There are no " + http://git-wip-us.apache.org/repos/asf/commons-io/blob/56f2a758/src/main/java/org/apache/commons/io/IOCase.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/commons/io/IOCase.java b/src/main/java/org/apache/commons/io/IOCase.java index d739c54..a0b2e32 100644 --- a/src/main/java/org/apache/commons/io/IOCase.java +++ b/src/main/java/org/apache/commons/io/IOCase.java @@ -77,7 +77,7 @@ public enum IOCase implements Serializable { * @throws IllegalArgumentException if the name is invalid */ public static IOCase forName(final String name) { - for (IOCase ioCase : IOCase.values()) + for (final IOCase ioCase : IOCase.values()) { if (ioCase.getName().equals(name)) { http://git-wip-us.apache.org/repos/asf/commons-io/blob/56f2a758/src/main/java/org/apache/commons/io/IOUtils.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/commons/io/IOUtils.java b/src/main/java/org/apache/commons/io/IOUtils.java index 8d558f0..8b2fe95 100644 --- a/src/main/java/org/apache/commons/io/IOUtils.java +++ b/src/main/java/org/apache/commons/io/IOUtils.java @@ -1706,7 +1706,7 @@ public class IOUtils { int bytes = data.length; int offset = 0; while (bytes > 0) { - int chunk = Math.min(bytes, DEFAULT_BUFFER_SIZE); + final int chunk = Math.min(bytes, DEFAULT_BUFFER_SIZE); output.write(data, offset, chunk); bytes -= chunk; offset += chunk; @@ -1813,7 +1813,7 @@ public class IOUtils { int bytes = data.length; int offset = 0; while (bytes > 0) { - int chunk = Math.min(bytes, DEFAULT_BUFFER_SIZE); + final int chunk = Math.min(bytes, DEFAULT_BUFFER_SIZE); output.write(data, offset, chunk); bytes -= chunk; offset += chunk; http://git-wip-us.apache.org/repos/asf/commons-io/blob/56f2a758/src/main/java/org/apache/commons/io/ThreadMonitor.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/commons/io/ThreadMonitor.java b/src/main/java/org/apache/commons/io/ThreadMonitor.java index 12ec610..57077e1 100644 --- a/src/main/java/org/apache/commons/io/ThreadMonitor.java +++ b/src/main/java/org/apache/commons/io/ThreadMonitor.java @@ -122,7 +122,7 @@ class ThreadMonitor implements Runnable { * @throws InterruptedException if interrupted */ private static void sleep(final long ms) throws InterruptedException { - long finishAt = System.currentTimeMillis() + ms; + final long finishAt = System.currentTimeMillis() + ms; long remaining = ms; do { Thread.sleep(remaining); http://git-wip-us.apache.org/repos/asf/commons-io/blob/56f2a758/src/main/java/org/apache/commons/io/input/BOMInputStream.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/commons/io/input/BOMInputStream.java b/src/main/java/org/apache/commons/io/input/BOMInputStream.java index 9e34547..a9bb0db 100644 --- a/src/main/java/org/apache/commons/io/input/BOMInputStream.java +++ b/src/main/java/org/apache/commons/io/input/BOMInputStream.java @@ -169,7 +169,7 @@ public class BOMInputStream extends ProxyInputStream { throw new IllegalArgumentException("No BOMs specified"); } this.include = include; - List<ByteOrderMark> list = Arrays.asList(boms); + final List<ByteOrderMark> list = Arrays.asList(boms); // Sort the BOMs to match the longest BOM first because some BOMs have the same starting two bytes. Collections.sort(list, ByteOrderMarkLengthComparator); this.boms = list; http://git-wip-us.apache.org/repos/asf/commons-io/blob/56f2a758/src/main/java/org/apache/commons/io/input/ClassLoaderObjectInputStream.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/commons/io/input/ClassLoaderObjectInputStream.java b/src/main/java/org/apache/commons/io/input/ClassLoaderObjectInputStream.java index 275d92c..7e4345c 100644 --- a/src/main/java/org/apache/commons/io/input/ClassLoaderObjectInputStream.java +++ b/src/main/java/org/apache/commons/io/input/ClassLoaderObjectInputStream.java @@ -66,7 +66,7 @@ public class ClassLoaderObjectInputStream extends ObjectInputStream { try { return Class.forName(objectStreamClass.getName(), false, classLoader); - } catch (ClassNotFoundException cnfe) { + } catch (final ClassNotFoundException cnfe) { // delegate to super class loader which can resolve primitives return super.resolveClass(objectStreamClass); } http://git-wip-us.apache.org/repos/asf/commons-io/blob/56f2a758/src/main/java/org/apache/commons/io/input/ObservableInputStream.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/commons/io/input/ObservableInputStream.java b/src/main/java/org/apache/commons/io/input/ObservableInputStream.java index 2e9c6d5..03e8292 100644 --- a/src/main/java/org/apache/commons/io/input/ObservableInputStream.java +++ b/src/main/java/org/apache/commons/io/input/ObservableInputStream.java @@ -116,7 +116,7 @@ public class ObservableInputStream extends ProxyInputStream { IOException ioe = null; try { result = super.read(); - } catch (IOException pException) { + } catch (final IOException pException) { ioe = pException; } if (ioe != null) { @@ -135,7 +135,7 @@ public class ObservableInputStream extends ProxyInputStream { IOException ioe = null; try { result = super.read(pBuffer); - } catch (IOException pException) { + } catch (final IOException pException) { ioe = pException; } if (ioe != null) { @@ -154,7 +154,7 @@ public class ObservableInputStream extends ProxyInputStream { IOException ioe = null; try { result = super.read(pBuffer, pOffset, pLength); - } catch (IOException pException) { + } catch (final IOException pException) { ioe = pException; } if (ioe != null) { @@ -176,7 +176,7 @@ public class ObservableInputStream extends ProxyInputStream { * passed down. */ protected void noteDataBytes(final byte[] pBuffer, final int pOffset, final int pLength) throws IOException { - for (Observer observer : getObservers()) { + for (final Observer observer : getObservers()) { observer.data(pBuffer, pOffset, pLength); } } @@ -186,7 +186,7 @@ public class ObservableInputStream extends ProxyInputStream { * passed down. */ protected void noteFinished() throws IOException { - for (Observer observer : getObservers()) { + for (final Observer observer : getObservers()) { observer.finished(); } } @@ -198,7 +198,7 @@ public class ObservableInputStream extends ProxyInputStream { * passed down. */ protected void noteDataByte(final int pDataByte) throws IOException { - for (Observer observer : getObservers()) { + for (final Observer observer : getObservers()) { observer.data(pDataByte); } } @@ -211,7 +211,7 @@ public class ObservableInputStream extends ProxyInputStream { * argument. */ protected void noteError(final IOException pException) throws IOException { - for (Observer observer : getObservers()) { + for (final Observer observer : getObservers()) { observer.error(pException); } } @@ -221,7 +221,7 @@ public class ObservableInputStream extends ProxyInputStream { * passed down. */ protected void noteClosed() throws IOException { - for (Observer observer : getObservers()) { + for (final Observer observer : getObservers()) { observer.closed(); } } @@ -238,7 +238,7 @@ public class ObservableInputStream extends ProxyInputStream { IOException ioe = null; try { super.close(); - } catch (IOException e) { + } catch (final IOException e) { ioe = e; } if (ioe == null) { http://git-wip-us.apache.org/repos/asf/commons-io/blob/56f2a758/src/main/java/org/apache/commons/io/input/Tailer.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/commons/io/input/Tailer.java b/src/main/java/org/apache/commons/io/input/Tailer.java index a15fbf2..0434e83 100644 --- a/src/main/java/org/apache/commons/io/input/Tailer.java +++ b/src/main/java/org/apache/commons/io/input/Tailer.java @@ -439,7 +439,7 @@ public class Tailer implements Runnable { // Finish scanning the old file and then we'll start with the new one try { readLines(save); - } catch (IOException ioe) { + } catch (final IOException ioe) { listener.handle(ioe); } position = 0; http://git-wip-us.apache.org/repos/asf/commons-io/blob/56f2a758/src/main/java/org/apache/commons/io/input/UnixLineEndingInputStream.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/commons/io/input/UnixLineEndingInputStream.java b/src/main/java/org/apache/commons/io/input/UnixLineEndingInputStream.java index 5c4c319..0fbd903 100644 --- a/src/main/java/org/apache/commons/io/input/UnixLineEndingInputStream.java +++ b/src/main/java/org/apache/commons/io/input/UnixLineEndingInputStream.java @@ -69,12 +69,12 @@ public class UnixLineEndingInputStream extends InputStream { */ @Override public int read() throws IOException { - boolean previousWasSlashR = slashRSeen; + final boolean previousWasSlashR = slashRSeen; if ( eofSeen ) { return eofGame(previousWasSlashR); } else { - int target = readWithUpdate(); + final int target = readWithUpdate(); if ( eofSeen ) { return eofGame(previousWasSlashR); } http://git-wip-us.apache.org/repos/asf/commons-io/blob/56f2a758/src/main/java/org/apache/commons/io/input/WindowsLineEndingInputStream.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/commons/io/input/WindowsLineEndingInputStream.java b/src/main/java/org/apache/commons/io/input/WindowsLineEndingInputStream.java index 907ecce..a153a53 100644 --- a/src/main/java/org/apache/commons/io/input/WindowsLineEndingInputStream.java +++ b/src/main/java/org/apache/commons/io/input/WindowsLineEndingInputStream.java @@ -76,8 +76,8 @@ public class WindowsLineEndingInputStream extends InputStream { injectSlashN = false; return '\n'; } else { - boolean prevWasSlashR = slashRSeen; - int target = readWithUpdate(); + final boolean prevWasSlashR = slashRSeen; + final int target = readWithUpdate(); if ( eofSeen ) { return eofGame(); } http://git-wip-us.apache.org/repos/asf/commons-io/blob/56f2a758/src/main/java/org/apache/commons/io/output/ByteArrayOutputStream.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/commons/io/output/ByteArrayOutputStream.java b/src/main/java/org/apache/commons/io/output/ByteArrayOutputStream.java index 58ec160..499aeee 100644 --- a/src/main/java/org/apache/commons/io/output/ByteArrayOutputStream.java +++ b/src/main/java/org/apache/commons/io/output/ByteArrayOutputStream.java @@ -240,7 +240,7 @@ public class ByteArrayOutputStream extends OutputStream { } else { //Throw away old buffers currentBuffer = null; - int size = buffers.get(0).length; + final int size = buffers.get(0).length; buffers.clear(); needNewBuffer(size); reuseBuffers = true; http://git-wip-us.apache.org/repos/asf/commons-io/blob/56f2a758/src/main/java/org/apache/commons/io/output/ChunkedOutputStream.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/commons/io/output/ChunkedOutputStream.java b/src/main/java/org/apache/commons/io/output/ChunkedOutputStream.java index c004303..394b84e 100644 --- a/src/main/java/org/apache/commons/io/output/ChunkedOutputStream.java +++ b/src/main/java/org/apache/commons/io/output/ChunkedOutputStream.java @@ -77,7 +77,7 @@ public class ChunkedOutputStream extends FilterOutputStream { int bytes = length; int dstOffset = srcOffset; while(bytes > 0) { - int chunk = Math.min(bytes, chunkSize); + final int chunk = Math.min(bytes, chunkSize); out.write(data, dstOffset, chunk); bytes -= chunk; dstOffset += chunk; http://git-wip-us.apache.org/repos/asf/commons-io/blob/56f2a758/src/main/java/org/apache/commons/io/output/ChunkedWriter.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/commons/io/output/ChunkedWriter.java b/src/main/java/org/apache/commons/io/output/ChunkedWriter.java index 1485178..7b9a16a 100644 --- a/src/main/java/org/apache/commons/io/output/ChunkedWriter.java +++ b/src/main/java/org/apache/commons/io/output/ChunkedWriter.java @@ -75,7 +75,7 @@ public class ChunkedWriter extends FilterWriter { int bytes = length; int dstOffset = srcOffset; while(bytes > 0) { - int chunk = Math.min(bytes, chunkSize); + final int chunk = Math.min(bytes, chunkSize); out.write(data, dstOffset, chunk); bytes -= chunk; dstOffset += chunk; http://git-wip-us.apache.org/repos/asf/commons-io/blob/56f2a758/src/main/java/org/apache/commons/io/output/DeferredFileOutputStream.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/commons/io/output/DeferredFileOutputStream.java b/src/main/java/org/apache/commons/io/output/DeferredFileOutputStream.java index bb3c246..12bc0a2 100644 --- a/src/main/java/org/apache/commons/io/output/DeferredFileOutputStream.java +++ b/src/main/java/org/apache/commons/io/output/DeferredFileOutputStream.java @@ -223,7 +223,7 @@ public class DeferredFileOutputStream final FileOutputStream fos = new FileOutputStream(outputFile); try { memoryOutputStream.writeTo(fos); - } catch (IOException e){ + } catch (final IOException e){ fos.close(); throw e; } http://git-wip-us.apache.org/repos/asf/commons-io/blob/56f2a758/src/main/java/org/apache/commons/io/output/WriterOutputStream.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/commons/io/output/WriterOutputStream.java b/src/main/java/org/apache/commons/io/output/WriterOutputStream.java index 67d1e5f..4b7110b 100644 --- a/src/main/java/org/apache/commons/io/output/WriterOutputStream.java +++ b/src/main/java/org/apache/commons/io/output/WriterOutputStream.java @@ -320,18 +320,18 @@ public class WriterOutputStream extends OutputStream { return; } final String TEST_STRING_2 = "v\u00e9s"; - byte[] bytes = TEST_STRING_2.getBytes(charset); + final byte[] bytes = TEST_STRING_2.getBytes(charset); final CharsetDecoder charsetDecoder2 = charset.newDecoder(); - ByteBuffer bb2 = ByteBuffer.allocate(16); - CharBuffer cb2 = CharBuffer.allocate(TEST_STRING_2.length()); + final ByteBuffer bb2 = ByteBuffer.allocate(16); + final CharBuffer cb2 = CharBuffer.allocate(TEST_STRING_2.length()); final int len = bytes.length; for (int i = 0; i < len; i++) { bb2.put(bytes[i]); bb2.flip(); try { charsetDecoder2.decode(bb2, cb2, i == (len - 1)); - } catch ( IllegalArgumentException e){ + } catch ( final IllegalArgumentException e){ throw new UnsupportedOperationException("UTF-16 requested when runninng on an IBM JDK with broken UTF-16 support. " + "Please find a JDK that supports UTF-16 if you intend to use UF-16 with WriterOutputStream"); } http://git-wip-us.apache.org/repos/asf/commons-io/blob/56f2a758/src/main/java/org/apache/commons/io/serialization/ValidatingObjectInputStream.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/commons/io/serialization/ValidatingObjectInputStream.java b/src/main/java/org/apache/commons/io/serialization/ValidatingObjectInputStream.java index 06e68ab..9a9b942 100644 --- a/src/main/java/org/apache/commons/io/serialization/ValidatingObjectInputStream.java +++ b/src/main/java/org/apache/commons/io/serialization/ValidatingObjectInputStream.java @@ -65,14 +65,14 @@ public class ValidatingObjectInputStream extends ObjectInputStream { */ private void validateClassName(final String name) throws InvalidClassException { // Reject has precedence over accept - for (ClassNameMatcher m : rejectMatchers) { + for (final ClassNameMatcher m : rejectMatchers) { if (m.matches(name)) { invalidClassNameFound(name); } } boolean ok = false; - for (ClassNameMatcher m : acceptMatchers) { + for (final ClassNameMatcher m : acceptMatchers) { if (m.matches(name)) { ok = true; break; @@ -109,7 +109,7 @@ public class ValidatingObjectInputStream extends ObjectInputStream { * @return this object */ public ValidatingObjectInputStream accept(final Class<?>... classes) { - for (Class<?> c : classes) { + for (final Class<?> c : classes) { acceptMatchers.add(new FullClassNameMatcher(c.getName())); } return this; @@ -123,7 +123,7 @@ public class ValidatingObjectInputStream extends ObjectInputStream { * @return this object */ public ValidatingObjectInputStream reject(final Class<?>... classes) { - for (Class<?> c : classes) { + for (final Class<?> c : classes) { rejectMatchers.add(new FullClassNameMatcher(c.getName())); } return this; @@ -138,7 +138,7 @@ public class ValidatingObjectInputStream extends ObjectInputStream { * @return this object */ public ValidatingObjectInputStream accept(final String... patterns) { - for (String pattern : patterns) { + for (final String pattern : patterns) { acceptMatchers.add(new WildcardClassNameMatcher(pattern)); } return this; @@ -153,7 +153,7 @@ public class ValidatingObjectInputStream extends ObjectInputStream { * @return this object */ public ValidatingObjectInputStream reject(final String... patterns) { - for (String pattern : patterns) { + for (final String pattern : patterns) { rejectMatchers.add(new WildcardClassNameMatcher(pattern)); } return this; http://git-wip-us.apache.org/repos/asf/commons-io/blob/56f2a758/src/test/java/org/apache/commons/io/DemuxTestCase.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/commons/io/DemuxTestCase.java b/src/test/java/org/apache/commons/io/DemuxTestCase.java index e8f3230..f0214dd 100644 --- a/src/test/java/org/apache/commons/io/DemuxTestCase.java +++ b/src/test/java/org/apache/commons/io/DemuxTestCase.java @@ -67,7 +67,7 @@ public class DemuxTestCase { private void doStart() throws Exception { - for (String name : m_threadMap.keySet()) { + for (final String name : m_threadMap.keySet()) { final Thread thread = m_threadMap.get(name); thread.start(); } @@ -75,7 +75,7 @@ public class DemuxTestCase { private void doJoin() throws Exception { - for (String name : m_threadMap.keySet()) { + for (final String name : m_threadMap.keySet()) { final Thread thread = m_threadMap.get(name); thread.join(); } http://git-wip-us.apache.org/repos/asf/commons-io/blob/56f2a758/src/test/java/org/apache/commons/io/DirectoryWalkerTestCaseJava4.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/commons/io/DirectoryWalkerTestCaseJava4.java b/src/test/java/org/apache/commons/io/DirectoryWalkerTestCaseJava4.java index 3e69729..e2dab3b 100644 --- a/src/test/java/org/apache/commons/io/DirectoryWalkerTestCaseJava4.java +++ b/src/test/java/org/apache/commons/io/DirectoryWalkerTestCaseJava4.java @@ -236,7 +236,7 @@ public class DirectoryWalkerTestCaseJava4 { */ private List directoriesOnly(final Collection<File> results) { final List list = new ArrayList(results.size()); - for (File file : results) { + for (final File file : results) { if (file.isDirectory()) { list.add(file); } @@ -249,7 +249,7 @@ public class DirectoryWalkerTestCaseJava4 { */ private List filesOnly(final Collection<File> results) { final List list = new ArrayList(results.size()); - for (File file : results) { + for (final File file : results) { if (file.isFile()) { list.add(file); } http://git-wip-us.apache.org/repos/asf/commons-io/blob/56f2a758/src/test/java/org/apache/commons/io/FileSystemUtilsTestCase.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/commons/io/FileSystemUtilsTestCase.java b/src/test/java/org/apache/commons/io/FileSystemUtilsTestCase.java index 31bb7dc..9baa50d 100644 --- a/src/test/java/org/apache/commons/io/FileSystemUtilsTestCase.java +++ b/src/test/java/org/apache/commons/io/FileSystemUtilsTestCase.java @@ -73,7 +73,7 @@ public class FileSystemUtilsTestCase { // more than 1% between the above two calls; // this also also small enough to verifiy freeSpaceKb uses // kibibytes (1024) instead of SI kilobytes (1000) - double acceptableDelta = kb * 0.01d; + final double acceptableDelta = kb * 0.01d; if (kilobyteBlock) { assertEquals(free, kb, acceptableDelta); } else { @@ -83,7 +83,7 @@ public class FileSystemUtilsTestCase { final long bytes = FileSystemUtils.freeSpace(""); final long kb = FileSystemUtils.freeSpaceKb(""); // Assume disk space does not fluctuate more than 1% - double acceptableDelta = kb * 0.01d; + final double acceptableDelta = kb * 0.01d; assertEquals((double) bytes / 1024, kb, acceptableDelta); } } http://git-wip-us.apache.org/repos/asf/commons-io/blob/56f2a758/src/test/java/org/apache/commons/io/FileUtilsDirectoryContainsTestCase.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/commons/io/FileUtilsDirectoryContainsTestCase.java b/src/test/java/org/apache/commons/io/FileUtilsDirectoryContainsTestCase.java index 4e4e88b..7ed9660 100644 --- a/src/test/java/org/apache/commons/io/FileUtilsDirectoryContainsTestCase.java +++ b/src/test/java/org/apache/commons/io/FileUtilsDirectoryContainsTestCase.java @@ -139,7 +139,7 @@ public class FileUtilsDirectoryContainsTestCase { @Test public void testIO466() throws IOException { - File fooFile = new File(directory1.getParent(), "directory1.txt"); + final File fooFile = new File(directory1.getParent(), "directory1.txt"); assertFalse(FileUtils.directoryContains(directory1, fooFile)); } http://git-wip-us.apache.org/repos/asf/commons-io/blob/56f2a758/src/test/java/org/apache/commons/io/FileUtilsTestCase.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/commons/io/FileUtilsTestCase.java b/src/test/java/org/apache/commons/io/FileUtilsTestCase.java index 200eeb3..7138491 100644 --- a/src/test/java/org/apache/commons/io/FileUtilsTestCase.java +++ b/src/test/java/org/apache/commons/io/FileUtilsTestCase.java @@ -1615,7 +1615,7 @@ public class FileUtilsTestCase { directory.mkdirs(); } - List<File> input = new ArrayList<>(); + final List<File> input = new ArrayList<>(); input.add(testFile1); input.add(testFile2); @@ -3084,12 +3084,12 @@ public class FileUtilsTestCase { // This test relies on FileUtils.copyFile using File.length to check the output size @Test public void testIncorrectOutputSize() throws Exception { - File inFile = new File("pom.xml"); - File outFile = new ShorterFile("target/pom.tmp"); // it will report a shorter file + final File inFile = new File("pom.xml"); + final File outFile = new ShorterFile("target/pom.tmp"); // it will report a shorter file try { FileUtils.copyFile(inFile, outFile); fail("Expected IOException"); - } catch (Exception e) { + } catch (final Exception e) { final String msg = e.toString(); assertTrue(msg, msg.contains("Failed to copy full contents")); } finally { http://git-wip-us.apache.org/repos/asf/commons-io/blob/56f2a758/src/test/java/org/apache/commons/io/FileUtilsWaitForTestCase.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/commons/io/FileUtilsWaitForTestCase.java b/src/test/java/org/apache/commons/io/FileUtilsWaitForTestCase.java index 3acab89..293298c 100644 --- a/src/test/java/org/apache/commons/io/FileUtilsWaitForTestCase.java +++ b/src/test/java/org/apache/commons/io/FileUtilsWaitForTestCase.java @@ -44,7 +44,7 @@ public class FileUtilsWaitForTestCase { public void testWaitForInterrupted() throws InterruptedException { final AtomicBoolean wasInterrupted = new AtomicBoolean(false); final CountDownLatch started = new CountDownLatch(1); - Runnable thread = new Runnable() { + final Runnable thread = new Runnable() { @Override public void run() { started.countDown(); @@ -52,7 +52,7 @@ public class FileUtilsWaitForTestCase { wasInterrupted.set( Thread.currentThread().isInterrupted()); } }; - Thread thread1 = new Thread(thread); + final Thread thread1 = new Thread(thread); thread1.start(); started.await(); thread1.interrupt(); http://git-wip-us.apache.org/repos/asf/commons-io/blob/56f2a758/src/test/java/org/apache/commons/io/FilenameUtilsTestCase.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/commons/io/FilenameUtilsTestCase.java b/src/test/java/org/apache/commons/io/FilenameUtilsTestCase.java index dfb9434..234c25e 100644 --- a/src/test/java/org/apache/commons/io/FilenameUtilsTestCase.java +++ b/src/test/java/org/apache/commons/io/FilenameUtilsTestCase.java @@ -250,12 +250,12 @@ public class FilenameUtilsTestCase { public void testNormalize_with_nullbytes() throws Exception { try { assertEquals("a" + SEP + "b" + SEP + "c.txt", FilenameUtils.normalize("a\\b/c\u0000.txt")); - } catch (IllegalArgumentException ignore) { + } catch (final IllegalArgumentException ignore) { } try { assertEquals("a" + SEP + "b" + SEP + "c.txt", FilenameUtils.normalize("\u0000a\\b/c.txt")); - } catch (IllegalArgumentException ignore) { + } catch (final IllegalArgumentException ignore) { } } @@ -625,7 +625,7 @@ public class FilenameUtilsTestCase { public void testGetPrefix_with_nullbyte() { try { assertEquals("~user\\", FilenameUtils.getPrefix("~u\u0000ser\\a\\b\\c.txt")); - } catch (IllegalArgumentException ignore) { + } catch (final IllegalArgumentException ignore) { } } @@ -714,7 +714,7 @@ public class FilenameUtilsTestCase { public void testGetPathNoEndSeparator_with_null_byte() { try { assertEquals("a/b", FilenameUtils.getPathNoEndSeparator("~user/a\u0000/b/c.txt")); - } catch (IllegalArgumentException ignore) { + } catch (final IllegalArgumentException ignore) { } } @@ -822,7 +822,7 @@ public class FilenameUtilsTestCase { public void testInjectionFailure() { try { assertEquals("c", FilenameUtils.getName("a\\b\\\u0000c")); - } catch (IllegalArgumentException ignore) { + } catch (final IllegalArgumentException ignore) { } } @@ -842,7 +842,7 @@ public class FilenameUtilsTestCase { public void testGetBaseName_with_nullByte() { try { assertEquals("file.txt", FilenameUtils.getBaseName("fil\u0000e.txt.bak")); - } catch (IllegalArgumentException ignore) { + } catch (final IllegalArgumentException ignore) { } } @@ -1001,7 +1001,7 @@ public class FilenameUtilsTestCase { try { FilenameUtils.isExtension("a.b\\fi\u0000le.txt", "TXT"); fail("Should throw IAE"); - } catch (IllegalArgumentException ignore) { + } catch (final IllegalArgumentException ignore) { } } http://git-wip-us.apache.org/repos/asf/commons-io/blob/56f2a758/src/test/java/org/apache/commons/io/IOUtilsTestCase.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/commons/io/IOUtilsTestCase.java b/src/test/java/org/apache/commons/io/IOUtilsTestCase.java index c5c34db..b5adc04 100644 --- a/src/test/java/org/apache/commons/io/IOUtilsTestCase.java +++ b/src/test/java/org/apache/commons/io/IOUtilsTestCase.java @@ -1214,7 +1214,7 @@ public class IOUtilsTestCase { try { IOUtils.resourceToString(null, StandardCharsets.UTF_8); fail(); - } catch (NullPointerException npe) { + } catch (final NullPointerException npe) { exceptionOccurred = true; assertNotNull(npe); } @@ -1228,7 +1228,7 @@ public class IOUtilsTestCase { try { IOUtils.resourceToString(null, StandardCharsets.UTF_8, ClassLoader.getSystemClassLoader()); fail(); - } catch (NullPointerException npe) { + } catch (final NullPointerException npe) { exceptionOccurred = true; assertNotNull(npe); } @@ -1286,7 +1286,7 @@ public class IOUtilsTestCase { try { IOUtils.resourceToByteArray(null); fail(); - } catch (NullPointerException npe) { + } catch (final NullPointerException npe) { exceptionOccurred = true; assertNotNull(npe); } @@ -1300,7 +1300,7 @@ public class IOUtilsTestCase { try { IOUtils.resourceToByteArray(null, ClassLoader.getSystemClassLoader()); fail(); - } catch (NullPointerException npe) { + } catch (final NullPointerException npe) { exceptionOccurred = true; assertNotNull(npe); } @@ -1350,7 +1350,7 @@ public class IOUtilsTestCase { try { IOUtils.resourceToURL(null); fail(); - } catch (NullPointerException npe) { + } catch (final NullPointerException npe) { exceptionOccurred = true; assertNotNull(npe); } @@ -1364,7 +1364,7 @@ public class IOUtilsTestCase { try { IOUtils.resourceToURL(null, ClassLoader.getSystemClassLoader()); fail(); - } catch (NullPointerException npe) { + } catch (final NullPointerException npe) { exceptionOccurred = true; assertNotNull(npe); } @@ -1376,31 +1376,31 @@ public class IOUtilsTestCase { try { IOUtils.buffer((InputStream) null); fail("Expected NullPointerException"); - } catch (NullPointerException npe) { + } catch (final NullPointerException npe) { // expected } try { IOUtils.buffer((OutputStream) null); fail("Expected NullPointerException"); - } catch (NullPointerException npe) { + } catch (final NullPointerException npe) { // expected } try { IOUtils.buffer((Reader) null); fail("Expected NullPointerException"); - } catch (NullPointerException npe) { + } catch (final NullPointerException npe) { // expected } try { IOUtils.buffer((Writer) null); fail("Expected NullPointerException"); - } catch (NullPointerException npe) { + } catch (final NullPointerException npe) { // expected } } @Test public void testAsBufferedInputStream() { - InputStream is = new InputStream() { + final InputStream is = new InputStream() { @Override public int read() throws IOException { return 0; @@ -1412,7 +1412,7 @@ public class IOUtilsTestCase { } @Test public void testAsBufferedInputStreamWithBufferSize() { - InputStream is = new InputStream() { + final InputStream is = new InputStream() { @Override public int read() throws IOException { return 0; @@ -1425,7 +1425,7 @@ public class IOUtilsTestCase { } @Test public void testAsBufferedOutputStream() { - OutputStream is = new OutputStream() { + final OutputStream is = new OutputStream() { @Override public void write(final int b) throws IOException { } }; @@ -1435,7 +1435,7 @@ public class IOUtilsTestCase { } @Test public void testAsBufferedOutputStreamWithBufferSize() { - OutputStream os = new OutputStream() { + final OutputStream os = new OutputStream() { @Override public void write(final int b) throws IOException { } }; @@ -1446,7 +1446,7 @@ public class IOUtilsTestCase { } @Test public void testAsBufferedReader() { - Reader is = new Reader() { + final Reader is = new Reader() { @Override public int read(final char[] cbuf, final int off, final int len) throws IOException { return 0; @@ -1460,7 +1460,7 @@ public class IOUtilsTestCase { } @Test public void testAsBufferedReaderWithBufferSize() { - Reader r = new Reader() { + final Reader r = new Reader() { @Override public int read(final char[] cbuf, final int off, final int len) throws IOException { return 0; @@ -1475,7 +1475,7 @@ public class IOUtilsTestCase { } @Test public void testAsBufferedWriter() { - Writer is = new Writer() { + final Writer is = new Writer() { @Override public void write(final int b) throws IOException { } @@ -1495,7 +1495,7 @@ public class IOUtilsTestCase { @Test public void testAsBufferedWriterWithBufferSize() { - Writer w = new Writer() { + final Writer w = new Writer() { @Override public void write(final int b) throws IOException { } http://git-wip-us.apache.org/repos/asf/commons-io/blob/56f2a758/src/test/java/org/apache/commons/io/filefilter/AndFileFilterTestCase.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/commons/io/filefilter/AndFileFilterTestCase.java b/src/test/java/org/apache/commons/io/filefilter/AndFileFilterTestCase.java index 17d4bbc..1e69ab1 100644 --- a/src/test/java/org/apache/commons/io/filefilter/AndFileFilterTestCase.java +++ b/src/test/java/org/apache/commons/io/filefilter/AndFileFilterTestCase.java @@ -35,7 +35,7 @@ public class AndFileFilterTestCase extends ConditionalFileFilterAbstractTestCase @Override protected IOFileFilter buildFilterUsingAdd(final List<IOFileFilter> filters) { final AndFileFilter filter = new AndFileFilter(); - for (IOFileFilter filter1 : filters) { + for (final IOFileFilter filter1 : filters) { filter.addFileFilter(filter1); } return filter; http://git-wip-us.apache.org/repos/asf/commons-io/blob/56f2a758/src/test/java/org/apache/commons/io/filefilter/ConditionalFileFilterAbstractTestCase.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/commons/io/filefilter/ConditionalFileFilterAbstractTestCase.java b/src/test/java/org/apache/commons/io/filefilter/ConditionalFileFilterAbstractTestCase.java index 0a8e07f..2c320fe 100644 --- a/src/test/java/org/apache/commons/io/filefilter/ConditionalFileFilterAbstractTestCase.java +++ b/src/test/java/org/apache/commons/io/filefilter/ConditionalFileFilterAbstractTestCase.java @@ -78,7 +78,7 @@ public abstract class ConditionalFileFilterAbstractTestCase extends IOFileFilter filters.add(new TesterTrueFileFilter()); filters.add(new TesterTrueFileFilter()); filters.add(new TesterTrueFileFilter()); - for (TesterTrueFileFilter filter : filters) { + for (final TesterTrueFileFilter filter : filters) { fileFilter.removeFileFilter(filter); assertTrue("file filter removed", !fileFilter.getFileFilters().contains(filter)); } http://git-wip-us.apache.org/repos/asf/commons-io/blob/56f2a758/src/test/java/org/apache/commons/io/filefilter/OrFileFilterTestCase.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/commons/io/filefilter/OrFileFilterTestCase.java b/src/test/java/org/apache/commons/io/filefilter/OrFileFilterTestCase.java index 15414aa..a3b9c30 100644 --- a/src/test/java/org/apache/commons/io/filefilter/OrFileFilterTestCase.java +++ b/src/test/java/org/apache/commons/io/filefilter/OrFileFilterTestCase.java @@ -35,7 +35,7 @@ public class OrFileFilterTestCase extends ConditionalFileFilterAbstractTestCase @Override protected IOFileFilter buildFilterUsingAdd(final List<IOFileFilter> filters) { final OrFileFilter filter = new OrFileFilter(); - for (IOFileFilter filter1 : filters) { + for (final IOFileFilter filter1 : filters) { filter.addFileFilter(filter1); } return filter; http://git-wip-us.apache.org/repos/asf/commons-io/blob/56f2a758/src/test/java/org/apache/commons/io/input/BOMInputStreamTest.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/commons/io/input/BOMInputStreamTest.java b/src/test/java/org/apache/commons/io/input/BOMInputStreamTest.java index 43b4970..20b7e0d 100644 --- a/src/test/java/org/apache/commons/io/input/BOMInputStreamTest.java +++ b/src/test/java/org/apache/commons/io/input/BOMInputStreamTest.java @@ -698,8 +698,8 @@ public class BOMInputStreamTest { @Test public void skipReturnValueWithBom() throws IOException { - byte[] baseData = new byte[]{(byte) 0x31, (byte) 0x32, (byte) 0x33}; - BOMInputStream is1 = new BOMInputStream(createUtf8DataStream(baseData, true)); + final byte[] baseData = new byte[]{(byte) 0x31, (byte) 0x32, (byte) 0x33}; + final BOMInputStream is1 = new BOMInputStream(createUtf8DataStream(baseData, true)); assertEquals(2, is1.skip(2)); assertEquals((byte) 0x33, is1.read()); is1.close(); @@ -707,8 +707,8 @@ public class BOMInputStreamTest { @Test public void skipReturnValueWithoutBom() throws IOException { - byte[] baseData = new byte[]{(byte) 0x31, (byte) 0x32, (byte) 0x33}; - BOMInputStream is2 = new BOMInputStream(createUtf8DataStream(baseData, false)); + final byte[] baseData = new byte[]{(byte) 0x31, (byte) 0x32, (byte) 0x33}; + final BOMInputStream is2 = new BOMInputStream(createUtf8DataStream(baseData, false)); assertEquals(2, is2.skip(2)); // IO-428 assertEquals((byte) 0x33, is2.read()); is2.close(); @@ -763,7 +763,7 @@ public class BOMInputStreamTest { final InputSource is = new InputSource(new ByteArrayInputStream(data)); is.setEncoding(charSetName); documentBuilder.parse(is); - } catch (SAXParseException e) { + } catch (final SAXParseException e) { if (e.getMessage().contains(charSetName)) { return false; } http://git-wip-us.apache.org/repos/asf/commons-io/blob/56f2a758/src/test/java/org/apache/commons/io/input/BoundedReaderTest.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/commons/io/input/BoundedReaderTest.java b/src/test/java/org/apache/commons/io/input/BoundedReaderTest.java index 4ad3b6d..5401168 100644 --- a/src/test/java/org/apache/commons/io/input/BoundedReaderTest.java +++ b/src/test/java/org/apache/commons/io/input/BoundedReaderTest.java @@ -37,7 +37,7 @@ public class BoundedReaderTest @Test public void readTillEnd() throws IOException { - BoundedReader mr = new BoundedReader( sr, 3 ); + final BoundedReader mr = new BoundedReader( sr, 3 ); mr.read(); mr.read(); mr.read(); @@ -47,7 +47,7 @@ public class BoundedReaderTest @Test public void shortReader() throws IOException { - BoundedReader mr = new BoundedReader( shortReader, 3 ); + final BoundedReader mr = new BoundedReader( shortReader, 3 ); mr.read(); mr.read(); assertEquals( -1, mr.read() ); @@ -56,8 +56,8 @@ public class BoundedReaderTest @Test public void readMulti() throws IOException { - BoundedReader mr = new BoundedReader( sr, 3 ); - char[] cbuf = new char[4]; + final BoundedReader mr = new BoundedReader( sr, 3 ); + final char[] cbuf = new char[4]; for ( int i = 0; i < cbuf.length; i++ ) { cbuf[i] = 'X'; @@ -73,8 +73,8 @@ public class BoundedReaderTest @Test public void readMultiWithOffset() throws IOException { - BoundedReader mr = new BoundedReader( sr, 3 ); - char[] cbuf = new char[4]; + final BoundedReader mr = new BoundedReader( sr, 3 ); + final char[] cbuf = new char[4]; for ( int i = 0; i < cbuf.length; i++ ) { cbuf[i] = 'X'; } @@ -89,7 +89,7 @@ public class BoundedReaderTest @Test public void markReset() throws IOException { - BoundedReader mr = new BoundedReader( sr, 3 ); + final BoundedReader mr = new BoundedReader( sr, 3 ); mr.mark( 3 ); mr.read(); mr.read(); @@ -105,7 +105,7 @@ public class BoundedReaderTest @Test public void markResetWithMarkOutsideBoundedReaderMax() throws IOException { - BoundedReader mr = new BoundedReader( sr, 3 ); + final BoundedReader mr = new BoundedReader( sr, 3 ); mr.mark( 4 ); mr.read(); mr.read(); @@ -116,7 +116,7 @@ public class BoundedReaderTest @Test public void markResetWithMarkOutsideBoundedReaderMaxAndInitialOffset() throws IOException { - BoundedReader mr = new BoundedReader( sr, 3 ); + final BoundedReader mr = new BoundedReader( sr, 3 ); mr.read(); mr.mark( 3 ); mr.read(); @@ -127,7 +127,7 @@ public class BoundedReaderTest @Test public void markResetFromOffset1() throws IOException { - BoundedReader mr = new BoundedReader( sr, 3 ); + final BoundedReader mr = new BoundedReader( sr, 3 ); mr.mark( 3 ); mr.read(); mr.read(); @@ -142,7 +142,7 @@ public class BoundedReaderTest @Test public void markResetMarkMore() throws IOException { - BoundedReader mr = new BoundedReader( sr, 3 ); + final BoundedReader mr = new BoundedReader( sr, 3 ); mr.mark( 4 ); mr.read(); mr.read(); @@ -157,7 +157,7 @@ public class BoundedReaderTest @Test public void skipTest() throws IOException { - BoundedReader mr = new BoundedReader( sr, 3 ); + final BoundedReader mr = new BoundedReader( sr, 3 ); mr.skip( 2 ); mr.read(); assertEquals( -1, mr.read() ); @@ -177,14 +177,14 @@ public class BoundedReaderTest } }; - BoundedReader mr = new BoundedReader( sr, 3 ); + final BoundedReader mr = new BoundedReader( sr, 3 ); mr.close(); assertTrue( closed.get() ); } @Test(timeout = 5000) public void testReadBytesEOF() throws IOException { - BoundedReader mr = new BoundedReader( sr, 3 ); + final BoundedReader mr = new BoundedReader( sr, 3 ); try ( BufferedReader br = new BufferedReader( mr ) ) { br.readLine(); br.readLine(); http://git-wip-us.apache.org/repos/asf/commons-io/blob/56f2a758/src/test/java/org/apache/commons/io/input/CharSequenceInputStreamTest.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/commons/io/input/CharSequenceInputStreamTest.java b/src/test/java/org/apache/commons/io/input/CharSequenceInputStreamTest.java index a66d37c..d77e42f 100644 --- a/src/test/java/org/apache/commons/io/input/CharSequenceInputStreamTest.java +++ b/src/test/java/org/apache/commons/io/input/CharSequenceInputStreamTest.java @@ -356,7 +356,7 @@ public class CharSequenceInputStreamTest { } private int checkAvail(final InputStream is, final int min) throws Exception { - int available = is.available(); + final int available = is.available(); assertTrue("avail should be >= " + min + ", but was " + available, available >= min); return available; } @@ -403,7 +403,7 @@ public class CharSequenceInputStreamTest { testAvailableSkip(csName); testAvailableRead(csName); } - } catch (UnsupportedOperationException e){ + } catch (final UnsupportedOperationException e){ fail("Operation not supported for " + csName); } } http://git-wip-us.apache.org/repos/asf/commons-io/blob/56f2a758/src/test/java/org/apache/commons/io/input/ClassLoaderObjectInputStreamTest.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/commons/io/input/ClassLoaderObjectInputStreamTest.java b/src/test/java/org/apache/commons/io/input/ClassLoaderObjectInputStreamTest.java index 27fd445..191b4e0 100644 --- a/src/test/java/org/apache/commons/io/input/ClassLoaderObjectInputStreamTest.java +++ b/src/test/java/org/apache/commons/io/input/ClassLoaderObjectInputStreamTest.java @@ -113,7 +113,7 @@ public class ClassLoaderObjectInputStreamTest { @Override public boolean equals(final Object other) { if (other instanceof Test) { - Test tother = (Test) other; + final Test tother = (Test) other; return (this.i == tother.i) & (this.e == tother.e) & equalObject(tother.o); http://git-wip-us.apache.org/repos/asf/commons-io/blob/56f2a758/src/test/java/org/apache/commons/io/input/InfiniteCircularInputStreamTest.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/commons/io/input/InfiniteCircularInputStreamTest.java b/src/test/java/org/apache/commons/io/input/InfiniteCircularInputStreamTest.java index 7468393..cd5828b 100644 --- a/src/test/java/org/apache/commons/io/input/InfiniteCircularInputStreamTest.java +++ b/src/test/java/org/apache/commons/io/input/InfiniteCircularInputStreamTest.java @@ -27,31 +27,31 @@ public class InfiniteCircularInputStreamTest { @Test public void should_cycle_bytes() throws IOException { - byte[] input = new byte[] { 1, 2 }; - byte[] expected = new byte[] { 1, 2, 1, 2, 1 }; + final byte[] input = new byte[] { 1, 2 }; + final byte[] expected = new byte[] { 1, 2, 1, 2, 1 }; assertStreamOutput(input, expected); } @Test public void should_handle_whole_range_of_bytes() throws IOException { - int size = Byte.MAX_VALUE - Byte.MIN_VALUE + 1; - byte[] contentToCycle = new byte[size]; + final int size = Byte.MAX_VALUE - Byte.MIN_VALUE + 1; + final byte[] contentToCycle = new byte[size]; byte value = Byte.MIN_VALUE; for (int i = 0; i < contentToCycle.length; i++) { contentToCycle[i] = value++; } - byte[] expectedOutput = Arrays.copyOf(contentToCycle, size); + final byte[] expectedOutput = Arrays.copyOf(contentToCycle, size); assertStreamOutput(contentToCycle, expectedOutput); } private void assertStreamOutput(final byte[] toCycle, final byte[] expected) throws IOException { - byte[] actual = new byte[expected.length]; + final byte[] actual = new byte[expected.length]; try (InputStream infStream = new InfiniteCircularInputStream(toCycle)) { - int actualReadBytes = infStream.read(actual); + final int actualReadBytes = infStream.read(actual); Assert.assertArrayEquals(expected, actual); Assert.assertEquals(expected.length, actualReadBytes); http://git-wip-us.apache.org/repos/asf/commons-io/blob/56f2a758/src/test/java/org/apache/commons/io/input/ObservableInputStreamTest.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/commons/io/input/ObservableInputStreamTest.java b/src/test/java/org/apache/commons/io/input/ObservableInputStreamTest.java index d75ee46..007ca99 100644 --- a/src/test/java/org/apache/commons/io/input/ObservableInputStreamTest.java +++ b/src/test/java/org/apache/commons/io/input/ObservableInputStreamTest.java @@ -98,7 +98,7 @@ public class ObservableInputStreamTest { @Test public void testDataBytesCalled() throws Exception { final byte[] buffer = MessageDigestCalculatingInputStreamTest.generateRandomByteStream(4096); - ByteArrayInputStream bais = new ByteArrayInputStream(buffer); + final ByteArrayInputStream bais = new ByteArrayInputStream(buffer); final ObservableInputStream ois = new ObservableInputStream(bais); final LastBytesKeepingObserver lko = new LastBytesKeepingObserver(); final byte[] readBuffer = new byte[23]; http://git-wip-us.apache.org/repos/asf/commons-io/blob/56f2a758/src/test/java/org/apache/commons/io/input/TailerTest.java ---------------------------------------------------------------------- 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 13ac187..66b5c68 100644 --- a/src/test/java/org/apache/commons/io/input/TailerTest.java +++ b/src/test/java/org/apache/commons/io/input/TailerTest.java @@ -143,7 +143,7 @@ public class TailerTest { try (Writer out = new OutputStreamWriter(new FileOutputStream(file), charsetUTF8); BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(origin), charsetUTF8))) { - List<String> lines = new ArrayList<>(); + final List<String> lines = new ArrayList<>(); String line; while((line = reader.readLine()) != null){ out.write(line); @@ -154,7 +154,7 @@ public class TailerTest { final long testDelayMillis = delay * 10; TestUtils.sleep(testDelayMillis); - List<String> tailerlines = listener.getLines(); + final List<String> tailerlines = listener.getLines(); assertEquals("line count",lines.size(),tailerlines.size()); for(int i = 0,len = lines.size();i<len;i++){ final String expected = lines.get(i); http://git-wip-us.apache.org/repos/asf/commons-io/blob/56f2a758/src/test/java/org/apache/commons/io/input/UnixLineEndingInputStreamTest.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/commons/io/input/UnixLineEndingInputStreamTest.java b/src/test/java/org/apache/commons/io/input/UnixLineEndingInputStreamTest.java index 2f5020a..4809d5b 100644 --- a/src/test/java/org/apache/commons/io/input/UnixLineEndingInputStreamTest.java +++ b/src/test/java/org/apache/commons/io/input/UnixLineEndingInputStreamTest.java @@ -77,9 +77,9 @@ public class UnixLineEndingInputStreamTest } private String roundtrip( final String msg, final boolean ensure ) throws IOException { - ByteArrayInputStream baos = new ByteArrayInputStream( msg.getBytes( "UTF-8" ) ); - UnixLineEndingInputStream lf = new UnixLineEndingInputStream( baos, ensure ); - byte[] buf = new byte[100]; + final ByteArrayInputStream baos = new ByteArrayInputStream( msg.getBytes( "UTF-8" ) ); + final UnixLineEndingInputStream lf = new UnixLineEndingInputStream( baos, ensure ); + final byte[] buf = new byte[100]; final int read = lf.read( buf ); lf.close(); return new String( buf, 0, read, "UTF-8" ); http://git-wip-us.apache.org/repos/asf/commons-io/blob/56f2a758/src/test/java/org/apache/commons/io/input/WindowsLineEndingInputStreamTest.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/commons/io/input/WindowsLineEndingInputStreamTest.java b/src/test/java/org/apache/commons/io/input/WindowsLineEndingInputStreamTest.java index fc01bf8..28626c5 100644 --- a/src/test/java/org/apache/commons/io/input/WindowsLineEndingInputStreamTest.java +++ b/src/test/java/org/apache/commons/io/input/WindowsLineEndingInputStreamTest.java @@ -67,9 +67,9 @@ public class WindowsLineEndingInputStreamTest { } private String roundtrip( final String msg, final boolean ensure ) throws IOException { - ByteArrayInputStream baos = new ByteArrayInputStream( msg.getBytes( "UTF-8" ) ); - WindowsLineEndingInputStream lf = new WindowsLineEndingInputStream( baos, ensure ); - byte[] buf = new byte[100]; + final ByteArrayInputStream baos = new ByteArrayInputStream( msg.getBytes( "UTF-8" ) ); + final WindowsLineEndingInputStream lf = new WindowsLineEndingInputStream( baos, ensure ); + final byte[] buf = new byte[100]; final int read = lf.read( buf ); lf.close(); return new String( buf, 0, read, "UTF-8" ); http://git-wip-us.apache.org/repos/asf/commons-io/blob/56f2a758/src/test/java/org/apache/commons/io/input/compatibility/XmlStreamReaderUtilitiesCompatibilityTest.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/commons/io/input/compatibility/XmlStreamReaderUtilitiesCompatibilityTest.java b/src/test/java/org/apache/commons/io/input/compatibility/XmlStreamReaderUtilitiesCompatibilityTest.java index 63c7b16..af2a8f7 100644 --- a/src/test/java/org/apache/commons/io/input/compatibility/XmlStreamReaderUtilitiesCompatibilityTest.java +++ b/src/test/java/org/apache/commons/io/input/compatibility/XmlStreamReaderUtilitiesCompatibilityTest.java @@ -38,7 +38,7 @@ public class XmlStreamReaderUtilitiesCompatibilityTest extends XmlStreamReaderUt protected String calculateHttpEncoding(final String httpContentType, final String bomEnc, final String xmlGuessEnc, final String xmlEnc, final boolean lenient, final String defaultEncoding) throws IOException { final MockXmlStreamReader mock = new MockXmlStreamReader(defaultEncoding); - String enc = mock.calculateHttpEncoding( + final String enc = mock.calculateHttpEncoding( XmlStreamReader.getContentTypeMime(httpContentType), XmlStreamReader.getContentTypeEncoding(httpContentType), bomEnc, xmlGuessEnc, xmlEnc, null, lenient); http://git-wip-us.apache.org/repos/asf/commons-io/blob/56f2a758/src/test/java/org/apache/commons/io/output/AppendableOutputStreamTest.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/commons/io/output/AppendableOutputStreamTest.java b/src/test/java/org/apache/commons/io/output/AppendableOutputStreamTest.java index 6ea664f..fe55e2e 100644 --- a/src/test/java/org/apache/commons/io/output/AppendableOutputStreamTest.java +++ b/src/test/java/org/apache/commons/io/output/AppendableOutputStreamTest.java @@ -36,7 +36,7 @@ public class AppendableOutputStreamTest { @Test public void testWriteStringBuilder() throws Exception { - String testData = "ABCD"; + final String testData = "ABCD"; out.write(testData.getBytes()); http://git-wip-us.apache.org/repos/asf/commons-io/blob/56f2a758/src/test/java/org/apache/commons/io/output/ByteArrayOutputStreamTestCase.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/commons/io/output/ByteArrayOutputStreamTestCase.java b/src/test/java/org/apache/commons/io/output/ByteArrayOutputStreamTestCase.java index b2772d7..ca1701d 100644 --- a/src/test/java/org/apache/commons/io/output/ByteArrayOutputStreamTestCase.java +++ b/src/test/java/org/apache/commons/io/output/ByteArrayOutputStreamTestCase.java @@ -97,8 +97,8 @@ public class ByteArrayOutputStreamTestCase { @Test public void testToInputStream() throws IOException { - ByteArrayOutputStream baout = new ByteArrayOutputStream(); - java.io.ByteArrayOutputStream ref = new java.io.ByteArrayOutputStream(); + final ByteArrayOutputStream baout = new ByteArrayOutputStream(); + final java.io.ByteArrayOutputStream ref = new java.io.ByteArrayOutputStream(); //Write 8224 bytes writeData(baout, ref, 32); @@ -107,7 +107,7 @@ public class ByteArrayOutputStreamTestCase { } //Get data before more writes - InputStream in = baout.toInputStream(); + final InputStream in = baout.toInputStream(); byte refData[] = ref.toByteArray(); //Write some more data @@ -130,8 +130,8 @@ public class ByteArrayOutputStreamTestCase { @Test public void testToInputStreamWithReset() throws IOException { //Make sure reset() do not destroy InputStream returned from toInputStream() - ByteArrayOutputStream baout = new ByteArrayOutputStream(); - java.io.ByteArrayOutputStream ref = new java.io.ByteArrayOutputStream(); + final ByteArrayOutputStream baout = new ByteArrayOutputStream(); + final java.io.ByteArrayOutputStream ref = new java.io.ByteArrayOutputStream(); //Write 8224 bytes writeData(baout, ref, 32); @@ -140,7 +140,7 @@ public class ByteArrayOutputStreamTestCase { } //Get data before reset - InputStream in = baout.toInputStream(); + final InputStream in = baout.toInputStream(); byte refData[] = ref.toByteArray(); //Reset and write some new data http://git-wip-us.apache.org/repos/asf/commons-io/blob/56f2a758/src/test/java/org/apache/commons/io/output/ChunkedOutputStreamTest.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/commons/io/output/ChunkedOutputStreamTest.java b/src/test/java/org/apache/commons/io/output/ChunkedOutputStreamTest.java index 2eb3865..5a7ab94 100644 --- a/src/test/java/org/apache/commons/io/output/ChunkedOutputStreamTest.java +++ b/src/test/java/org/apache/commons/io/output/ChunkedOutputStreamTest.java @@ -31,8 +31,8 @@ public class ChunkedOutputStreamTest { @Test public void write_four_chunks() throws Exception { final AtomicInteger numWrites = new AtomicInteger(); - ByteArrayOutputStream baos = getByteArrayOutputStream(numWrites); - ChunkedOutputStream chunked = new ChunkedOutputStream(baos, 10); + final ByteArrayOutputStream baos = getByteArrayOutputStream(numWrites); + final ChunkedOutputStream chunked = new ChunkedOutputStream(baos, 10); chunked.write("0123456789012345678901234567891".getBytes()); assertEquals(4, numWrites.get()); chunked.close(); @@ -40,15 +40,15 @@ public class ChunkedOutputStreamTest { @Test(expected = IllegalArgumentException.class) public void negative_chunksize_not_permitted() throws Exception{ - ChunkedOutputStream chunked = new ChunkedOutputStream(new ByteArrayOutputStream(), 0); + final ChunkedOutputStream chunked = new ChunkedOutputStream(new ByteArrayOutputStream(), 0); chunked.close(); } @Test public void defaultConstructor() throws IOException { final AtomicInteger numWrites = new AtomicInteger(); - ByteArrayOutputStream baos = getByteArrayOutputStream(numWrites); - ChunkedOutputStream chunked = new ChunkedOutputStream(baos); + final ByteArrayOutputStream baos = getByteArrayOutputStream(numWrites); + final ChunkedOutputStream chunked = new ChunkedOutputStream(baos); chunked.write(new byte[1024 * 4 + 1]); assertEquals(2, numWrites.get()); chunked.close(); http://git-wip-us.apache.org/repos/asf/commons-io/blob/56f2a758/src/test/java/org/apache/commons/io/output/ChunkedWriterTest.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/commons/io/output/ChunkedWriterTest.java b/src/test/java/org/apache/commons/io/output/ChunkedWriterTest.java index cb937eb..426b142 100644 --- a/src/test/java/org/apache/commons/io/output/ChunkedWriterTest.java +++ b/src/test/java/org/apache/commons/io/output/ChunkedWriterTest.java @@ -28,9 +28,9 @@ public class ChunkedWriterTest { @Test public void write_four_chunks() throws Exception { final AtomicInteger numWrites = new AtomicInteger(); - OutputStreamWriter osw = getOutputStreamWriter(numWrites); + final OutputStreamWriter osw = getOutputStreamWriter(numWrites); - ChunkedWriter chunked = new ChunkedWriter(osw, 10); + final ChunkedWriter chunked = new ChunkedWriter(osw, 10); chunked.write("0123456789012345678901234567891".toCharArray()); chunked.flush(); assertEquals(4, numWrites.get()); @@ -40,9 +40,9 @@ public class ChunkedWriterTest { @Test public void write_two_chunks_default_constructor() throws Exception { final AtomicInteger numWrites = new AtomicInteger(); - OutputStreamWriter osw = getOutputStreamWriter(numWrites); + final OutputStreamWriter osw = getOutputStreamWriter(numWrites); - ChunkedWriter chunked = new ChunkedWriter(osw); + final ChunkedWriter chunked = new ChunkedWriter(osw); chunked.write(new char[1024 * 4 + 1]); chunked.flush(); assertEquals(2, numWrites.get()); @@ -50,7 +50,7 @@ public class ChunkedWriterTest { } private OutputStreamWriter getOutputStreamWriter(final AtomicInteger numWrites) { - ByteArrayOutputStream baos = new ByteArrayOutputStream(); + final ByteArrayOutputStream baos = new ByteArrayOutputStream(); return new OutputStreamWriter(baos) { @Override public void write(final char[] cbuf, final int off, final int len) throws IOException { http://git-wip-us.apache.org/repos/asf/commons-io/blob/56f2a758/src/test/java/org/apache/commons/io/output/FileWriterWithEncodingTest.java ---------------------------------------------------------------------- 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 54c00f7..6ab2da6 100644 --- a/src/test/java/org/apache/commons/io/output/FileWriterWithEncodingTest.java +++ b/src/test/java/org/apache/commons/io/output/FileWriterWithEncodingTest.java @@ -94,13 +94,13 @@ public class FileWriterWithEncodingTest { @Test public void sameEncoding_CharsetEncoder_constructor() throws Exception { - CharsetEncoder enc = Charset.defaultCharset().newEncoder(); + final CharsetEncoder enc = Charset.defaultCharset().newEncoder(); succesfulRun(new FileWriterWithEncoding(file2, enc)); } @Test public void sameEncoding_string_CharsetEncoder_constructor() throws Exception { - CharsetEncoder enc = Charset.defaultCharset().newEncoder(); + final CharsetEncoder enc = Charset.defaultCharset().newEncoder(); succesfulRun(new FileWriterWithEncoding(file2.getPath(), enc)); } @@ -255,7 +255,7 @@ public class FileWriterWithEncodingTest { try { succesfulRun(new FileWriterWithEncoding(file2, (Charset) null)); fail(); - } catch (NullPointerException ignore) { + } catch (final NullPointerException ignore) { } } http://git-wip-us.apache.org/repos/asf/commons-io/blob/56f2a758/src/test/java/org/apache/commons/io/output/ProxyWriterTest.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/commons/io/output/ProxyWriterTest.java b/src/test/java/org/apache/commons/io/output/ProxyWriterTest.java index d5fb70b..88d2eef 100644 --- a/src/test/java/org/apache/commons/io/output/ProxyWriterTest.java +++ b/src/test/java/org/apache/commons/io/output/ProxyWriterTest.java @@ -136,7 +136,7 @@ public class ProxyWriterTest { @Test(expected = UnsupportedEncodingException.class) public void exceptions_in_append_char() throws IOException { - OutputStreamWriter osw = new OutputStreamWriter(new ByteArrayOutputStream()) { + final OutputStreamWriter osw = new OutputStreamWriter(new ByteArrayOutputStream()) { @Override public void write(final int c) throws IOException { throw new UnsupportedEncodingException("Bah"); @@ -149,7 +149,7 @@ public class ProxyWriterTest { @Test(expected = UnsupportedEncodingException.class) public void exceptions_in_append_charSequence() throws IOException { - OutputStreamWriter osw = new OutputStreamWriter(new ByteArrayOutputStream()) { + final OutputStreamWriter osw = new OutputStreamWriter(new ByteArrayOutputStream()) { @Override public Writer append(final CharSequence csq) throws IOException { throw new UnsupportedEncodingException("Bah"); @@ -162,7 +162,7 @@ public class ProxyWriterTest { @Test(expected = UnsupportedEncodingException.class) public void exceptions_in_append_charSequence_offset() throws IOException { - OutputStreamWriter osw = new OutputStreamWriter(new ByteArrayOutputStream()) { + final OutputStreamWriter osw = new OutputStreamWriter(new ByteArrayOutputStream()) { @Override public Writer append(final CharSequence csq, final int start, final int end) throws IOException { throw new UnsupportedEncodingException("Bah"); @@ -175,7 +175,7 @@ public class ProxyWriterTest { @Test(expected = UnsupportedEncodingException.class) public void exceptions_in_write_int() throws IOException { - OutputStreamWriter osw = new OutputStreamWriter(new ByteArrayOutputStream()) { + final OutputStreamWriter osw = new OutputStreamWriter(new ByteArrayOutputStream()) { @Override public void write(final int c) throws IOException { throw new UnsupportedEncodingException("Bah"); @@ -188,7 +188,7 @@ public class ProxyWriterTest { @Test(expected = UnsupportedEncodingException.class) public void exceptions_in_write_char_array() throws IOException { - OutputStreamWriter osw = new OutputStreamWriter(new ByteArrayOutputStream()) { + final OutputStreamWriter osw = new OutputStreamWriter(new ByteArrayOutputStream()) { @Override public void write(final char[] cbuf) throws IOException { throw new UnsupportedEncodingException("Bah"); @@ -201,7 +201,7 @@ public class ProxyWriterTest { @Test(expected = UnsupportedEncodingException.class) public void exceptions_in_write_offset_char_array() throws IOException { - OutputStreamWriter osw = new OutputStreamWriter(new ByteArrayOutputStream()) { + final OutputStreamWriter osw = new OutputStreamWriter(new ByteArrayOutputStream()) { @Override public void write(final char[] cbuf, final int off, final int len) throws IOException { throw new UnsupportedEncodingException("Bah"); @@ -214,7 +214,7 @@ public class ProxyWriterTest { @Test(expected = UnsupportedEncodingException.class) public void exceptions_in_write_string() throws IOException { - OutputStreamWriter osw = new OutputStreamWriter(new ByteArrayOutputStream()) { + final OutputStreamWriter osw = new OutputStreamWriter(new ByteArrayOutputStream()) { @Override public void write(final String str) throws IOException { throw new UnsupportedEncodingException("Bah"); @@ -227,7 +227,7 @@ public class ProxyWriterTest { @Test(expected = UnsupportedEncodingException.class) public void exceptions_in_write_string_offset() throws IOException { - OutputStreamWriter osw = new OutputStreamWriter(new ByteArrayOutputStream()) { + final OutputStreamWriter osw = new OutputStreamWriter(new ByteArrayOutputStream()) { @Override public void write(final String str, final int off, final int len) throws IOException { throw new UnsupportedEncodingException("Bah"); @@ -240,7 +240,7 @@ public class ProxyWriterTest { @Test(expected = UnsupportedEncodingException.class) public void exceptions_in_flush() throws IOException { - OutputStreamWriter osw = new OutputStreamWriter(new ByteArrayOutputStream()) { + final OutputStreamWriter osw = new OutputStreamWriter(new ByteArrayOutputStream()) { @Override public void flush() throws IOException { throw new UnsupportedEncodingException("Bah"); @@ -253,7 +253,7 @@ public class ProxyWriterTest { @Test(expected = UnsupportedEncodingException.class) public void exceptions_in_close() throws IOException { - OutputStreamWriter osw = new OutputStreamWriter(new ByteArrayOutputStream()) { + final OutputStreamWriter osw = new OutputStreamWriter(new ByteArrayOutputStream()) { @Override public void close() throws IOException { throw new UnsupportedEncodingException("Bah"); http://git-wip-us.apache.org/repos/asf/commons-io/blob/56f2a758/src/test/java/org/apache/commons/io/output/ThresholdingOutputStreamTest.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/commons/io/output/ThresholdingOutputStreamTest.java b/src/test/java/org/apache/commons/io/output/ThresholdingOutputStreamTest.java index 76a8d28..a71996c 100644 --- a/src/test/java/org/apache/commons/io/output/ThresholdingOutputStreamTest.java +++ b/src/test/java/org/apache/commons/io/output/ThresholdingOutputStreamTest.java @@ -29,7 +29,7 @@ public class ThresholdingOutputStreamTest { @Test public void testSetByteCount() throws Exception { final AtomicBoolean reached = new AtomicBoolean(false); - ThresholdingOutputStream tos = new ThresholdingOutputStream(3) { + final ThresholdingOutputStream tos = new ThresholdingOutputStream(3) { { setByteCount(2); } http://git-wip-us.apache.org/repos/asf/commons-io/blob/56f2a758/src/test/java/org/apache/commons/io/output/WriterOutputStreamTest.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/commons/io/output/WriterOutputStreamTest.java b/src/test/java/org/apache/commons/io/output/WriterOutputStreamTest.java index 0a689fc..9315daf 100644 --- a/src/test/java/org/apache/commons/io/output/WriterOutputStreamTest.java +++ b/src/test/java/org/apache/commons/io/output/WriterOutputStreamTest.java @@ -88,7 +88,7 @@ public class WriterOutputStreamTest { public void testUTF16WithSingleByteWrite() throws IOException { try { testWithSingleByteWrite(TEST_STRING, "UTF-16"); - } catch (UnsupportedOperationException e){ + } catch (final UnsupportedOperationException e){ if (!System.getProperty("java.vendor").contains("IBM")){ fail("This test should only throw UOE on IBM JDKs with broken UTF-16"); } @@ -99,7 +99,7 @@ public class WriterOutputStreamTest { public void testUTF16WithBufferedWrite() throws IOException { try { testWithBufferedWrite(TEST_STRING, "UTF-16"); - } catch (UnsupportedOperationException e) { + } catch (final UnsupportedOperationException e) { if (!System.getProperty("java.vendor").contains("IBM")) { fail("This test should only throw UOE on IBM JDKs with broken UTF-16"); } http://git-wip-us.apache.org/repos/asf/commons-io/blob/56f2a758/src/test/java/org/apache/commons/io/serialization/ClosingBase.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/commons/io/serialization/ClosingBase.java b/src/test/java/org/apache/commons/io/serialization/ClosingBase.java index ea3bce5..960b8fc 100644 --- a/src/test/java/org/apache/commons/io/serialization/ClosingBase.java +++ b/src/test/java/org/apache/commons/io/serialization/ClosingBase.java @@ -44,10 +44,10 @@ public class ClosingBase { @After public void cleanup() { - for (Closeable c : toClose) { + for (final Closeable c : toClose) { try { c.close(); - } catch (IOException ignored) { + } catch (final IOException ignored) { } } } http://git-wip-us.apache.org/repos/asf/commons-io/blob/56f2a758/src/test/java/org/apache/commons/io/serialization/RegexpClassNameMatcherTest.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/commons/io/serialization/RegexpClassNameMatcherTest.java b/src/test/java/org/apache/commons/io/serialization/RegexpClassNameMatcherTest.java index d54542f..e87780e 100644 --- a/src/test/java/org/apache/commons/io/serialization/RegexpClassNameMatcherTest.java +++ b/src/test/java/org/apache/commons/io/serialization/RegexpClassNameMatcherTest.java @@ -29,21 +29,21 @@ public class RegexpClassNameMatcherTest { @Test public void testSimplePatternFromString() { - ClassNameMatcher ca = new RegexpClassNameMatcher("foo.*"); + final ClassNameMatcher ca = new RegexpClassNameMatcher("foo.*"); assertTrue(ca.matches("foo.should.match")); assertFalse(ca.matches("bar.should.not.match")); } @Test public void testSimplePatternFromPattern() { - ClassNameMatcher ca = new RegexpClassNameMatcher(Pattern.compile("foo.*")); + final ClassNameMatcher ca = new RegexpClassNameMatcher(Pattern.compile("foo.*")); assertTrue(ca.matches("foo.should.match")); assertFalse(ca.matches("bar.should.not.match")); } @Test public void testOrPattern() { - ClassNameMatcher ca = new RegexpClassNameMatcher("foo.*|bar.*"); + final ClassNameMatcher ca = new RegexpClassNameMatcher("foo.*|bar.*"); assertTrue(ca.matches("foo.should.match")); assertTrue(ca.matches("bar.should.match")); assertFalse(ca.matches("zoo.should.not.match")); http://git-wip-us.apache.org/repos/asf/commons-io/blob/56f2a758/src/test/java/org/apache/commons/io/serialization/ValidatingObjectInputStreamTest.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/commons/io/serialization/ValidatingObjectInputStreamTest.java b/src/test/java/org/apache/commons/io/serialization/ValidatingObjectInputStreamTest.java index 76e8cfe..5bfd3ad 100644 --- a/src/test/java/org/apache/commons/io/serialization/ValidatingObjectInputStreamTest.java +++ b/src/test/java/org/apache/commons/io/serialization/ValidatingObjectInputStreamTest.java @@ -73,7 +73,7 @@ public class ValidatingObjectInputStreamTest extends ClosingBase { assertSerialization( willClose(new ValidatingObjectInputStream(testStream))); fail("Expected an InvalidClassException"); - } catch(InvalidClassException ice) { + } catch(final InvalidClassException ice) { final String name = MockSerializedClass.class.getName(); assertTrue("Expecting message to contain " + name, ice.getMessage().contains(name)); } http://git-wip-us.apache.org/repos/asf/commons-io/blob/56f2a758/src/test/java/org/apache/commons/io/serialization/WildcardClassNameMatcherTest.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/commons/io/serialization/WildcardClassNameMatcherTest.java b/src/test/java/org/apache/commons/io/serialization/WildcardClassNameMatcherTest.java index 59a950b..e82fd2b 100644 --- a/src/test/java/org/apache/commons/io/serialization/WildcardClassNameMatcherTest.java +++ b/src/test/java/org/apache/commons/io/serialization/WildcardClassNameMatcherTest.java @@ -27,7 +27,7 @@ public class WildcardClassNameMatcherTest { @Test public void noPattern() { - ClassNameMatcher ca = new WildcardClassNameMatcher("org.foo"); + final ClassNameMatcher ca = new WildcardClassNameMatcher("org.foo"); assertTrue(ca.matches("org.foo")); assertFalse(ca.matches("org.foo.and.more")); assertFalse(ca.matches("org_foo")); @@ -35,14 +35,14 @@ public class WildcardClassNameMatcherTest { @Test public void star() { - ClassNameMatcher ca = new WildcardClassNameMatcher("org*"); + final ClassNameMatcher ca = new WildcardClassNameMatcher("org*"); assertTrue(ca.matches("org.foo.should.match")); assertFalse(ca.matches("bar.should.not.match")); } @Test public void starAndQuestionMark() { - ClassNameMatcher ca = new WildcardClassNameMatcher("org?apache?something*"); + final ClassNameMatcher ca = new WildcardClassNameMatcher("org?apache?something*"); assertTrue(ca.matches("org.apache_something.more")); assertFalse(ca.matches("org..apache_something.more")); } http://git-wip-us.apache.org/repos/asf/commons-io/blob/56f2a758/src/test/java/org/apache/commons/io/testtools/TestUtils.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/commons/io/testtools/TestUtils.java b/src/test/java/org/apache/commons/io/testtools/TestUtils.java index a2fe36f..7cc0ec0 100644 --- a/src/test/java/org/apache/commons/io/testtools/TestUtils.java +++ b/src/test/java/org/apache/commons/io/testtools/TestUtils.java @@ -223,7 +223,7 @@ public abstract class TestUtils { * @throws InterruptedException if interrupted */ public static void sleep(final long ms) throws InterruptedException { - long finishAt = System.currentTimeMillis() + ms; + final long finishAt = System.currentTimeMillis() + ms; long remaining = ms; do { Thread.sleep(remaining); @@ -234,7 +234,7 @@ public abstract class TestUtils { public static void sleepQuietly(final long ms) { try { sleep(ms); - } catch (InterruptedException ignored){ + } catch (final InterruptedException ignored){ } }