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
commit b7ec4f7e855ecb77c8bf42fdd97f123d4588edd2 Author: Gary Gregory <gardgreg...@gmail.com> AuthorDate: Fri Aug 9 14:08:44 2019 -0400 Use final. --- src/main/java/org/apache/commons/io/FileUtils.java | 4 ++-- src/main/java/org/apache/commons/io/IOExceptionList.java | 6 +++--- .../commons/io/input/buffer/CircularBufferInputStream.java | 10 +++++----- .../apache/commons/io/input/buffer/CircularByteBuffer.java | 12 ++++++------ .../apache/commons/io/input/buffer/PeekableInputStream.java | 8 ++++---- .../org/apache/commons/io/input/CloseShieldReaderTest.java | 2 +- 6 files changed, 21 insertions(+), 21 deletions(-) diff --git a/src/main/java/org/apache/commons/io/FileUtils.java b/src/main/java/org/apache/commons/io/FileUtils.java index c77e35a..6503eb3 100644 --- a/src/main/java/org/apache/commons/io/FileUtils.java +++ b/src/main/java/org/apache/commons/io/FileUtils.java @@ -1154,8 +1154,8 @@ public class FileUtils { throw new IOException("Destination '" + destFile + "' exists but is a directory"); } - Path srcPath = srcFile.toPath(); - Path destPath = destFile.toPath(); + final Path srcPath = srcFile.toPath(); + final Path destPath = destFile.toPath(); final long newLastModifed = preserveFileDate ? srcFile.lastModified() : destFile.lastModified(); Files.copy(srcPath, destPath, StandardCopyOption.REPLACE_EXISTING); diff --git a/src/main/java/org/apache/commons/io/IOExceptionList.java b/src/main/java/org/apache/commons/io/IOExceptionList.java index cdfffca..5cb2c74 100644 --- a/src/main/java/org/apache/commons/io/IOExceptionList.java +++ b/src/main/java/org/apache/commons/io/IOExceptionList.java @@ -40,7 +40,7 @@ public class IOExceptionList extends IOException { * * @param causeList a list of cause exceptions. */ - public IOExceptionList(List<? extends Throwable> causeList) { + public IOExceptionList(final List<? extends Throwable> causeList) { super(String.format("%,d exceptions: %s", causeList == null ? 0 : causeList.size(), causeList), causeList == null ? null : causeList.get(0)); this.causeList = causeList == null ? Collections.emptyList() : causeList; @@ -75,7 +75,7 @@ public class IOExceptionList extends IOException { * @param clazz type of exception to return. * @return The list of causes. */ - public <T extends Throwable> T getCause(final int index, Class<T> clazz) { + public <T extends Throwable> T getCause(final int index, final Class<T> clazz) { return (T) causeList.get(index); } @@ -86,7 +86,7 @@ public class IOExceptionList extends IOException { * @param clazz the target type * @return The list of causes. */ - public <T extends Throwable> List<T> getCauseList(Class<T> clazz) { + public <T extends Throwable> List<T> getCauseList(final Class<T> clazz) { return (List<T>) causeList; } diff --git a/src/main/java/org/apache/commons/io/input/buffer/CircularBufferInputStream.java b/src/main/java/org/apache/commons/io/input/buffer/CircularBufferInputStream.java index 8d20de1..1ab8000 100644 --- a/src/main/java/org/apache/commons/io/input/buffer/CircularBufferInputStream.java +++ b/src/main/java/org/apache/commons/io/input/buffer/CircularBufferInputStream.java @@ -40,7 +40,7 @@ public class CircularBufferInputStream extends InputStream { * @param pBufferSize The size of the {@link CircularByteBuffer}, which is * used internally. */ - public CircularBufferInputStream(InputStream pIn, int pBufferSize) { + public CircularBufferInputStream(final InputStream pIn, final int pBufferSize) { Objects.requireNonNull(pIn, "InputStream"); if (pBufferSize <= 0) { throw new IllegalArgumentException("Invalid buffer size: " + pBufferSize); @@ -57,7 +57,7 @@ public class CircularBufferInputStream extends InputStream { * * @param pIn The input stream, which is being buffered. */ - public CircularBufferInputStream(InputStream pIn) { + public CircularBufferInputStream(final InputStream pIn) { this(pIn, 8192); } @@ -91,7 +91,7 @@ public class CircularBufferInputStream extends InputStream { * @return true if the buffer has bytes * @throws IOException in case of an error while reading from the input stream. */ - protected boolean haveBytes(int pNumber) throws IOException { + protected boolean haveBytes(final int pNumber) throws IOException { if (buffer.getCurrentNumberOfBytes() < pNumber) { fillBuffer(); } @@ -107,12 +107,12 @@ public class CircularBufferInputStream extends InputStream { } @Override - public int read(byte[] pBuffer) throws IOException { + public int read(final byte[] pBuffer) throws IOException { return read(pBuffer, 0, pBuffer.length); } @Override - public int read(byte[] pBuffer, int pOffset, int pLength) throws IOException { + public int read(final byte[] pBuffer, final int pOffset, final int pLength) throws IOException { Objects.requireNonNull(pBuffer, "Buffer"); if (pOffset < 0) { throw new IllegalArgumentException("Offset must not be negative"); diff --git a/src/main/java/org/apache/commons/io/input/buffer/CircularByteBuffer.java b/src/main/java/org/apache/commons/io/input/buffer/CircularByteBuffer.java index 95ca142..b15a737 100644 --- a/src/main/java/org/apache/commons/io/input/buffer/CircularByteBuffer.java +++ b/src/main/java/org/apache/commons/io/input/buffer/CircularByteBuffer.java @@ -34,7 +34,7 @@ public class CircularByteBuffer { * * @param pSize the size of buffer to create */ - public CircularByteBuffer(int pSize) { + public CircularByteBuffer(final int pSize) { buffer = new byte[pSize]; startOffset = 0; endOffset = 0; @@ -82,7 +82,7 @@ public class CircularByteBuffer { * of bytes. Use {@link #getCurrentNumberOfBytes()} to prevent this * exception. */ - public void read(byte[] pBuffer, int pOffset, int pLength) { + public void read(final byte[] pBuffer, final int pOffset, final int pLength) { Objects.requireNonNull(pBuffer); if (pOffset < 0 || pOffset >= pBuffer.length) { throw new IllegalArgumentException("Invalid offset: " + pOffset); @@ -117,7 +117,7 @@ public class CircularByteBuffer { * @throws IllegalStateException The buffer is full. Use {@link #hasSpace()}, * or {@link #getSpace()}, to prevent this exception. */ - public void add(byte pByte) { + public void add(final byte pByte) { if (currentNumberOfBytes >= buffer.length) { throw new IllegalStateException("No space available"); } @@ -143,7 +143,7 @@ public class CircularByteBuffer { * @throws IllegalArgumentException Either of {@code pOffset}, or {@code pLength} is negative. * @throws NullPointerException The byte array {@code pBuffer} is null. */ - public boolean peek(byte[] pBuffer, int pOffset, int pLength) { + public boolean peek(final byte[] pBuffer, final int pOffset, final int pLength) { Objects.requireNonNull(pBuffer, "Buffer"); if (pOffset < 0 || pOffset >= pBuffer.length) { throw new IllegalArgumentException("Invalid offset: " + pOffset); @@ -179,7 +179,7 @@ public class CircularByteBuffer { * @throws IllegalArgumentException Either of {@code pOffset}, or {@code pLength} is negative. * @throws NullPointerException The byte array {@code pBuffer} is null. */ - public void add(byte[] pBuffer, int pOffset, int pLength) { + public void add(final byte[] pBuffer, final int pOffset, final int pLength) { Objects.requireNonNull(pBuffer, "Buffer"); if (pOffset < 0 || pOffset >= pBuffer.length) { throw new IllegalArgumentException("Invalid offset: " + pOffset); @@ -219,7 +219,7 @@ public class CircularByteBuffer { * @see #hasSpace() * @see #getSpace() */ - public boolean hasSpace(int pBytes) { + public boolean hasSpace(final int pBytes) { return currentNumberOfBytes + pBytes <= buffer.length; } diff --git a/src/main/java/org/apache/commons/io/input/buffer/PeekableInputStream.java b/src/main/java/org/apache/commons/io/input/buffer/PeekableInputStream.java index feed9c1..891f138 100644 --- a/src/main/java/org/apache/commons/io/input/buffer/PeekableInputStream.java +++ b/src/main/java/org/apache/commons/io/input/buffer/PeekableInputStream.java @@ -35,7 +35,7 @@ public class PeekableInputStream extends CircularBufferInputStream { * @param pBufferSize The size of the {@link CircularByteBuffer}, which is * used internally. */ - public PeekableInputStream(InputStream pIn, int pBufferSize) { + public PeekableInputStream(final InputStream pIn, final int pBufferSize) { super(pIn, pBufferSize); } @@ -45,7 +45,7 @@ public class PeekableInputStream extends CircularBufferInputStream { * * @param pIn The input stream, which is being buffered. */ - public PeekableInputStream(InputStream pIn) { + public PeekableInputStream(final InputStream pIn) { super(pIn); } @@ -58,7 +58,7 @@ public class PeekableInputStream extends CircularBufferInputStream { * @return true if the next bytes are as given * @throws IOException Refilling the buffer failed. */ - public boolean peek(byte[] pBuffer) throws IOException { + public boolean peek(final byte[] pBuffer) throws IOException { Objects.requireNonNull(pBuffer, "Buffer"); if (pBuffer.length > bufferSize) { throw new IllegalArgumentException("Peek request size of " + pBuffer.length @@ -80,7 +80,7 @@ public class PeekableInputStream extends CircularBufferInputStream { * @return true if the next bytes in the buffer are as given * @throws IOException if there is a problem calling fillBuffer() */ - public boolean peek(byte[] pBuffer, int pOffset, int pLength) throws IOException { + public boolean peek(final byte[] pBuffer, final int pOffset, final int pLength) throws IOException { Objects.requireNonNull(pBuffer, "Buffer"); if (pBuffer.length > bufferSize) { throw new IllegalArgumentException("Peek request size of " + pBuffer.length diff --git a/src/test/java/org/apache/commons/io/input/CloseShieldReaderTest.java b/src/test/java/org/apache/commons/io/input/CloseShieldReaderTest.java index 6c6d659..b609df9 100644 --- a/src/test/java/org/apache/commons/io/input/CloseShieldReaderTest.java +++ b/src/test/java/org/apache/commons/io/input/CloseShieldReaderTest.java @@ -49,7 +49,7 @@ public class CloseShieldReaderTest { public void testClose() throws IOException { shielded.close(); verify(original, never()).close(); - char[] cbuf = new char[10]; + final char[] cbuf = new char[10]; assertEquals("read(cbuf, off, len)", -1, shielded.read(cbuf, 0, 10)); assertEquals("read(cbuf, off, len)", data.length(), original.read(cbuf, 0, 10)); assertEquals(data, new String(cbuf, 0, data.length()));