Kaydet (Commit) 18ceb207 authored tarafından Robert Antoni Buj i Gelonch's avatar Robert Antoni Buj i Gelonch Kaydeden (comit) Noel Grandin

javaunohelper: More robust way to wait for finalization

Change-Id: I09fa2462d8131381f380574b8a9aeaf080211b2b
Reviewed-on: https://gerrit.libreoffice.org/11759Reviewed-by: 's avatarNoel Grandin <noelgrandin@gmail.com>
Tested-by: 's avatarNoel Grandin <noelgrandin@gmail.com>
üst ca7899d6
...@@ -34,6 +34,7 @@ import static org.junit.Assert.assertNull; ...@@ -34,6 +34,7 @@ import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertSame; import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertTrue;
import org.junit.Test; import org.junit.Test;
import util.WaitUnreachable;
public class WeakBase_Test public class WeakBase_Test
{ {
...@@ -81,12 +82,9 @@ public class WeakBase_Test ...@@ -81,12 +82,9 @@ public class WeakBase_Test
adapter.addReference(aRef2); adapter.addReference(aRef2);
assertSame(adapter.queryAdapted(), comp); assertSame(adapter.queryAdapted(), comp);
WaitUnreachable u = new WaitUnreachable(comp);
comp= null; comp= null;
logger.log(Level.FINE, "Wait 51ms (-XX:MaxGCPauseMillis=50)"); u.waitUnreachable();
System.gc();
System.runFinalization();
Thread.sleep(51);
assertEquals(aRef1.nDisposeCalled, 1); assertEquals(aRef1.nDisposeCalled, 1);
assertEquals(aRef2.nDisposeCalled, 1); assertEquals(aRef2.nDisposeCalled, 1);
assertNull(adapter.queryAdapted()); assertNull(adapter.queryAdapted());
...@@ -102,11 +100,9 @@ public class WeakBase_Test ...@@ -102,11 +100,9 @@ public class WeakBase_Test
adapter.addReference(aRef2); adapter.addReference(aRef2);
adapter.removeReference(aRef1); adapter.removeReference(aRef1);
logger.log(Level.FINE, "Wait 51ms (-XX:MaxGCPauseMillis=50)"); u = new WaitUnreachable(comp);
comp= null; comp= null;
System.gc(); u.waitUnreachable();
System.runFinalization();
Thread.sleep(51);
assertEquals(aRef1.nDisposeCalled, 0); assertEquals(aRef1.nDisposeCalled, 0);
assertEquals(aRef2.nDisposeCalled, 1); assertEquals(aRef2.nDisposeCalled, 1);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment