Program: 59468
Project: 59468
Buggy source:
@Test public void testCallbacks() throws InterruptedException {
  Context appContext=InstrumentationRegistry.getTargetContext();
  CallbackDispatcher dispatcher=new DefaultCallbackDispatcher(appContext);
  CallbackCounter callbackCounter=new CallbackCounter();
  dispatcher.registerCallback(callbackCounter);
  dispatcher.dispatchStart("String_Node_Str");
  dispatcher.dispatchProgress("String_Node_Str",10,100);
  dispatcher.dispatchSuccess(appContext,"String_Node_Str",Collections.singletonMap("String_Node_Str","String_Node_Str"));
  dispatcher.dispatchError(appContext,"String_Node_Str",new ErrorInfo(ErrorInfo.RESOURCE_DOES_NOT_EXIST,null));
  dispatcher.dispatchReschedule(appContext,"String_Node_Str",new ErrorInfo(ErrorInfo.FILE_DOES_NOT_EXIST,null));
  Thread.sleep(DISPATCH_SLEEP_MILLIS);
  assertEquals(1,callbackCounter.start);
  assertEquals(1,callbackCounter.progress);
  assertEquals(1,callbackCounter.success);
  assertEquals(1,callbackCounter.error);
  assertEquals(1,callbackCounter.reschedule);
  dispatcher.dispatchProgress("String_Node_Str",10,100);
  dispatcher.dispatchSuccess(appContext,"String_Node_Str",Collections.singletonMap("String_Node_Str","String_Node_Str"));
  dispatcher.dispatchError(appContext,"String_Node_Str",new ErrorInfo(ErrorInfo.RESOURCE_DOES_NOT_EXIST,null));
  Thread.sleep(DISPATCH_SLEEP_MILLIS);
  assertEquals(2,callbackCounter.progress);
  assertEquals(2,callbackCounter.success);
  assertEquals(2,callbackCounter.error);
  dispatcher.unregisterCallback(callbackCounter);
  dispatcher.dispatchProgress("String_Node_Str",10,100);
  dispatcher.dispatchSuccess(appContext,"String_Node_Str",Collections.singletonMap("String_Node_Str","String_Node_Str"));
  dispatcher.dispatchError(appContext,"String_Node_Str",new ErrorInfo(ErrorInfo.RESOURCE_DOES_NOT_EXIST,null));
  Thread.sleep(DISPATCH_SLEEP_MILLIS);
  assertEquals(2,callbackCounter.progress);
  assertEquals(2,callbackCounter.success);
  assertEquals(2,callbackCounter.error);
}

Fixed version (ground truth):
@Test public void testCallbacks() throws InterruptedException {
  Context appContext=InstrumentationRegistry.getTargetContext();
  CallbackDispatcher dispatcher=new DefaultCallbackDispatcher(appContext);
  CallbackCounter callbackCounter=new CallbackCounter();
  CallbackCounter oneRequestCallbackCounter=new CallbackCounter();
  dispatcher.registerCallback(callbackCounter);
  dispatcher.registerCallback("String_Node_Str",oneRequestCallbackCounter);
  dispatcher.dispatchStart("String_Node_Str");
  dispatcher.dispatchProgress("String_Node_Str",10,100);
  dispatcher.dispatchSuccess(appContext,"String_Node_Str",Collections.singletonMap("String_Node_Str","String_Node_Str"));
  dispatcher.dispatchError(appContext,"String_Node_Str",new ErrorInfo(ErrorInfo.RESOURCE_DOES_NOT_EXIST,null));
  dispatcher.dispatchReschedule(appContext,"String_Node_Str",new ErrorInfo(ErrorInfo.FILE_DOES_NOT_EXIST,null));
  Thread.sleep(DISPATCH_SLEEP_MILLIS);
  assertEquals(1,oneRequestCallbackCounter.start);
  assertEquals(1,oneRequestCallbackCounter.progress);
  assertEquals(1,oneRequestCallbackCounter.success);
  assertEquals(1,oneRequestCallbackCounter.error);
  assertEquals(1,oneRequestCallbackCounter.reschedule);
  assertEquals(1,callbackCounter.start);
  assertEquals(1,callbackCounter.progress);
  assertEquals(1,callbackCounter.success);
  assertEquals(1,callbackCounter.error);
  assertEquals(1,callbackCounter.reschedule);
  dispatcher.dispatchProgress("String_Node_Str",10,100);
  dispatcher.dispatchSuccess(appContext,"String_Node_Str",Collections.singletonMap("String_Node_Str","String_Node_Str"));
  dispatcher.dispatchError(appContext,"String_Node_Str",new ErrorInfo(ErrorInfo.RESOURCE_DOES_NOT_EXIST,null));
  Thread.sleep(DISPATCH_SLEEP_MILLIS);
  assertEquals(2,callbackCounter.progress);
  assertEquals(2,callbackCounter.success);
  assertEquals(2,callbackCounter.error);
  dispatcher.unregisterCallback(callbackCounter);
  dispatcher.dispatchProgress("String_Node_Str",10,100);
  dispatcher.dispatchSuccess(appContext,"String_Node_Str",Collections.singletonMap("String_Node_Str","String_Node_Str"));
  dispatcher.dispatchError(appContext,"String_Node_Str",new ErrorInfo(ErrorInfo.RESOURCE_DOES_NOT_EXIST,null));
  Thread.sleep(DISPATCH_SLEEP_MILLIS);
  assertEquals(1,oneRequestCallbackCounter.start);
  assertEquals(1,oneRequestCallbackCounter.progress);
  assertEquals(1,oneRequestCallbackCounter.success);
  assertEquals(1,oneRequestCallbackCounter.error);
  assertEquals(1,oneRequestCallbackCounter.reschedule);
  assertEquals(2,callbackCounter.progress);
  assertEquals(2,callbackCounter.success);
  assertEquals(2,callbackCounter.error);
}