commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nia...@apache.org
Subject svn commit: r1002920 - /commons/proper/io/trunk/src/test/org/apache/commons/io/FileCleaningTrackerTestCase.java
Date Thu, 30 Sep 2010 01:27:59 GMT
Author: niallp
Date: Thu Sep 30 01:27:59 2010
New Revision: 1002920

URL: http://svn.apache.org/viewvc?rev=1002920&view=rev
Log:
IO-161 Try to fix the OutOfMemoryError in FileCleaningTrackerTestCase were seeing in Continuum
and Gump

Modified:
    commons/proper/io/trunk/src/test/org/apache/commons/io/FileCleaningTrackerTestCase.java

Modified: commons/proper/io/trunk/src/test/org/apache/commons/io/FileCleaningTrackerTestCase.java
URL: http://svn.apache.org/viewvc/commons/proper/io/trunk/src/test/org/apache/commons/io/FileCleaningTrackerTestCase.java?rev=1002920&r1=1002919&r2=1002920&view=diff
==============================================================================
--- commons/proper/io/trunk/src/test/org/apache/commons/io/FileCleaningTrackerTestCase.java
(original)
+++ commons/proper/io/trunk/src/test/org/apache/commons/io/FileCleaningTrackerTestCase.java
Thu Sep 30 01:27:59 2010
@@ -19,6 +19,7 @@ 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;
 
@@ -280,11 +281,12 @@ 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 (true && theInstance.getTrackCount() != 0) {
+                while (ref.get() != null) {
                     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) {
@@ -293,6 +295,7 @@ 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)");



Mime
View raw message