Program: 160285
Project: 160285
Buggy source:
private void runChangeTrackerTransientError(ChangeTracker.ChangeTrackerMode mode,final int errorCode,final String statusMessage,int numExpectedChangeCallbacks) throws Exception {
  final CountDownLatch changeTrackerFinishedSignal=new CountDownLatch(1);
  final CountDownLatch changeReceivedSignal=new CountDownLatch(numExpectedChangeCallbacks);
  URL testURL=getReplicationURL();
  ChangeTrackerClient client=new ChangeTrackerClient(){
    @Override public String getUserAgent(){
      return manager.getUserAgent();
    }
    @Override public void changeTrackerStopped(    ChangeTracker tracker){
      changeTrackerFinishedSignal.countDown();
    }
    @Override public void changeTrackerFinished(    ChangeTracker tracker){
    }
    @Override public void changeTrackerCaughtUp(){
    }
    @Override public void changeTrackerReceivedChange(    Map<String,Object> change){
      changeReceivedSignal.countDown();
    }
    @Override public HttpClient getHttpClient(){
      CustomizableMockHttpClient mockHttpClient=new CustomizableMockHttpClient();
      CustomizableMockHttpClient.Responder sentinal=defaultChangesResponder();
      Queue<CustomizableMockHttpClient.Responder> responders=new LinkedList<CustomizableMockHttpClient.Responder>();
      responders.add(defaultChangesResponder());
      responders.add(CustomizableMockHttpClient.transientErrorResponder(errorCode,statusMessage));
      ResponderChain responderChain=new ResponderChain(responders,sentinal);
      mockHttpClient.setResponder("String_Node_Str",responderChain);
      return mockHttpClient;
    }
    private CustomizableMockHttpClient.Responder defaultChangesResponder(){
      return new CustomizableMockHttpClient.Responder(){
        @Override public HttpResponse execute(        HttpUriRequest httpUriRequest) throws IOException {
          String json="String_Node_Str" + "String_Node_Str" + "String_Node_Str";
          return CustomizableMockHttpClient.generateHttpResponseObject(json);
        }
      }
;
    }
  }
;
  final ChangeTracker changeTracker=new ChangeTracker(testURL,mode,false,0,client);
  changeTracker.setUsePOST(isTestingAgainstSyncGateway());
  changeTracker.start();
  try {
    boolean success=changeReceivedSignal.await(30,TimeUnit.SECONDS);
    assertTrue(success);
  }
 catch (  InterruptedException e) {
    e.printStackTrace();
  }
  changeTracker.stop();
  try {
    boolean success=changeTrackerFinishedSignal.await(30,TimeUnit.SECONDS);
    assertTrue(success);
  }
 catch (  InterruptedException e) {
    e.printStackTrace();
  }
}

Fixed version (ground truth):
private void runChangeTrackerTransientError(ChangeTracker.ChangeTrackerMode mode,final int errorCode,final String statusMessage,int numExpectedChangeCallbacks) throws Exception {
  final CountDownLatch changeTrackerFinishedSignal=new CountDownLatch(1);
  final CountDownLatch changeReceivedSignal=new CountDownLatch(numExpectedChangeCallbacks);
  URL testURL=getReplicationURL();
  ChangeTrackerClient client=new ChangeTrackerClient(){
    @Override public void changeTrackerStopped(    ChangeTracker tracker){
      changeTrackerFinishedSignal.countDown();
    }
    @Override public void changeTrackerFinished(    ChangeTracker tracker){
    }
    @Override public void changeTrackerCaughtUp(){
    }
    @Override public void changeTrackerReceivedChange(    Map<String,Object> change){
      changeReceivedSignal.countDown();
    }
    @Override public HttpClient getHttpClient(){
      CustomizableMockHttpClient mockHttpClient=new CustomizableMockHttpClient();
      CustomizableMockHttpClient.Responder sentinal=defaultChangesResponder();
      Queue<CustomizableMockHttpClient.Responder> responders=new LinkedList<CustomizableMockHttpClient.Responder>();
      responders.add(defaultChangesResponder());
      responders.add(CustomizableMockHttpClient.transientErrorResponder(errorCode,statusMessage));
      ResponderChain responderChain=new ResponderChain(responders,sentinal);
      mockHttpClient.setResponder("String_Node_Str",responderChain);
      return mockHttpClient;
    }
    private CustomizableMockHttpClient.Responder defaultChangesResponder(){
      return new CustomizableMockHttpClient.Responder(){
        @Override public HttpResponse execute(        HttpUriRequest httpUriRequest) throws IOException {
          String json="String_Node_Str" + "String_Node_Str" + "String_Node_Str";
          return CustomizableMockHttpClient.generateHttpResponseObject(json);
        }
      }
;
    }
  }
;
  final ChangeTracker changeTracker=new ChangeTracker(testURL,mode,false,0,client);
  changeTracker.setUsePOST(isTestingAgainstSyncGateway());
  changeTracker.start();
  try {
    boolean success=changeReceivedSignal.await(30,TimeUnit.SECONDS);
    assertTrue(success);
  }
 catch (  InterruptedException e) {
    e.printStackTrace();
  }
  changeTracker.stop();
  try {
    boolean success=changeTrackerFinishedSignal.await(30,TimeUnit.SECONDS);
    assertTrue(success);
  }
 catch (  InterruptedException e) {
    e.printStackTrace();
  }
}