Skip to content

Commit 7c58d8a

Browse files
committed
Fixed all checkstyle errors and a findbugs error
Findbugs error was: org.apache.commons.io.output.DeferredFileOutputStream#thresholdReached possible file handle leak upon exception Also contains fix for IO-446, submitted by Jeffrey Barrus git-svn-id: https://svn.apache.org/repos/asf/commons/proper/io/trunk@1686747 13f79535-47bb-0310-9956-ffa450edef68
1 parent a053fef commit 7c58d8a

25 files changed

Lines changed: 898 additions & 698 deletions

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
package org.apache.commons.io;
1818

1919
import java.nio.charset.Charset;
20-
import java.nio.charset.UnsupportedCharsetException;
2120
import java.util.Collections;
2221
import java.util.SortedMap;
2322
import java.util.TreeMap;
@@ -101,7 +100,7 @@ public static Charset toCharset(final Charset charset) {
101100
* @param charset
102101
* The name of the requested charset, may be null.
103102
* @return a Charset for the named charset
104-
* @throws UnsupportedCharsetException
103+
* @throws java.nio.charset.UnsupportedCharsetException
105104
* If the named charset is unavailable
106105
*/
107106
public static Charset toCharset(final String charset) {

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

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -390,7 +390,8 @@ private void walk(final File directory, final int depth, final Collection<T> res
390390
* @param results the collection of result objects, may be updated
391391
* @throws IOException if an I/O Error occurs
392392
*/
393-
protected final void checkIfCancelled(final File file, final int depth, final Collection<T> results) throws IOException {
393+
protected final void checkIfCancelled(final File file, final int depth, final Collection<T> results) throws
394+
IOException {
394395
if (handleIsCancelled(file, depth, results)) {
395396
throw new CancelException(file, depth);
396397
}
@@ -485,7 +486,8 @@ protected void handleStart(final File startDirectory, final Collection<T> result
485486
* @return true to process this directory, false to skip this directory
486487
* @throws IOException if an I/O Error occurs
487488
*/
488-
protected boolean handleDirectory(final File directory, final int depth, final Collection<T> results) throws IOException {
489+
protected boolean handleDirectory(final File directory, final int depth, final Collection<T> results) throws
490+
IOException {
489491
// do nothing - overridable by subclass
490492
return true; // process directory
491493
}
@@ -500,7 +502,8 @@ protected boolean handleDirectory(final File directory, final int depth, final C
500502
* @param results the collection of result objects, may be updated
501503
* @throws IOException if an I/O Error occurs
502504
*/
503-
protected void handleDirectoryStart(final File directory, final int depth, final Collection<T> results) throws IOException {
505+
protected void handleDirectoryStart(final File directory, final int depth, final Collection<T> results) throws
506+
IOException {
504507
// do nothing - overridable by subclass
505508
}
506509

@@ -516,7 +519,8 @@ protected void handleDirectoryStart(final File directory, final int depth, final
516519
* @throws IOException if an I/O Error occurs
517520
* @since 2.0
518521
*/
519-
protected File[] filterDirectoryContents(final File directory, final int depth, final File[] files) throws IOException {
522+
protected File[] filterDirectoryContents(final File directory, final int depth, final File[] files) throws
523+
IOException {
520524
return files;
521525
}
522526

@@ -544,7 +548,8 @@ protected void handleFile(final File file, final int depth, final Collection<T>
544548
* @param results the collection of result objects, may be updated
545549
* @throws IOException if an I/O Error occurs
546550
*/
547-
protected void handleRestricted(final File directory, final int depth, final Collection<T> results) throws IOException {
551+
protected void handleRestricted(final File directory, final int depth, final Collection<T> results) throws
552+
IOException {
548553
// do nothing - overridable by subclass
549554
}
550555

@@ -558,7 +563,8 @@ protected void handleRestricted(final File directory, final int depth, final Col
558563
* @param results the collection of result objects, may be updated
559564
* @throws IOException if an I/O Error occurs
560565
*/
561-
protected void handleDirectoryEnd(final File directory, final int depth, final Collection<T> results) throws IOException {
566+
protected void handleDirectoryEnd(final File directory, final int depth, final Collection<T> results) throws
567+
IOException {
562568
// do nothing - overridable by subclass
563569
}
564570

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

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
* @version $Id$
4343
*/
4444
public class FileCleaningTracker {
45-
45+
4646
// Note: fields are package protected to allow use by test cases
4747

4848
/**
@@ -129,12 +129,13 @@ public void track(final String path, final Object marker, final FileDeleteStrate
129129

130130
/**
131131
* Adds a tracker to the list of trackers.
132-
*
132+
*
133133
* @param path the full path to the file to be tracked, not null
134134
* @param marker the marker object used to track the file, not null
135135
* @param deleteStrategy the strategy to delete the file, null means normal
136136
*/
137-
private synchronized void addTracker(final String path, final Object marker, final FileDeleteStrategy deleteStrategy) {
137+
private synchronized void addTracker(final String path, final Object marker, final FileDeleteStrategy
138+
deleteStrategy) {
138139
// synchronized block protects reaper
139140
if (exitWhenFinished) {
140141
throw new IllegalStateException("No new trackers can be added once exitWhenFinished() is called");
@@ -185,7 +186,7 @@ public List<String> getDeleteFailures() {
185186
* posing a memory leak.
186187
* <p>
187188
* This method allows the thread to be terminated. Simply call this method
188-
* in the resource cleanup code, such as
189+
* in the resource cleanup code, such as
189190
* {@code javax.servlet.ServletContextListener.contextDestroyed(javax.servlet.ServletContextEvent)}.
190191
* Once called, no new objects can be tracked by the file cleaner.
191192
*/
@@ -257,7 +258,8 @@ private static final class Tracker extends PhantomReference<Object> {
257258
* @param marker the marker object used to track the file, not null
258259
* @param queue the queue on to which the tracker will be pushed, not null
259260
*/
260-
Tracker(final String path, final FileDeleteStrategy deleteStrategy, final Object marker, final ReferenceQueue<? super Object> queue) {
261+
Tracker(final String path, final FileDeleteStrategy deleteStrategy, final Object marker,
262+
final ReferenceQueue<? super Object> queue) {
261263
super(marker, queue);
262264
this.path = path;
263265
this.deleteStrategy = deleteStrategy == null ? FileDeleteStrategy.NORMAL : deleteStrategy;

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -377,7 +377,8 @@ long parseDir(final String line, final String path) throws IOException {
377377
* @return the amount of free drive space on the volume
378378
* @throws IOException if an error occurs
379379
*/
380-
long freeSpaceUnix(final String path, final boolean kb, final boolean posix, final long timeout) throws IOException {
380+
long freeSpaceUnix(final String path, final boolean kb, final boolean posix, final long timeout)
381+
throws IOException {
381382
if (path.isEmpty()) {
382383
throw new IllegalArgumentException("Path must not be empty");
383384
}

0 commit comments

Comments
 (0)