void () { Object same = new Object(); CancellablePromise<String> promise = WriteAction.compute(() -> { CancellablePromise<String> promise1 = ReadAction.nonBlocking(() -> "y").coalesceBy(same).submit(AppExecutorUtil.getAppExecutorService()); assertFalse(promise1.isCancelled()); CancellablePromise<String> promise2 = ReadAction.nonBlocking(() -> "x").coalesceBy(same).submit(AppExecutorUtil.getAppExecutorService()); assertTrue(promise1.isCancelled()); assertFalse(promise2.isCancelled()); return promise2; }); String result = waitForPromise(promise); assertEquals("x", result); }