Skip to content

Commit 3925b50

Browse files
committed
Use final
1 parent 9f75849 commit 3925b50

File tree

4 files changed

+17
-15
lines changed

4 files changed

+17
-15
lines changed

src/main/java/org/apache/commons/io/IOUtils.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ static char[] getScratchCharArray() {
198198
*
199199
* @param array the byte array to release.
200200
*/
201-
static void releaseScratchByteArray(byte[] array) {
201+
static void releaseScratchByteArray(final byte[] array) {
202202
final Object[] holder = SCRATCH_BYTE_BUFFER_HOLDER.get();
203203
if (array == holder[1]) {
204204
Arrays.fill(array, (byte) 0);
@@ -211,7 +211,7 @@ static void releaseScratchByteArray(byte[] array) {
211211
*
212212
* @param array the char array to release.
213213
*/
214-
static void releaseScratchCharArray(char[] array) {
214+
static void releaseScratchCharArray(final char[] array) {
215215
final Object[] holder = SCRATCH_CHAR_BUFFER_HOLDER.get();
216216
if (array == holder[1]) {
217217
Arrays.fill(array, (char) 0);

src/test/java/org/apache/commons/io/FileUtilsTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ List<File> list(final File startDirectory) throws IOException {
170170
*/
171171
private static final ListDirectoryWalker LIST_WALKER = new ListDirectoryWalker();
172172

173-
private static void setDosReadOnly(Path p, boolean readOnly) throws IOException {
173+
private static void setDosReadOnly(final Path p, final boolean readOnly) throws IOException {
174174
if (Files.getFileStore(p).supportsFileAttributeView(DosFileAttributeView.class)) {
175175
Files.setAttribute(p, "dos:readonly", readOnly, LinkOption.NOFOLLOW_LINKS);
176176
}

src/test/java/org/apache/commons/io/IOUtilsConcurrentTest.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ private static class ChecksumReader extends Reader {
4848
private final long expectedChecksumValue;
4949
private final Reader reader;
5050

51-
ChecksumReader(Reader reader, long expectedChecksumValue) {
51+
ChecksumReader(final Reader reader, final long expectedChecksumValue) {
5252
this.reader = reader;
5353
this.checksum = new CRC32();
5454
this.expectedChecksumValue = expectedChecksumValue;
@@ -69,7 +69,7 @@ public int read() throws IOException {
6969
}
7070

7171
@Override
72-
public int read(char[] cbuf, int off, int len) throws IOException {
72+
public int read(final char[] cbuf, final int off, final int len) throws IOException {
7373
final int n = reader.read(cbuf, off, len);
7474
if (n > 0) {
7575
final byte[] bytes = new String(cbuf, off, n).getBytes(Charset.defaultCharset());
@@ -171,7 +171,7 @@ static Stream<IOConsumer<Reader>> testConcurrentReaderTasks() {
171171

172172
@ParameterizedTest
173173
@MethodSource
174-
void testConcurrentInputStreamTasks(IOConsumer<InputStream> consumer) throws InterruptedException {
174+
void testConcurrentInputStreamTasks(final IOConsumer<InputStream> consumer) throws InterruptedException {
175175
final ExecutorService threadPool = Executors.newFixedThreadPool(THREAD_COUNT);
176176
try {
177177
final List<Future<Void>> futures = IntStream.range(0, THREAD_COUNT * RUNS_PER_THREAD)
@@ -194,7 +194,7 @@ void testConcurrentInputStreamTasks(IOConsumer<InputStream> consumer) throws Int
194194

195195
@ParameterizedTest
196196
@MethodSource
197-
void testConcurrentReaderTasks(IOConsumer<Reader> consumer) throws InterruptedException {
197+
void testConcurrentReaderTasks(final IOConsumer<Reader> consumer) throws InterruptedException {
198198
final ExecutorService threadPool = Executors.newFixedThreadPool(THREAD_COUNT);
199199
try {
200200
final List<Future<Void>> futures = IntStream.range(0, THREAD_COUNT * RUNS_PER_THREAD)

src/test/java/org/apache/commons/io/IOUtilsTest.java

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -421,7 +421,7 @@ void testByteArrayWithNegativeSize() {
421421

422422
@ParameterizedTest
423423
@MethodSource
424-
void testCheckFromIndexSizeInvalidCases(int off, int len, int arrayLength) {
424+
void testCheckFromIndexSizeInvalidCases(final int off, final int len, final int arrayLength) {
425425
final IndexOutOfBoundsException ex = assertThrows(IndexOutOfBoundsException.class, () -> IOUtils.checkFromIndexSize(off, len, arrayLength));
426426
assertTrue(ex.getMessage().contains(String.valueOf(off)));
427427
assertTrue(ex.getMessage().contains(String.valueOf(len)));
@@ -431,7 +431,7 @@ void testCheckFromIndexSizeInvalidCases(int off, int len, int arrayLength) {
431431
final IndexOutOfBoundsException jreEx = assertThrows(IndexOutOfBoundsException.class, () -> {
432432
try {
433433
Objects.class.getDeclaredMethod("checkFromIndexSize", int.class, int.class, int.class).invoke(null, off, len, arrayLength);
434-
} catch (InvocationTargetException ite) {
434+
} catch (final InvocationTargetException ite) {
435435
throw ite.getTargetException();
436436
}
437437
});
@@ -441,13 +441,13 @@ void testCheckFromIndexSizeInvalidCases(int off, int len, int arrayLength) {
441441

442442
@ParameterizedTest
443443
@MethodSource
444-
void testCheckFromIndexSizeValidCases(int off, int len, int arrayLength) {
444+
void testCheckFromIndexSizeValidCases(final int off, final int len, final int arrayLength) {
445445
assertDoesNotThrow(() -> IOUtils.checkFromIndexSize(off, len, arrayLength));
446446
}
447447

448448
@ParameterizedTest
449449
@MethodSource
450-
void testCheckFromToIndexInvalidCases(int from, int to, int arrayLength) {
450+
void testCheckFromToIndexInvalidCases(final int from, final int to, final int arrayLength) {
451451
final IndexOutOfBoundsException ex = assertThrows(IndexOutOfBoundsException.class, () -> IOUtils.checkFromToIndex(from, to, arrayLength));
452452
assertTrue(ex.getMessage().contains(String.valueOf(from)));
453453
assertTrue(ex.getMessage().contains(String.valueOf(to)));
@@ -457,7 +457,7 @@ void testCheckFromToIndexInvalidCases(int from, int to, int arrayLength) {
457457
final IndexOutOfBoundsException jreEx = assertThrows(IndexOutOfBoundsException.class, () -> {
458458
try {
459459
Objects.class.getDeclaredMethod("checkFromToIndex", int.class, int.class, int.class).invoke(null, from, to, arrayLength);
460-
} catch (InvocationTargetException ite) {
460+
} catch (final InvocationTargetException ite) {
461461
throw ite.getTargetException();
462462
}
463463
});
@@ -467,7 +467,7 @@ void testCheckFromToIndexInvalidCases(int from, int to, int arrayLength) {
467467

468468
@ParameterizedTest
469469
@MethodSource
470-
void testCheckFromToIndexValidCases(int from, int to, int arrayLength) {
470+
void testCheckFromToIndexValidCases(final int from, final int to, final int arrayLength) {
471471
assertDoesNotThrow(() -> IOUtils.checkFromToIndex(from, to, arrayLength));
472472
}
473473

@@ -1168,7 +1168,8 @@ void testCopyLarge_SkipWithInvalidOffset() throws IOException {
11681168

11691169
@ParameterizedTest
11701170
@MethodSource("invalidRead_InputStream_Offset_ArgumentsProvider")
1171-
void testRead_InputStream_Offset_ArgumentsValidation(InputStream input, byte[] b, int off, int len, Class<? extends Throwable> expected) {
1171+
void testRead_InputStream_Offset_ArgumentsValidation(final InputStream input, final byte[] b, final int off, final int len,
1172+
final Class<? extends Throwable> expected) {
11721173
assertThrows(expected, () -> IOUtils.read(input, b, off, len));
11731174
}
11741175

@@ -1223,7 +1224,8 @@ void testReadFully_InputStream_Offset() throws Exception {
12231224

12241225
@ParameterizedTest
12251226
@MethodSource("invalidRead_InputStream_Offset_ArgumentsProvider")
1226-
void testReadFully_InputStream_Offset_ArgumentsValidation(InputStream input, byte[] b, int off, int len, Class<? extends Throwable> expected) {
1227+
void testReadFully_InputStream_Offset_ArgumentsValidation(final InputStream input, final byte[] b, final int off, final int len,
1228+
final Class<? extends Throwable> expected) {
12271229
assertThrows(expected, () -> IOUtils.read(input, b, off, len));
12281230
}
12291231

0 commit comments

Comments
 (0)