Program: 34664
Project: 34664
Buggy source:
/** 
 * Test the constructor for managed completable future that has no underlying action, backed by the specified executor as its default asynchronous execution facility. This test specifies an unmanaged executor to validate that managed completable future can tolerate other executors.
 */
@Test public void testActionlessFutureWithSpecifiedExecutor() throws Exception {
  BlockableIncrementFunction increment1=new BlockableIncrementFunction("String_Node_Str",null,null,false);
  BlockableIncrementFunction increment2=new BlockableIncrementFunction("String_Node_Str",null,null,false);
  BlockableIncrementFunction increment3=new BlockableIncrementFunction("String_Node_Str",null,null,false);
  BlockableIncrementFunction increment4=new BlockableIncrementFunction("String_Node_Str",null,null,false);
  CompletableFuture<Integer> cf0=new ManagedCompletableFuture<Integer>(sameThreadExecutor);
  CompletableFuture<Integer> cf1=cf0.thenApplyAsync(increment1);
  CompletableFuture<Integer> cf2=cf1.thenApplyAsync(increment2);
  CompletableFuture<Integer> cf3=cf2.thenApplyAsync(increment3,noContextExecutor);
  CompletableFuture<Integer> cf4=cf3.thenApplyAsync(increment4);
  assertFalse(cf0.isDone());
  assertFalse(cf1.isDone());
  assertFalse(cf2.isDone());
  assertFalse(cf3.isDone());
  assertFalse(cf4.isDone());
  assertTrue(cf0.complete(180));
  assertEquals(Integer.valueOf(181),cf1.get(TIMEOUT_NS,TimeUnit.NANOSECONDS));
  assertEquals(Integer.valueOf(182),cf2.get(TIMEOUT_NS,TimeUnit.NANOSECONDS));
  assertEquals(Integer.valueOf(183),cf3.get(TIMEOUT_NS,TimeUnit.NANOSECONDS));
  assertEquals(Integer.valueOf(184),cf4.get(TIMEOUT_NS,TimeUnit.NANOSECONDS));
  Thread servletThread=Thread.currentThread();
  assertEquals(servletThread,increment1.executionThread);
  assertEquals(servletThread,increment2.executionThread);
  String executorThreadName=increment3.executionThread.getName();
  assertTrue(executorThreadName,executorThreadName.startsWith("String_Node_Str"));
  assertNotSame(servletThread,increment3.executionThread);
  assertEquals(increment3.executionThread,increment4.executionThread);
}

Fixed version (ground truth):
/** 
 * Test the constructor for managed completable future that has no underlying action, backed by the specified executor as its default asynchronous execution facility. This test specifies an unmanaged executor to validate that managed completable future can tolerate other executors.
 */
@Test public void testActionlessFutureWithSpecifiedExecutor() throws Exception {
  BlockableIncrementFunction increment1=new BlockableIncrementFunction("String_Node_Str",null,null,false);
  BlockableIncrementFunction increment2=new BlockableIncrementFunction("String_Node_Str",null,null,false);
  BlockableIncrementFunction increment3=new BlockableIncrementFunction("String_Node_Str",null,null,false);
  BlockableIncrementFunction increment4=new BlockableIncrementFunction("String_Node_Str",null,null,false);
  CompletableFuture<Integer> cf0=new ManagedCompletableFuture<Integer>(sameThreadExecutor);
  CompletableFuture<Integer> cf1=cf0.thenApplyAsync(increment1);
  CompletableFuture<Integer> cf2=cf1.thenApplyAsync(increment2);
  CompletableFuture<Integer> cf3=cf2.thenApplyAsync(increment3,noContextExecutor);
  CompletableFuture<Integer> cf4=cf3.thenApplyAsync(increment4);
  assertFalse(cf0.isDone());
  assertFalse(cf1.isDone());
  assertFalse(cf2.isDone());
  assertFalse(cf3.isDone());
  assertFalse(cf4.isDone());
  assertTrue(cf0.complete(180));
  assertEquals(Integer.valueOf(181),cf1.get(TIMEOUT_NS,TimeUnit.NANOSECONDS));
  assertEquals(Integer.valueOf(182),cf2.get(TIMEOUT_NS,TimeUnit.NANOSECONDS));
  assertEquals(Integer.valueOf(183),cf3.get(TIMEOUT_NS,TimeUnit.NANOSECONDS));
  assertEquals(Integer.valueOf(184),cf4.get(TIMEOUT_NS,TimeUnit.NANOSECONDS));
  Thread servletThread=Thread.currentThread();
  assertEquals(servletThread,increment1.executionThread);
  assertEquals(servletThread,increment2.executionThread);
  String executorThreadName=increment3.executionThread.getName();
  assertTrue(executorThreadName,executorThreadName.startsWith("String_Node_Str"));
  assertNotSame(servletThread,increment3.executionThread);
  assertEquals(increment3.executionThread,increment4.executionThread);
  assertTrue("String_Node_Str" + increment3.executionThread + "String_Node_Str"+ servletThread+ "String_Node_Str"+ increment4.executionThread,increment4.executionThread.equals(increment3.executionThread) || increment4.executionThread.equals(servletThread));
}