mirror of
https://github.com/OpenHFT/Chronicle-Map.git
synced 2021-09-13 01:26:12 +00:00
Stop the test killing all processes when run in Java 11, https://github.com/OpenHFT/Chronicle-Core/issues/128
This commit is contained in:
@@ -17,6 +17,7 @@
|
||||
package net.openhft.chronicle.map;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import net.openhft.chronicle.core.Jvm;
|
||||
import net.openhft.chronicle.core.OS;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
@@ -24,7 +25,6 @@ import org.junit.rules.TemporaryFolder;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Field;
|
||||
import java.nio.file.Files;
|
||||
import java.util.Iterator;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
@@ -35,7 +35,7 @@ import static org.junit.Assert.*;
|
||||
public class ExitHookTest {
|
||||
|
||||
private static final int KEY = 1;
|
||||
private static final int JVM_STARTUP_WAIT_TIME_MS = 5_000;
|
||||
private static final int JVM_STARTUP_WAIT_TIME_MS = 2_000;
|
||||
private static final String PRE_SHUTDOWN_ACTION_EXECUTED = "PRE_SHUTDOWN_ACTION_EXECUTED";
|
||||
private static final String USER_SHUTDOWN_HOOK_EXECUTED = "USER_SHUTDOWN_HOOK_EXECUTED";
|
||||
|
||||
@@ -92,7 +92,7 @@ public class ExitHookTest {
|
||||
mapReference.set(mapBuilder.createPersistedTo(mapFile));
|
||||
try (ExternalMapQueryContext<Integer, Integer, ?> c = mapReference.get().queryContext(KEY)) {
|
||||
c.writeLock().lock();
|
||||
Thread.sleep(30_000);
|
||||
Thread.sleep(8_000);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -104,19 +104,8 @@ public class ExitHookTest {
|
||||
|
||||
// http://stackoverflow.com/a/33171840/648955
|
||||
public static long getPidOfProcess(Process p) {
|
||||
long pid = -1;
|
||||
|
||||
try {
|
||||
if (p.getClass().getName().equals("java.lang.UNIXProcess")) {
|
||||
Field f = p.getClass().getDeclaredField("pid");
|
||||
f.setAccessible(true);
|
||||
pid = f.getLong(p);
|
||||
f.setAccessible(false);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
pid = -1;
|
||||
}
|
||||
return pid;
|
||||
Number pid = Jvm.getValue(p, "pid");
|
||||
return pid.longValue();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
Reference in New Issue
Block a user