You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by ni...@apache.org on 2010/10/07 18:29:15 UTC
svn commit: r1005515 - in /commons/proper/io/trunk/src:
main/java/org/apache/commons/io/FileCleaningTracker.java
test/java/org/apache/commons/io/FileCleaningTrackerTestCase.java
Author: niallp
Date: Thu Oct 7 16:29:15 2010
New Revision: 1005515
URL: http://svn.apache.org/viewvc?rev=1005515&view=rev
Log:
IO-161 try to fix OutOfMemoryError being thrown by FileCleaningTrackerTestCase in Gump and fix a potential *hanging* situation.
Remove the tracker from the list first. Theres a potential loop-for-ever situation if for some reason the delete fails because the Tracker will have been removed from the queue but still be in the List - and this method loops until the List is empty.
Hopefully this will also resolve the FileCleaningTrackerTestCase's OutOfMemoryError in Gump and Continuum. Its failing during the file.delete() operation - the test code to fill-up-memory continues until the Tracker List is zero.
Modified:
commons/proper/io/trunk/src/main/java/org/apache/commons/io/FileCleaningTracker.java
commons/proper/io/trunk/src/test/java/org/apache/commons/io/FileCleaningTrackerTestCase.java
Modified: commons/proper/io/trunk/src/main/java/org/apache/commons/io/FileCleaningTracker.java
URL: http://svn.apache.org/viewvc/commons/proper/io/trunk/src/main/java/org/apache/commons/io/FileCleaningTracker.java?rev=1005515&r1=1005514&r2=1005515&view=diff
==============================================================================
--- commons/proper/io/trunk/src/main/java/org/apache/commons/io/FileCleaningTracker.java (original)
+++ commons/proper/io/trunk/src/main/java/org/apache/commons/io/FileCleaningTracker.java Thu Oct 7 16:29:15 2010
@@ -204,9 +204,9 @@ public class FileCleaningTracker {
try {
// Wait for a tracker to remove.
Tracker tracker = (Tracker) q.remove(); // cannot return null
+ trackers.remove(tracker);
tracker.delete();
tracker.clear();
- trackers.remove(tracker);
} catch (InterruptedException e) {
continue;
}
Modified: commons/proper/io/trunk/src/test/java/org/apache/commons/io/FileCleaningTrackerTestCase.java
URL: http://svn.apache.org/viewvc/commons/proper/io/trunk/src/test/java/org/apache/commons/io/FileCleaningTrackerTestCase.java?rev=1005515&r1=1005514&r2=1005515&view=diff
==============================================================================
--- commons/proper/io/trunk/src/test/java/org/apache/commons/io/FileCleaningTrackerTestCase.java (original)
+++ commons/proper/io/trunk/src/test/java/org/apache/commons/io/FileCleaningTrackerTestCase.java Thu Oct 7 16:29:15 2010
@@ -19,7 +19,6 @@ package org.apache.commons.io;
import java.io.File;
import java.io.RandomAccessFile;
import java.lang.ref.ReferenceQueue;
-import java.lang.ref.SoftReference;
import java.util.ArrayList;
import java.util.List;
@@ -281,12 +280,11 @@ public class FileCleaningTrackerTestCase
//-----------------------------------------------------------------------
private void waitUntilTrackCount() throws Exception {
int count = 0;
- SoftReference<?> ref = new SoftReference<Object>(new Object());
while(theInstance.getTrackCount() != 0 && count++ < 5) {
List<String> list = new ArrayList<String>();
try {
long i = 0;
- while (ref.get() != null) {
+ while (theInstance.getTrackCount() != 0) {
list.add("A Big String A Big String A Big String A Big String A Big String A Big String A Big String A Big String A Big String A Big String " + (i++));
}
} catch (Throwable ignored) {
@@ -295,7 +293,6 @@ public class FileCleaningTrackerTestCase
list = null;
System.gc();
Thread.sleep(1000);
- ref = new SoftReference<Object>(new Object());
}
if (theInstance.getTrackCount() != 0) {
throw new IllegalStateException("Your JVM is not releasing SoftReference, try running the testcase with less memory (-Xmx)");