Program: 10479
Project: 10479
Buggy source:
/** 
 * This method is invoked when the user hits "Done" in the setup view controller. The options chosen by the user are passed in as a map. The keys for this map are declared in SetupViewController. 
 */
private void finishSetup(SetupViewController controller,Map<String,Double> setupInfo){
  startButton.setAlpha(0);
  descriptionLabel.setAlpha(0);
  tableView.setAlpha(1);
  locationManager=new CLLocationManager();
  locationManager.setDelegate(new CLLocationManagerDelegateAdapter(){
    /** 
 * We want to get and store a location measurement that meets the desired accuracy. For this example, we are going to use horizontal accuracy as the deciding factor. In other cases, you may wish to use vertical accuracy, or both together. 
 */
    @Override public void didUpdateToLocation(    CLLocationManager manager,    CLLocation newLocation,    CLLocation oldLocation){
      locationMeasurements.add(newLocation);
      double locationAge=-newLocation.getTimestamp().getTimeIntervalSinceNow();
      if (locationAge > 5)       return;
      if (newLocation.getHorizontalAccuracy() < 0)       return;
      if (bestEffortAtLocation == null || bestEffortAtLocation.getHorizontalAccuracy() > newLocation.getHorizontalAccuracy()) {
        bestEffortAtLocation=newLocation;
        if (newLocation.getHorizontalAccuracy() <= locationManager.getDesiredAccuracy()) {
          stopUpdatingLocation(Str.getLocalizedString("String_Node_Str"));
        }
      }
      tableView.reloadData();
      canTimeOut=false;
    }
    @Override public void didFail(    CLLocationManager manager,    NSError error){
      if (error.getCode() != CLError.LocationUnknown.value()) {
        stopUpdatingLocation(Str.getLocalizedString("String_Node_Str"));
      }
    }
  }
);
  locationManager.setDesiredAccuracy(setupInfo.get(SetupViewController.SETUP_INFO_KEY_ACCURACY));
  locationManager.startUpdatingLocation();
  canTimeOut=true;
  DispatchQueue.after(Dispatch.time(Dispatch.TIME_NOW,(long)(setupInfo.get(SetupViewController.SETUP_INFO_KEY_TIMEOUT) * 1000000000)),DispatchQueue.getMainQueue(),new Runnable(){
    @Override public void run(){
      if (canTimeOut) {
        stopUpdatingLocation("String_Node_Str");
      }
    }
  }
);
  stateString=Str.getLocalizedString("String_Node_Str");
  tableView.reloadData();
}

Fixed version (ground truth):
/** 
 * This method is invoked when the user hits "Done" in the setup view controller. The options chosen by the user are passed in as a map. The keys for this map are declared in SetupViewController. 
 */
private void finishSetup(SetupViewController controller,Map<String,Double> setupInfo){
  startButton.setAlpha(0);
  descriptionLabel.setAlpha(0);
  tableView.setAlpha(1);
  locationManager=new CLLocationManager();
  locationManager.setDelegate(new CLLocationManagerDelegateAdapter(){
    /** 
 * We want to get and store a location measurement that meets the desired accuracy. For this example, we are going to use horizontal accuracy as the deciding factor. In other cases, you may wish to use vertical accuracy, or both together. 
 */
    @Override public void didUpdateToLocation(    CLLocationManager manager,    CLLocation newLocation,    CLLocation oldLocation){
      locationMeasurements.add(newLocation);
      double locationAge=-newLocation.getTimestamp().getTimeIntervalSinceNow();
      if (locationAge > 5)       return;
      if (newLocation.getHorizontalAccuracy() < 0)       return;
      if (bestEffortAtLocation == null || bestEffortAtLocation.getHorizontalAccuracy() > newLocation.getHorizontalAccuracy()) {
        bestEffortAtLocation=newLocation;
        if (newLocation.getHorizontalAccuracy() <= locationManager.getDesiredAccuracy()) {
          stopUpdatingLocation(Str.getLocalizedString("String_Node_Str"));
        }
      }
      tableView.reloadData();
      canTimeOut=false;
    }
    @Override public void didFail(    CLLocationManager manager,    NSError error){
      if (error.getCode() != CLError.LocationUnknown.value()) {
        stopUpdatingLocation(Str.getLocalizedString("String_Node_Str"));
      }
    }
  }
);
  locationManager.setDesiredAccuracy(setupInfo.get(SetupViewController.SETUP_INFO_KEY_ACCURACY));
  locationManager.startUpdatingLocation();
  canTimeOut=true;
  DispatchQueue.getMainQueue().after(Math.round(setupInfo.get(SetupViewController.SETUP_INFO_KEY_TIMEOUT)),TimeUnit.SECONDS,new Runnable(){
    @Override public void run(){
      if (canTimeOut) {
        stopUpdatingLocation("String_Node_Str");
      }
    }
  }
);
  stateString=Str.getLocalizedString("String_Node_Str");
  tableView.reloadData();
}