Skip to content

Commit 8ae4137

Browse files
committed
See IO-159: remove() never returns null
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/io/trunk@919676 13f79535-47bb-0310-9956-ffa450edef68
1 parent e5940fd commit 8ae4137

1 file changed

Lines changed: 4 additions & 7 deletions

File tree

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

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ public int getTrackCount() {
168168
* <p>
169169
* This method allows the thread to be terminated. Simply call this method
170170
* in the resource cleanup code, such as {@link javax.servlet.ServletContextListener#contextDestroyed}.
171-
* One called, no new objects can be tracked by the file cleaner.
171+
* Once called, no new objects can be tracked by the file cleaner.
172172
*/
173173
public synchronized void exitWhenFinished() {
174174
// synchronized block protects reaper
@@ -200,17 +200,14 @@ private final class Reaper extends Thread {
200200
public void run() {
201201
// thread exits when exitWhenFinished is true and there are no more tracked objects
202202
while (exitWhenFinished == false || trackers.size() > 0) {
203-
Tracker tracker = null;
204203
try {
205204
// Wait for a tracker to remove.
206-
tracker = (Tracker) q.remove();
207-
} catch (Exception e) {
208-
continue;
209-
}
210-
if (tracker != null) {
205+
Tracker tracker = (Tracker) q.remove(); // cannot return null
211206
tracker.delete();
212207
tracker.clear();
213208
trackers.remove(tracker);
209+
} catch (InterruptedException e) {
210+
continue;
214211
}
215212
}
216213
}

0 commit comments

Comments
 (0)