Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -313,42 +313,45 @@ public void run() throws SuspendExecution {
fiber.join();
}

@Ignore // FIXME: This test currently fails and needs to be investigated.
@Test
public void whenCancelRunBlockingInterruptExecutingThread() throws Exception {
final AtomicBoolean started = new AtomicBoolean();
final AtomicBoolean interrupted = new AtomicBoolean();

Fiber fiber = new Fiber(new SuspendableRunnable() {
@Override
public void run() throws SuspendExecution, InterruptedException {
FiberAsync.runBlocking(Executors.newSingleThreadExecutor(),
new CheckedCallable<Void, RuntimeException>() {
@Override
public Void call() throws RuntimeException {
started.set(true);
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
interrupted.set(true);
for (int i = 0;i<100;i++) {
final AtomicBoolean started = new AtomicBoolean();
final AtomicBoolean interrupted = new AtomicBoolean();

Fiber fiber = new Fiber(new SuspendableRunnable() {
@Override
public void run() throws SuspendExecution, InterruptedException {
FiberAsync.runBlocking(Executors.newSingleThreadExecutor(),
new CheckedCallable<Void, RuntimeException>() {
@Override
public Void call() throws RuntimeException {
started.set(true);
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
interrupted.set(true);
}
return null;
}
return null;
}
});
}
});

fiber.start();
Thread.sleep(100);
fiber.cancel(true);
try {
fiber.join(5, TimeUnit.MILLISECONDS);
fail("InterruptedException not thrown");
} catch(ExecutionException e) {
if (!(e.getCause() instanceof InterruptedException))
});
}
});

fiber.start();
Thread.sleep(100);
fiber.cancel(true);
try {
fiber.join(5, TimeUnit.MILLISECONDS);
fail("InterruptedException not thrown");
} catch(ExecutionException e) {
if (!(e.getCause() instanceof InterruptedException))
fail("InterruptedException not thrown");
}
assertThat(started.get(), is(true));
assertThat(interrupted.get(), is(true));
}
assertThat(started.get(), is(true));
assertThat(interrupted.get(), is(true));
}

@Test
Expand Down