corda/sgx-jvm/avian/test/FutureTaskTest.java
Chris Rankin 4dbd404f64
Integrate our deterministic OpenJDK fork with Avian (#117)
* Remove non-deterministic classes from Avian (wip).
* Complete integration between Avian and our local OpenJDK fork.
* Revert accidental Avian modification.
* Implements a "blacklist filter" for Avian's system classloader.
* Remove .DSA, .RSA, .SF and .MF files when creating a fat jar.
* Revert more accidental Avian changes.
* Fix breakage with dependencies, and retain Kryo instance.
* Apply blacklisting per thread rather than globally.
* Blacklist java.lang.ClassLoader and all java.lang.Thread* classes.
* Add comment explaining class blacklisting.
* Fix Avian when building without OpenJDK.
* Configure ProGuard to keep more classes for deserialisation.
* Retain explicit return type for secure random function.
* Add sources of random numbers to the class blacklist.
* Blacklist the threading classes more precisely.
* Make SystemClassLoader.isForbidden() static.
* Prevent ProGuard from removing SerializedLambda.readResolve().
* Remove Avian tests involving direct buffers.
2017-11-21 17:06:18 +00:00

34 lines
915 B
Java

import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.FutureTask;
import java.util.concurrent.RunnableFuture;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
public class FutureTaskTest {
private static final int DELAY_TIME = 10;
public static void main(String[] args) throws InterruptedException, ExecutionException {
isDoneTest(false);
isDoneTest(true);
}
private static void isDoneTest(final boolean throwException) {
RunnableFuture<?> future = new FutureTask<Object>(new Runnable() {
@Override
public void run() {
if (throwException) {
throw new RuntimeException();
}
}
}, null);
// should finish the future
future.run();
if (! future.isDone()) {
throw new RuntimeException("Future should be done");
}
}
}