Skip to content

Commit 44c5c56

Browse files
committed
Use final.
1 parent 23cc158 commit 44c5c56

5 files changed

Lines changed: 23 additions & 23 deletions

File tree

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -597,7 +597,7 @@ public static Collection<File> listFilesAndDirs(
597597
*/
598598
private static Collection<File> innerListFilesOrDirectories(
599599
final File directory, final IOFileFilter fileFilter, final IOFileFilter dirFilter,
600-
boolean includeSubDirectories) {
600+
final boolean includeSubDirectories) {
601601
validateListFilesParameters(directory, fileFilter);
602602

603603
final IOFileFilter effFileFilter = setUpEffectiveFileFilter(fileFilter);

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

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -680,8 +680,8 @@ public static int getPrefixLength(final String fileName) {
680680
}
681681
posUnix = posUnix == NOT_FOUND ? posWin : posUnix;
682682
posWin = posWin == NOT_FOUND ? posUnix : posWin;
683-
int pos = Math.min(posUnix, posWin) + 1;
684-
String hostnamePart = fileName.substring(2, pos - 1);
683+
final int pos = Math.min(posUnix, posWin) + 1;
684+
final String hostnamePart = fileName.substring(2, pos - 1);
685685
return isValidHostName(hostnamePart) ? pos : NOT_FOUND;
686686
} else {
687687
return isSeparator(ch0) ? 1 : 0;
@@ -1075,10 +1075,10 @@ public static String getExtension(final String fileName) throws IllegalArgumentE
10751075
* @param fileName a file name
10761076
* @return ADS offsets.
10771077
*/
1078-
private static int getAdsCriticalOffset(String fileName) {
1078+
private static int getAdsCriticalOffset(final String fileName) {
10791079
// Step 1: Remove leading path segments.
1080-
int offset1 = fileName.lastIndexOf(SYSTEM_SEPARATOR);
1081-
int offset2 = fileName.lastIndexOf(OTHER_SEPARATOR);
1080+
final int offset1 = fileName.lastIndexOf(SYSTEM_SEPARATOR);
1081+
final int offset2 = fileName.lastIndexOf(OTHER_SEPARATOR);
10821082
if (offset1 == -1) {
10831083
if (offset2 == -1) {
10841084
return 0;
@@ -1508,7 +1508,7 @@ static String[] splitOnTokens(final String text) {
15081508
* @param name the hostname to validate
15091509
* @return true if the given name is a valid host name
15101510
*/
1511-
private static boolean isValidHostName(String name) {
1511+
private static boolean isValidHostName(final String name) {
15121512
return isIPv6Address(name) || isRFC3986HostName(name);
15131513
}
15141514

@@ -1523,16 +1523,16 @@ private static boolean isValidHostName(String name) {
15231523
* @return true if the given name is a valid IPv4 address
15241524
*/
15251525
// mostly copied from org.apache.commons.validator.routines.InetAddressValidator#isValidInet4Address
1526-
private static boolean isIPv4Address(String name) {
1527-
Matcher m = IPV4_PATTERN.matcher(name);
1526+
private static boolean isIPv4Address(final String name) {
1527+
final Matcher m = IPV4_PATTERN.matcher(name);
15281528
if (!m.matches() || m.groupCount() != 4) {
15291529
return false;
15301530
}
15311531

15321532
// verify that address subgroups are legal
15331533
for (int i = 1; i <= 4; i++) {
1534-
String ipSegment = m.group(i);
1535-
int iIpSegment = Integer.parseInt(ipSegment);
1534+
final String ipSegment = m.group(i);
1535+
final int iIpSegment = Integer.parseInt(ipSegment);
15361536
if (iIpSegment > IPV4_MAX_OCTET_VALUE) {
15371537
return false;
15381538
}
@@ -1558,8 +1558,8 @@ private static boolean isIPv4Address(String name) {
15581558
* @param inet6Address the name to validate
15591559
* @return true if the given name is a valid IPv6 address
15601560
*/
1561-
private static boolean isIPv6Address(String inet6Address) {
1562-
boolean containsCompressedZeroes = inet6Address.contains("::");
1561+
private static boolean isIPv6Address(final String inet6Address) {
1562+
final boolean containsCompressedZeroes = inet6Address.contains("::");
15631563
if (containsCompressedZeroes && (inet6Address.indexOf("::") != inet6Address.lastIndexOf("::"))) {
15641564
return false;
15651565
}
@@ -1569,7 +1569,7 @@ private static boolean isIPv6Address(String inet6Address) {
15691569
}
15701570
String[] octets = inet6Address.split(":");
15711571
if (containsCompressedZeroes) {
1572-
List<String> octetList = new ArrayList<>(Arrays.asList(octets));
1572+
final List<String> octetList = new ArrayList<>(Arrays.asList(octets));
15731573
if (inet6Address.endsWith("::")) {
15741574
// String.split() drops ending empty segments
15751575
octetList.add("");
@@ -1584,7 +1584,7 @@ private static boolean isIPv6Address(String inet6Address) {
15841584
int validOctets = 0;
15851585
int emptyOctets = 0; // consecutive empty chunks
15861586
for (int index = 0; index < octets.length; index++) {
1587-
String octet = octets[index];
1587+
final String octet = octets[index];
15881588
if (octet.length() == 0) {
15891589
emptyOctets++;
15901590
if (emptyOctets > 1) {
@@ -1606,7 +1606,7 @@ private static boolean isIPv6Address(String inet6Address) {
16061606
int octetInt = 0;
16071607
try {
16081608
octetInt = Integer.parseInt(octet, BASE_16);
1609-
} catch (NumberFormatException e) {
1609+
} catch (final NumberFormatException e) {
16101610
return false;
16111611
}
16121612
if (octetInt < 0 || octetInt > MAX_UNSIGNED_SHORT) {
@@ -1631,8 +1631,8 @@ private static boolean isIPv6Address(String inet6Address) {
16311631
* @param name the hostname to validate
16321632
* @return true if the given name is a valid host name
16331633
*/
1634-
private static boolean isRFC3986HostName(String name) {
1635-
String[] parts = name.split("\\.", -1);
1634+
private static boolean isRFC3986HostName(final String name) {
1635+
final String[] parts = name.split("\\.", -1);
16361636
for (int i = 0; i < parts.length; i++) {
16371637
if (parts[i].length() == 0) {
16381638
// trailing dot is legal, otherwise we've hit a .. sequence

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ public void testCopyInputStreamToFile() throws IOException {
8484
private class CheckingInputStream extends ByteArrayInputStream {
8585
private boolean closed;
8686

87-
public CheckingInputStream(byte[] data) {
87+
public CheckingInputStream(final byte[] data) {
8888
super(data);
8989
closed = false;
9090
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -624,7 +624,7 @@ public void testIndexOfExtension() {
624624
try {
625625
FilenameUtils.indexOfExtension("foo.exe:bar.txt");
626626
throw new AssertionError("Expected Exception");
627-
} catch (IllegalArgumentException e) {
627+
} catch (final IllegalArgumentException e) {
628628
assertEquals("NTFS ADS separator (':') in file name is forbidden.", e.getMessage());
629629
}
630630
} else {
@@ -920,7 +920,7 @@ public void testGetExtension() {
920920
try {
921921
FilenameUtils.getExtension("foo.exe:bar.txt");
922922
throw new AssertionError("Expected Exception");
923-
} catch (IllegalArgumentException e) {
923+
} catch (final IllegalArgumentException e) {
924924
assertEquals("NTFS ADS separator (':') in file name is forbidden.", e.getMessage());
925925
}
926926
} else {

src/test/java/org/apache/commons/io/monitor/FileAlterationMonitorTestCase.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ public void testStopWhileWaitingForNextInterval() throws Exception {
191191
private final ThreadFactory delegate = Executors.defaultThreadFactory();
192192

193193
@Override
194-
public Thread newThread(Runnable r) {
194+
public Thread newThread(final Runnable r) {
195195
final Thread thread = delegate.newThread(r);
196196
thread.setDaemon(true); //do not leak threads if the test fails
197197
createdThreads.add(thread);
@@ -208,7 +208,7 @@ public Thread newThread(Runnable r) {
208208
Thread.sleep(10); // wait until the watcher thread enters Thread.sleep()
209209
monitor.stop(100);
210210

211-
for (Thread thread : createdThreads) {
211+
for (final Thread thread : createdThreads) {
212212
assertFalse("The FileAlterationMonitor did not stop the threads it created.", thread.isAlive());
213213
}
214214
}

0 commit comments

Comments
 (0)