nus-yam/ex-repair huggingface dataset:
Program: 94892
Project: 94892
Buggy source:
private void sendMavlinkPacket(MAVLinkPacket packet){
  drone.getMavClient().sendMavPacket(packet);
}

Fixed version (ground truth):
private void sendMavlinkPacket(MAVLinkPacket packet){
  packet.sysid=255;
  packet.compid=0;
  drone.getMavClient().sendMavPacket(packet);
}
Program: 94893
Project: 94893
Buggy source:
public void onHeartBeat(msg_gopro_heartbeat heartBeat){
  if (status != heartBeat.status) {
    status=heartBeat.status;
    drone.notifyDroneEvent(DroneEventsType.GOPRO_STATUS_UPDATE);
    if (!isConnected()) {
      resetFutures();
    }
  }
  restartWatchdog();
}

Fixed version (ground truth):
public void onHeartBeat(msg_gopro_heartbeat heartBeat){
  this.scratchSetRequest.target_component=(byte)heartBeat.compid;
  this.scratchGetRequest.target_component=(byte)heartBeat.compid;
  if (status != heartBeat.status) {
    status=heartBeat.status;
    drone.notifyDroneEvent(DroneEventsType.GOPRO_STATUS_UPDATE);
    if (!isConnected()) {
      resetFutures();
    }
  }
  restartWatchdog();
}
Program: 94894
Project: 94894
Buggy source:
private void sendSetRequest(int commandId,int value,SetResponseHandler future){
  setResponsesFutures.put(commandId,future);
  scratchSetRequest.cmd_id=(byte)commandId;
  scratchSetRequest.value=(byte)value;
  sendMavlinkPacket(scratchSetRequest.pack());
}

Fixed version (ground truth):
private void sendSetRequest(int commandId,int value,SetResponseHandler future){
  if (future != null)   setResponsesFutures.put(commandId,future);
  scratchSetRequest.cmd_id=(byte)commandId;
  scratchSetRequest.value=(byte)value;
  sendMavlinkPacket(scratchSetRequest.pack());
}
Program: 94895
Project: 94895
Buggy source:
private void sendGetRequest(int commandId,GetResponseHandler future){
  getResponsesFutures.put(commandId,future);
  scratchGetRequest.cmd_id=(byte)commandId;
  sendMavlinkPacket(scratchGetRequest.pack());
}

Fixed version (ground truth):
private void sendGetRequest(int commandId,GetResponseHandler future){
  if (future != null)   getResponsesFutures.put(commandId,future);
  scratchGetRequest.cmd_id=(byte)commandId;
  sendMavlinkPacket(scratchGetRequest.pack());
}
Program: 94896
Project: 94896
Buggy source:
public GoProImpl(Drone drone,Handler handler){
  this.drone=drone;
  this.watchdog=handler;
  if (drone.isConnected()) {
    updateRequestTarget();
  }
}

Fixed version (ground truth):
public GoProImpl(Drone drone,Handler handler){
  this.drone=drone;
  this.watchdog=handler;
  this.scratchGetRequest=new msg_gopro_get_request();
  this.scratchGetRequest.sysid=255;
  this.scratchGetRequest.compid=0;
  this.scratchGetRequest.target_system=0;
  this.scratchSetRequest=new msg_gopro_set_request();
  this.scratchSetRequest.sysid=255;
  this.scratchSetRequest.compid=0;
  this.scratchSetRequest.target_system=0;
  if (drone.isConnected()) {
    updateRequestTarget();
  }
}
Program: 94897
Project: 94897
Buggy source:
public boolean isRecording(){
  return status == GOPRO_HEARTBEAT_STATUS.GOPRO_HEARTBEAT_STATUS_RECORDING;
}

Fixed version (ground truth):
public boolean isRecording(){
  return isRecording;
}
Program: 94898
Project: 94898
Buggy source:
public void startRecording(){
  if (!isConnected() || isRecording())   return;
  scratchSetRequest.cmd_id=GOPRO_COMMAND.GOPRO_COMMAND_SHUTTER;
  sendSetRequest(GOPRO_COMMAND.GOPRO_COMMAND_POWER,1,new SetResponseHandler(){
    @Override public void onResponse(    byte commandId,    boolean result){
      if (result) {
        sendSetRequest(GOPRO_COMMAND.GOPRO_COMMAND_CAPTURE_MODE,0,new SetResponseHandler(){
          @Override public void onResponse(          byte commandId,          boolean success){
            if (success) {
              sendSetRequest(GOPRO_COMMAND.GOPRO_COMMAND_SHUTTER,1,null);
            }
 else {
              System.err.println("String_Node_Str");
            }
          }
        }
);
      }
 else {
        System.err.println("String_Node_Str");
      }
    }
  }
);
}

Fixed version (ground truth):
public void startRecording(){
  if (!isConnected() || isRecording())   return;
  sendSetRequest(GOPRO_COMMAND.GOPRO_COMMAND_SHUTTER,1,new SetResponseHandler(){
    @Override public void onResponse(    byte commandId,    boolean success){
      if (success != isRecording) {
        isRecording=success;
        drone.notifyDroneEvent(DroneEventsType.GOPRO_STATUS_UPDATE);
      }
    }
  }
);
}
Program: 94899
Project: 94899
Buggy source:
public void stopRecording(){
  if (!isConnected() || !isRecording())   return;
  sendSetRequest(GOPRO_COMMAND.GOPRO_COMMAND_SHUTTER,0,null);
}

Fixed version (ground truth):
public void stopRecording(){
  if (!isConnected() || !isRecording())   return;
  sendSetRequest(GOPRO_COMMAND.GOPRO_COMMAND_SHUTTER,0,new SetResponseHandler(){
    @Override public void onResponse(    byte commandId,    boolean success){
      if (success == isRecording) {
        isRecording=!success;
        drone.notifyDroneEvent(DroneEventsType.GOPRO_STATUS_UPDATE);
      }
    }
  }
);
}
Program: 94900
Project: 94900
Buggy source:
public DownloadImageTask(String appId,ImageView bmImage,Map<String,Bitmap> cachedMap){
  this.bmImage=bmImage;
  this.appId=appId;
  this.cachedMap=cachedMap;
}

Fixed version (ground truth):
public DownloadImageTask(Context context,String appId,ImageView bmImage,Map<String,Bitmap> cachedMap){
  this.bmImage=bmImage;
  this.appId=appId;
  this.cachedMap=cachedMap;
  final File rootDir=new File(context.getExternalFilesDir(null),ROOT_DIR);
  if (!rootDir.exists() && !rootDir.mkdirs()) {
    throw new IllegalStateException("String_Node_Str");
  }
  this.appIconFile=new File(rootDir,appId);
}
Program: 94901
Project: 94901
Buggy source:
protected Bitmap doInBackground(String... urls){
  String urlDisplay=urls[0];
  if (urlDisplay == null)   return null;
  Bitmap mIcon11=null;
  try {
    InputStream in=new URL(urlDisplay).openStream();
    mIcon11=BitmapFactory.decodeStream(in);
  }
 catch (  Exception e) {
    Log.e(TAG,e.getMessage(),e);
  }
  return mIcon11;
}

Fixed version (ground truth):
protected Bitmap doInBackground(String... urls){
  Bitmap mIcon11=null;
  if (this.appIconFile.isFile() && this.appIconFile.length() > 0) {
    mIcon11=BitmapFactory.decodeFile(this.appIconFile.getAbsolutePath());
    if (mIcon11 != null)     return mIcon11;
  }
  String urlDisplay=urls[0];
  if (urlDisplay == null)   return null;
  try {
    BufferedInputStream in=new BufferedInputStream(new URL(urlDisplay).openStream());
    final FileOutputStream fos=new FileOutputStream(this.appIconFile);
    final byte[] writeBuffer=new byte[BUFFER_SIZE];
    int byteCount;
    do {
      byteCount=in.read(writeBuffer);
      if (byteCount > -1) {
        fos.write(writeBuffer,0,byteCount);
        fos.flush();
      }
    }
 while (byteCount != -1);
    fos.close();
    mIcon11=BitmapFactory.decodeFile(this.appIconFile.getAbsolutePath());
  }
 catch (  Exception e) {
    Log.e(TAG,e.getMessage(),e);
  }
  return mIcon11;
}
Program: 94902
Project: 94902
Buggy source:
protected void onPostExecute(Bitmap result){
  if (result != null) {
    if (bmImage != null)     bmImage.setImageBitmap(result);
    if (cachedMap != null && appId != null)     cachedMap.put(appId,result);
  }
}

Fixed version (ground truth):
protected void onPostExecute(Bitmap result){
  if (result != null) {
    if (bmImage != null)     bmImage.setImageBitmap(result);
    if (cachedMap != null)     cachedMap.put(appId,result);
  }
}
Program: 94904
Project: 94904
Buggy source:
@Before public void setUp() throws Exception {
  final Context context=Robolectric.getShadowApplication().getApplicationContext();
  ConnectionParameter connParams=new ConnectionParameter(0,new Bundle(),null);
  mavlinkApi=new MockMavLinkServiceAPI();
  DroneInterfaces.Clock clock=new DroneInterfaces.Clock(){
    @Override public long elapsedRealtime(){
      return SystemClock.elapsedRealtime();
    }
  }
;
  DroidPlannerPrefs dpPrefs=new DroidPlannerPrefs(context);
  MAVLinkClient mavClient=new MAVLinkClient(context,inputStreamListener,connParams,mavlinkApi);
  drone=new DroneImpl(mavClient,clock,dpHandler,dpPrefs,new AndroidApWarningParser(context));
}

Fixed version (ground truth):
@Before public void setUp() throws Exception {
  final Context context=Robolectric.getShadowApplication().getApplicationContext();
  ConnectionParameter connParams=new ConnectionParameter(0,new Bundle(),null);
  mavlinkApi=new MockMavLinkServiceAPI();
  DroneInterfaces.Clock clock=new DroneInterfaces.Clock(){
    @Override public long elapsedRealtime(){
      return SystemClock.elapsedRealtime();
    }
  }
;
  DroidPlannerPrefs dpPrefs=new DroidPlannerPrefs(context);
  MAVLinkClient mavClient=new MAVLinkClient(context,inputStreamListener,connParams,mavlinkApi);
  drone=new DroneImpl(mavClient,clock,dpHandler,dpPrefs,new AndroidApWarningParser(context),new LogMessageListener(){
    @Override public void onMessageLogged(    int mavSeverity,    String message){
    }
  }
);
}
Program: 94905
Project: 94905
Buggy source:
@SuppressLint("String_Node_Str") @Override public void onCreate(){
  super.onCreate();
  Log.d(TAG,"String_Node_Str");
  final Context context=getApplicationContext();
  handlerThread=new HandlerThread("String_Node_Str");
  handlerThread.start();
  mavlinkApi=new MavLinkServiceApi(this);
  droneAccess=new DroneAccess(this);
  dpServices=new DPServices(this);
  lbm=LocalBroadcastManager.getInstance(context);
  this.cameraInfoLoader=new CameraInfoLoader(context);
  updateForegroundNotification();
}

Fixed version (ground truth):
@SuppressLint("String_Node_Str") @Override public void onCreate(){
  super.onCreate();
  Log.d(TAG,"String_Node_Str");
  final Context context=getApplicationContext();
  mavlinkApi=new MavLinkServiceApi(this);
  droneAccess=new DroneAccess(this);
  dpServices=new DPServices(this);
  lbm=LocalBroadcastManager.getInstance(context);
  this.cameraInfoLoader=new CameraInfoLoader(context);
  updateForegroundNotification();
}
Program: 94906
Project: 94906
Buggy source:
@Override public void onDestroy(){
  super.onDestroy();
  Log.d(TAG,"String_Node_Str");
  for (  DroneApi droneApi : droneApiStore.values()) {
    droneApi.destroy();
  }
  droneApiStore.clear();
  for (  AndroidMavLinkConnection conn : mavConnections.values()) {
    conn.disconnect();
    conn.removeAllMavLinkConnectionListeners();
  }
  mavConnections.clear();
  dpServices.destroy();
  handlerThread.quit();
  stopForeground(true);
}

Fixed version (ground truth):
@Override public void onDestroy(){
  super.onDestroy();
  Log.d(TAG,"String_Node_Str");
  for (  DroneApi droneApi : droneApiStore.values()) {
    droneApi.destroy();
  }
  droneApiStore.clear();
  for (  AndroidMavLinkConnection conn : mavConnections.values()) {
    conn.disconnect();
    conn.removeAllMavLinkConnectionListeners();
  }
  mavConnections.clear();
  dpServices.destroy();
  stopForeground(true);
}
Program: 94907
Project: 94907
Buggy source:
DroneApi registerDroneApi(IApiListener listener,String appId){
  if (listener == null)   return null;
  DroneApi droneApi=new DroneApi(this,handlerThread.getLooper(),mavlinkApi,listener,appId);
  droneApiStore.put(appId,droneApi);
  lbm.sendBroadcast(new Intent(ACTION_DRONE_CREATED));
  updateForegroundNotification();
  return droneApi;
}

Fixed version (ground truth):
DroneApi registerDroneApi(IApiListener listener,String appId){
  if (listener == null)   return null;
  DroneApi droneApi=new DroneApi(this,Looper.getMainLooper(),listener,appId);
  droneApiStore.put(appId,droneApi);
  lbm.sendBroadcast(new Intent(ACTION_DRONE_CREATED));
  updateForegroundNotification();
  return droneApi;
}
Program: 94908
Project: 94908
Buggy source:
DroneManager connectDroneManager(ConnectionParameter connParams,String appId,DroneEventsListener listener) throws ConnectionException {
  if (connParams == null || TextUtils.isEmpty(appId) || listener == null)   return null;
  DroneManager droneMgr=droneManagers.get(connParams);
  if (droneMgr == null) {
    Log.d(TAG,"String_Node_Str");
    droneMgr=new DroneManager(getApplicationContext(),connParams,new Handler(handlerThread.getLooper()),mavlinkApi);
    droneManagers.put(connParams,droneMgr);
  }
  Log.d(TAG,"String_Node_Str" + appId);
  droneMgr.connect(appId,listener);
  return droneMgr;
}

Fixed version (ground truth):
DroneManager connectDroneManager(ConnectionParameter connParams,String appId,DroneEventsListener listener) throws ConnectionException {
  if (connParams == null || TextUtils.isEmpty(appId) || listener == null)   return null;
  DroneManager droneMgr=droneManagers.get(connParams);
  if (droneMgr == null) {
    Log.d(TAG,"String_Node_Str");
    droneMgr=new DroneManager(getApplicationContext(),connParams,new Handler(Looper.getMainLooper()),mavlinkApi);
    droneManagers.put(connParams,droneMgr);
  }
  Log.d(TAG,"String_Node_Str" + appId);
  droneMgr.connect(appId,listener);
  return droneMgr;
}
Program: 94909
Project: 94909
Buggy source:
DroneApi(DroidPlannerService dpService,Looper looper,MavLinkServiceApi mavlinkApi,IApiListener listener,String ownerId){
  this.service=dpService;
  this.context=dpService.getApplicationContext();
  final Handler handler=new Handler(looper);
  this.droneHandler=new DroneInterfaces.Handler(){
    @Override public void removeCallbacks(    Runnable thread){
      handler.removeCallbacks(thread);
    }
    @Override public void post(    Runnable thread){
      handler.post(thread);
    }
    @Override public void postDelayed(    Runnable thread,    long timeout){
      handler.postDelayed(thread,timeout);
    }
  }
;
  this.ownerId=ownerId;
  observersList=new ConcurrentLinkedQueue<>();
  mavlinkObserversList=new ConcurrentLinkedQueue<>();
  this.apiListener=listener;
  try {
    this.apiListener.asBinder().linkToDeath(this,0);
    checkForSelfRelease();
  }
 catch (  RemoteException e) {
    Log.e(TAG,e.getMessage(),e);
    dpService.releaseDroneApi(this.ownerId);
  }
}

Fixed version (ground truth):
DroneApi(DroidPlannerService dpService,Looper looper,IApiListener listener,String ownerId){
  this.service=dpService;
  this.context=dpService.getApplicationContext();
  final Handler handler=new Handler(looper);
  this.droneHandler=new DroneInterfaces.Handler(){
    @Override public void removeCallbacks(    Runnable thread){
      handler.removeCallbacks(thread);
    }
    @Override public void post(    Runnable thread){
      handler.post(thread);
    }
    @Override public void postDelayed(    Runnable thread,    long timeout){
      handler.postDelayed(thread,timeout);
    }
  }
;
  this.ownerId=ownerId;
  observersList=new ConcurrentLinkedQueue<>();
  mavlinkObserversList=new ConcurrentLinkedQueue<>();
  this.apiListener=listener;
  try {
    this.apiListener.asBinder().linkToDeath(this,0);
    checkForSelfRelease();
  }
 catch (  RemoteException e) {
    Log.e(TAG,e.getMessage(),e);
    dpService.releaseDroneApi(this.ownerId);
  }
}
Program: 94912
Project: 94912
Buggy source:
public void disconnect(){
  try {
    service.disconnectDroneManager(this.droneMgr,this.ownerId);
  }
 catch (  ConnectionException e) {
    notifyConnectionFailed(new ConnectionResult(0,e.getMessage()));
  }
}

Fixed version (ground truth):
public void disconnect(){
  try {
    service.disconnectDroneManager(this.droneMgr,this.ownerId);
    this.droneMgr=null;
  }
 catch (  ConnectionException e) {
    notifyConnectionFailed(new ConnectionResult(0,e.getMessage()));
  }
}
Program: 94915
Project: 94915
Buggy source:
private void checkFailsafe(msg_heartbeat msg_heart){
  boolean failsafe2=msg_heart.system_status == (byte)MAV_STATE.MAV_STATE_CRITICAL;
  if (failsafe2) {
    drone.getState().setWarning("String_Node_Str");
  }
}

Fixed version (ground truth):
private void checkFailsafe(msg_heartbeat msg_heart){
  boolean failsafe2=msg_heart.system_status == (byte)MAV_STATE.MAV_STATE_CRITICAL || msg_heart.system_status == MAV_STATE.MAV_STATE_EMERGENCY;
  if (failsafe2) {
    drone.getState().repeatWarning();
  }
}
Program: 94916
Project: 94916
Buggy source:
@Override public void onLocationChanged(Location androidLocation){
  if (receiver != null) {
    float distanceToLast=-1.0f;
    long timeSinceLast=-1L;
    if (mLastLocation != null) {
      distanceToLast=androidLocation.distanceTo(mLastLocation);
      timeSinceLast=(androidLocation.getTime() - mLastLocation.getTime()) / 1000;
    }
    final float currentSpeed=distanceToLast > 0f && timeSinceLast > 0 ? (distanceToLast / timeSinceLast) : 0f;
    final boolean isLocationAccurate=isLocationAccurate(androidLocation.getAccuracy(),currentSpeed);
    org.droidplanner.core.gcs.location.Location location=new org.droidplanner.core.gcs.location.Location(new Coord3D(androidLocation.getLatitude(),androidLocation.getLongitude(),new Altitude(androidLocation.getAltitude())),androidLocation.getBearing(),androidLocation.getSpeed(),isLocationAccurate,androidLocation.getTime());
    mLastLocation=androidLocation;
    receiver.onLocationUpdate(location);
  }
}

Fixed version (ground truth):
@Override public void onLocationChanged(Location androidLocation){
  if (receiver != null) {
    float distanceToLast=-1.0f;
    long timeSinceLast=-1L;
    final long androidLocationTime=androidLocation.getTime();
    if (mLastLocation != null) {
      distanceToLast=androidLocation.distanceTo(mLastLocation);
      timeSinceLast=(androidLocationTime - mLastLocation.getTime()) / 1000;
    }
    final float currentSpeed=distanceToLast > 0f && timeSinceLast > 0 ? (distanceToLast / timeSinceLast) : 0f;
    final boolean isLocationAccurate=isLocationAccurate(androidLocation.getAccuracy(),currentSpeed);
    org.droidplanner.core.gcs.location.Location location=new org.droidplanner.core.gcs.location.Location(new Coord3D(androidLocation.getLatitude(),androidLocation.getLongitude(),new Altitude(androidLocation.getAltitude())),androidLocation.getBearing(),androidLocation.hasSpeed() ? androidLocation.getSpeed() : currentSpeed,isLocationAccurate,androidLocationTime);
    mLastLocation=androidLocation;
    receiver.onLocationUpdate(location);
  }
}
Program: 94917
Project: 94917
Buggy source:
private void enableFollowMe(){
  lastLocation=null;
  locationFinder.enableLocationUpdates();
  followAlgorithm.enableFollow();
  state=FollowStates.FOLLOW_START;
  drone.notifyDroneEvent(DroneEventsType.FOLLOW_START);
}

Fixed version (ground truth):
private void enableFollowMe(){
  lastLocation=null;
  state=FollowStates.FOLLOW_START;
  locationFinder.enableLocationUpdates();
  followAlgorithm.enableFollow();
  drone.notifyDroneEvent(DroneEventsType.FOLLOW_START);
}
Program: 94918
Project: 94918
Buggy source:
@Override public void onDroneEvent(DroneEventsType event,Drone drone){
switch (event) {
case MODE:
    if (!GuidedPoint.isGuidedMode(drone)) {
      disableFollowMe();
    }
  break;
case HEARTBEAT_TIMEOUT:
case DISCONNECTED:
disableFollowMe();
break;
}
}

Fixed version (ground truth):
@Override public void onDroneEvent(DroneEventsType event,Drone drone){
switch (event) {
case MODE:
    if (isEnabled() && !GuidedPoint.isGuidedMode(drone)) {
      disableFollowMe();
    }
  break;
case HEARTBEAT_TIMEOUT:
case DISCONNECTED:
if (isEnabled()) {
  disableFollowMe();
}
break;
}
}
Program: 94919
Project: 94919
Buggy source:
public void disableFollow(){
  isFollowEnabled.set(false);
  if (GuidedPoint.isGuidedMode(drone)) {
    drone.getGuidedPoint().pauseAtCurrentLocation();
  }
  roiEstimator.disableFollow();
}

Fixed version (ground truth):
public void disableFollow(){
  if (isFollowEnabled.compareAndSet(true,false)) {
    if (GuidedPoint.isGuidedMode(drone)) {
      drone.getGuidedPoint().pauseAtCurrentLocation();
    }
    roiEstimator.disableFollow();
  }
}
Program: 94920
Project: 94920
Buggy source:
protected void updateROI(){
  if (realLocation == null) {
    return;
  }
  Coord2D gcsCoord=new Coord2D(realLocation.getCoord().getLat(),realLocation.getCoord().getLng());
  double bearing=realLocation.getBearing();
  double distanceTraveledSinceLastPoint=realLocation.getSpeed() * (System.currentTimeMillis() - timeOfLastLocation) / 1000f;
  Coord2D goCoord=GeoTools.newCoordFromBearingAndDistance(gcsCoord,bearing,distanceTraveledSinceLastPoint);
  if (distanceTraveledSinceLastPoint > 0.0) {
    MavLinkDoCmds.setROI(drone,new Coord3D(goCoord.getLat(),goCoord.getLng(),new Altitude(0.0)));
  }
  watchdog.postDelayed(watchdogCallback,TIMEOUT);
}

Fixed version (ground truth):
protected void updateROI(){
  if (realLocation == null) {
    return;
  }
  Coord2D gcsCoord=realLocation.getCoord();
  double bearing=realLocation.getBearing();
  double distanceTraveledSinceLastPoint=realLocation.getSpeed() * (System.currentTimeMillis() - timeOfLastLocation) / 1000f;
  Coord2D goCoord=GeoTools.newCoordFromBearingAndDistance(gcsCoord,bearing,distanceTraveledSinceLastPoint);
  MavLinkDoCmds.setROI(drone,new Coord3D(goCoord.getLat(),goCoord.getLng(),new Altitude(0.0)));
  if (realLocation.getSpeed() > 0)   watchdog.postDelayed(watchdogCallback,TIMEOUT);
}
Program: 94921
Project: 94921
Buggy source:
public void disableFollow(){
  disableWatchdog();
  isFollowEnabled.set(false);
  MavLinkDoCmds.resetROI(drone);
}

Fixed version (ground truth):
public void disableFollow(){
  if (isFollowEnabled.compareAndSet(true,false)) {
    realLocation=null;
    MavLinkDoCmds.resetROI(drone);
    disableWatchdog();
  }
}
Program: 94923
Project: 94923
Buggy source:
@Override public void disableLocationUpdates(){
  try {
    gApiMgr.addTask(removeLocationUpdate);
    gApiMgr.addTask(stopgApiMgr);
  }
 catch (  IllegalStateException e) {
    Log.e(TAG,"String_Node_Str",e);
  }
}

Fixed version (ground truth):
@Override public void disableLocationUpdates(){
  try {
    if (gApiMgr.isStarted()) {
      gApiMgr.addTask(removeLocationUpdate);
      gApiMgr.addTask(stopgApiMgr);
    }
  }
 catch (  IllegalStateException e) {
    Log.e(TAG,"String_Node_Str",e);
  }
}
Program: 94924
Project: 94924
Buggy source:
/** 
 * Adds a task to the google api client manager tasks queue. This task will be scheduled to run on a background thread.
 * @param task task making use of the google api client.
 * @return true if the task was successfully added to the queue.
 * @throws IllegalStateException is the start() method was not called.
 */
public boolean addTaskToBackground(GoogleApiClientTask task){
  if (!isStarted()) {
    throw new IllegalStateException("String_Node_Str");
  }
  task.mRunOnBackgroundThread=true;
  return mTaskQueue.offer(task);
}

Fixed version (ground truth):
/** 
 * Adds a task to the google api client manager tasks queue. This task will be scheduled to run on a background thread.
 * @param task task making use of the google api client.
 * @return true if the task was successfully added to the queue.
 * @throws IllegalStateException is the start() method was not called.
 */
public boolean addTaskToBackground(GoogleApiClientTask task){
  if (!isStarted()) {
    Log.e(TAG,"String_Node_Str");
    return false;
  }
  task.mRunOnBackgroundThread=true;
  return mTaskQueue.offer(task);
}
Program: 94925
Project: 94925
Buggy source:
/** 
 * @return true the google api client manager was started.
 */
private boolean isStarted(){
  return mDriverThread != null && mDriverThread.isAlive() && mBgHandlerThread != null && mBgHandlerThread.isAlive() && mBgHandler != null && mBgHandler.getLooper() != null;
}

Fixed version (ground truth):
/** 
 * @return true the google api client manager was started.
 */
public boolean isStarted(){
  return mDriverThread != null && mDriverThread.isAlive() && mBgHandlerThread != null && mBgHandlerThread.isAlive() && mBgHandler != null && mBgHandler.getLooper() != null;
}
Program: 94926
Project: 94926
Buggy source:
/** 
 * Adds a task to the google api client manager tasks queue. This task will be scheduled to run on the calling thread.
 * @param task task making use of the google api client.
 * @return true if the task was successfully added to the queue.
 * @throws IllegalStateException is the start() method was not called.
 */
public boolean addTask(GoogleApiClientTask task){
  if (!isStarted()) {
    throw new IllegalStateException("String_Node_Str");
  }
  task.mRunOnBackgroundThread=false;
  return mTaskQueue.offer(task);
}

Fixed version (ground truth):
/** 
 * Adds a task to the google api client manager tasks queue. This task will be scheduled to run on the calling thread.
 * @param task task making use of the google api client.
 * @return true if the task was successfully added to the queue.
 * @throws IllegalStateException is the start() method was not called.
 */
public boolean addTask(GoogleApiClientTask task){
  if (!isStarted()) {
    Log.e(TAG,"String_Node_Str");
    return false;
  }
  task.mRunOnBackgroundThread=false;
  return mTaskQueue.offer(task);
}
Program: 94927
Project: 94927
Buggy source:
private void enableFollowMe(){
  followAlgorithm.enableFollow();
  locationFinder.enableLocationUpdates();
  state=FollowStates.FOLLOW_START;
  drone.notifyDroneEvent(DroneEventsType.FOLLOW_START);
}

Fixed version (ground truth):
private void enableFollowMe(){
  lastLocation=null;
  locationFinder.enableLocationUpdates();
  followAlgorithm.enableFollow();
  state=FollowStates.FOLLOW_START;
  drone.notifyDroneEvent(DroneEventsType.FOLLOW_START);
}
Program: 94928
Project: 94928
Buggy source:
private void disableFollowMe(){
  followAlgorithm.disableFollow();
  locationFinder.disableLocationUpdates();
  if (isEnabled()) {
    state=FollowStates.FOLLOW_END;
    drone.notifyDroneEvent(DroneEventsType.FOLLOW_STOP);
  }
}

Fixed version (ground truth):
private void disableFollowMe(){
  followAlgorithm.disableFollow();
  locationFinder.disableLocationUpdates();
  lastLocation=null;
  if (isEnabled()) {
    state=FollowStates.FOLLOW_END;
    drone.notifyDroneEvent(DroneEventsType.FOLLOW_STOP);
  }
}
Program: 94929
Project: 94929
Buggy source:
public void setAlgorithm(FollowAlgorithm algorithm){
  if (followAlgorithm != null && followAlgorithm != algorithm) {
    followAlgorithm.disableFollow();
  }
  followAlgorithm=algorithm;
  if (isEnabled()) {
    followAlgorithm.enableFollow();
  }
  drone.notifyDroneEvent(DroneEventsType.FOLLOW_CHANGE_TYPE);
}

Fixed version (ground truth):
public void setAlgorithm(FollowAlgorithm algorithm){
  if (followAlgorithm != null && followAlgorithm != algorithm) {
    followAlgorithm.disableFollow();
  }
  followAlgorithm=algorithm;
  if (isEnabled()) {
    followAlgorithm.enableFollow();
    if (lastLocation != null)     followAlgorithm.onLocationReceived(lastLocation);
  }
  drone.notifyDroneEvent(DroneEventsType.FOLLOW_CHANGE_TYPE);
}
Program: 94930
Project: 94930
Buggy source:
@Override public void onLocationChanged(Location location){
  if (location.isAccurate()) {
    state=FollowStates.FOLLOW_RUNNING;
    followAlgorithm.processNewLocation(location);
  }
 else {
    state=FollowStates.FOLLOW_START;
  }
  drone.notifyDroneEvent(DroneEventsType.FOLLOW_UPDATE);
}

Fixed version (ground truth):
@Override public void onLocationChanged(Location location){
  if (location.isAccurate()) {
    state=FollowStates.FOLLOW_RUNNING;
    lastLocation=location;
    followAlgorithm.onLocationReceived(location);
  }
 else {
    state=FollowStates.FOLLOW_START;
  }
  drone.notifyDroneEvent(DroneEventsType.FOLLOW_UPDATE);
}
Program: 94931
Project: 94931
Buggy source:
public void enableFollow(){
  isFollowEnabled.set(true);
}

Fixed version (ground truth):
public void enableFollow(){
  MavLinkDoCmds.resetROI(drone);
  isFollowEnabled.set(true);
}
Program: 94932
Project: 94932
Buggy source:
protected Bitmap doInBackground(String... urls){
  String urldisplay=urls[0];
  Bitmap mIcon11=null;
  try {
    InputStream in=new java.net.URL(urldisplay).openStream();
    mIcon11=BitmapFactory.decodeStream(in);
  }
 catch (  Exception e) {
    Log.e("String_Node_Str",e.getMessage());
  }
  return mIcon11;
}

Fixed version (ground truth):
protected Bitmap doInBackground(String... urls){
  String urlDisplay=urls[0];
  if (urlDisplay == null)   return null;
  Bitmap mIcon11=null;
  try {
    InputStream in=new URL(urlDisplay).openStream();
    mIcon11=BitmapFactory.decodeStream(in);
  }
 catch (  Exception e) {
    Log.e(TAG,e.getMessage(),e);
  }
  return mIcon11;
}
Program: 94933
Project: 94933
Buggy source:
protected void onPostExecute(Bitmap result){
  bmImage.setImageBitmap(result);
  cachedMap.put(appId,result);
}

Fixed version (ground truth):
protected void onPostExecute(Bitmap result){
  if (result != null) {
    if (bmImage != null)     bmImage.setImageBitmap(result);
    if (cachedMap != null && appId != null)     cachedMap.put(appId,result);
  }
}
Program: 94934
Project: 94934
Buggy source:
/** 
 * Set a Relay pin’s voltage high or low
 * @param drone target vehicle
 * @param relayNumber
 * @param enabled true for relay to be on, false for relay to be off.
 */
public static void setRelay(Drone drone,int relayNumber,boolean enabled){
  Bundle params=new Bundle(2);
  params.putInt(EXTRA_RELAY_NUMBER,relayNumber);
  params.putBoolean(EXTRA_IS_RELAY_ON,enabled);
  drone.performAsyncAction(new Action(ACTION_SET_RELAY,params));
}

Fixed version (ground truth):
/** 
 * Set a Relay pin’s voltage high or low
 * @param drone       target vehicle
 * @param relayNumber
 * @param enabled     true for relay to be on, false for relay to be off.
 */
public static void setRelay(Drone drone,int relayNumber,boolean enabled){
  Bundle params=new Bundle(2);
  params.putInt(EXTRA_RELAY_NUMBER,relayNumber);
  params.putBoolean(EXTRA_IS_RELAY_ON,enabled);
  drone.performAsyncAction(new Action(ACTION_SET_RELAY,params));
}
Program: 94935
Project: 94935
Buggy source:
@Override public Bundle[] getConnectedApps(String requesterId) throws RemoteException {
  Log.d(TAG,"String_Node_Str" + requesterId);
  List<Bundle> appsInfo=new ArrayList<>();
  for (  DroneApi droneApi : getService().droneApiStore) {
    if (droneApi.isConnected()) {
      final ConnectionParameter droneParams=droneApi.getDroneManager().getConnectionParameter();
      final ConnectionParameter sanitizedParams=new ConnectionParameter(droneParams.getConnectionType(),droneParams.getParamsBundle(),null);
      Bundle info=new Bundle();
      info.putString(GCSEvent.EXTRA_APP_ID,droneApi.getOwnerId());
      info.putParcelable(GCSEvent.EXTRA_VEHICLE_CONNECTION_PARAMETER,sanitizedParams);
      appsInfo.add(info);
    }
  }
  return appsInfo.toArray(new Bundle[appsInfo.size()]);
}

Fixed version (ground truth):
@Override public Bundle[] getConnectedApps(String requesterId) throws RemoteException {
  Log.d(TAG,"String_Node_Str" + requesterId);
  List<Bundle> appsInfo=new ArrayList<>();
  for (  DroneApi droneApi : serviceRef.droneApiStore.values()) {
    if (droneApi.isConnected()) {
      final ConnectionParameter droneParams=droneApi.getDroneManager().getConnectionParameter();
      final ConnectionParameter sanitizedParams=new ConnectionParameter(droneParams.getConnectionType(),droneParams.getParamsBundle(),null);
      Bundle info=new Bundle();
      info.putString(GCSEvent.EXTRA_APP_ID,droneApi.getOwnerId());
      info.putParcelable(GCSEvent.EXTRA_VEHICLE_CONNECTION_PARAMETER,sanitizedParams);
      appsInfo.add(info);
    }
  }
  return appsInfo.toArray(new Bundle[appsInfo.size()]);
}
Program: 94936
Project: 94936
Buggy source:
@Override public IDroneApi registerDroneApi(IApiListener listener,String appId) throws RemoteException {
  return getService().registerDroneApi(listener,appId);
}

Fixed version (ground truth):
@Override public IDroneApi registerDroneApi(IApiListener listener,String appId) throws RemoteException {
  return serviceRef.registerDroneApi(listener,appId);
}
Program: 94937
Project: 94937
Buggy source:
@Override public void releaseDroneApi(IDroneApi dpApi) throws RemoteException {
  Log.d(TAG,"String_Node_Str");
  if (dpApi instanceof DroneApi) {
    getService().releaseDroneApi((DroneApi)dpApi);
  }
}

Fixed version (ground truth):
@Override public void releaseDroneApi(IDroneApi dpApi) throws RemoteException {
  Log.d(TAG,"String_Node_Str");
  if (dpApi instanceof DroneApi) {
    serviceRef.releaseDroneApi(((DroneApi)dpApi).getOwnerId());
  }
}
Program: 94938
Project: 94938
Buggy source:
DPServices(DroidPlannerService service){
  serviceRef=new WeakReference<DroidPlannerService>(service);
}

Fixed version (ground truth):
DPServices(DroidPlannerService service){
  serviceRef=service;
}
Program: 94939
Project: 94939
Buggy source:
@Override public void onDestroy(){
  super.onDestroy();
  Log.d(TAG,"String_Node_Str");
  for (  DroneApi droneApi : droneApiStore) {
    droneApi.destroy();
  }
  droneApiStore.clear();
  for (  AndroidMavLinkConnection conn : mavConnections.values()) {
    conn.disconnect();
    conn.removeAllMavLinkConnectionListeners();
  }
  mavConnections.clear();
  stopForeground(true);
}

Fixed version (ground truth):
@Override public void onDestroy(){
  super.onDestroy();
  Log.d(TAG,"String_Node_Str");
  for (  DroneApi droneApi : droneApiStore.values()) {
    droneApi.destroy();
  }
  droneApiStore.clear();
  for (  AndroidMavLinkConnection conn : mavConnections.values()) {
    conn.disconnect();
    conn.removeAllMavLinkConnectionListeners();
  }
  mavConnections.clear();
  dpServices.destroy();
  stopForeground(true);
}
Program: 94940
Project: 94940
Buggy source:
DroneApi registerDroneApi(IApiListener listener,String appId){
  if (listener == null)   return null;
  DroneApi droneApi=new DroneApi(this,new Handler(Looper.getMainLooper()),mavlinkApi,listener,appId);
  droneApiStore.add(droneApi);
  lbm.sendBroadcast(new Intent(ACTION_DRONE_CREATED));
  return droneApi;
}

Fixed version (ground truth):
DroneApi registerDroneApi(IApiListener listener,String appId){
  if (listener == null)   return null;
  DroneApi droneApi=new DroneApi(this,new Handler(Looper.getMainLooper()),mavlinkApi,listener,appId);
  droneApiStore.put(appId,droneApi);
  lbm.sendBroadcast(new Intent(ACTION_DRONE_CREATED));
  return droneApi;
}
Program: 94941
Project: 94941
Buggy source:
void releaseDroneApi(DroneApi droneApi){
  if (droneApi == null)   return;
  droneApiStore.remove(droneApi);
  droneApi.destroy();
  lbm.sendBroadcast(new Intent(ACTION_DRONE_DESTROYED));
}

Fixed version (ground truth):
void releaseDroneApi(String appId){
  if (appId == null)   return;
  DroneApi droneApi=droneApiStore.remove(appId);
  if (droneApi != null) {
    Log.d(TAG,"String_Node_Str" + appId);
    droneApi.destroy();
    lbm.sendBroadcast(new Intent(ACTION_DRONE_DESTROYED));
  }
}
Program: 94942
Project: 94942
Buggy source:
@Override public int onStartCommand(Intent intent,int flags,int startId){
  if (intent != null) {
    final String action=intent.getAction();
    if (ACTION_KICK_START_DRONESHARE_UPLOADS.equals(action)) {
      for (      DroneApi droneApi : droneApiStore) {
        droneApi.getDroneManager().kickStartDroneShareUpload();
      }
    }
  }
  stopSelf();
  return START_NOT_STICKY;
}

Fixed version (ground truth):
@Override public int onStartCommand(Intent intent,int flags,int startId){
  if (intent != null) {
    final String action=intent.getAction();
switch (action) {
case ACTION_KICK_START_DRONESHARE_UPLOADS:
      for (      DroneApi droneApi : droneApiStore.values()) {
        droneApi.getDroneManager().kickStartDroneShareUpload();
      }
    break;
case ACTION_RELEASE_API_INSTANCE:
  final String appId=intent.getStringExtra(EXTRA_API_INSTANCE_APP_ID);
releaseDroneApi(appId);
break;
}
}
stopSelf();
return START_NOT_STICKY;
}
Program: 94943
Project: 94943
Buggy source:
public List<DroneApi> getDroneApiList(){
  return new ArrayList<>(serviceRef.droneApiStore);
}

Fixed version (ground truth):
public List<DroneApi> getDroneApiList(){
  return new ArrayList<>(serviceRef.droneApiStore.values());
}
Program: 94944
Project: 94944
Buggy source:
void destroy(){
  this.serviceRef.clear();
  this.observersList.clear();
  this.mavlinkObserversList.clear();
  this.apiListener.asBinder().unlinkToDeath(this,0);
  this.droneMgr.setDroneEventsListener(null);
  this.droneMgr.destroy();
}

Fixed version (ground truth):
void destroy(){
  Log.d(TAG,"String_Node_Str" + this.ownerId);
  this.observersList.clear();
  this.mavlinkObserversList.clear();
  this.apiListener.asBinder().unlinkToDeath(this,0);
  this.droneMgr.setDroneEventsListener(null);
  this.droneMgr.destroy();
}
Program: 94945
Project: 94945
Buggy source:
private void checkForSelfRelease(){
  if (!apiListener.asBinder().pingBinder()) {
    Log.w(TAG,"String_Node_Str");
    getService().releaseDroneApi(this);
  }
}

Fixed version (ground truth):
private void checkForSelfRelease(){
  if (!apiListener.asBinder().pingBinder()) {
    Log.w(TAG,"String_Node_Str");
    this.context.startService(new Intent(this.context,DroidPlannerService.class).setAction(DroidPlannerService.ACTION_RELEASE_API_INSTANCE).putExtra(DroidPlannerService.EXTRA_API_INSTANCE_APP_ID,this.ownerId));
  }
}
Program: 94946
Project: 94946
Buggy source:
private Parameters getParameters(){
  final Drone drone=this.droneMgr.getDrone();
  final Map<String,com.o3dr.services.android.lib.drone.property.Parameter> proxyParams=new HashMap<String,com.o3dr.services.android.lib.drone.property.Parameter>();
  List<Parameter> droneParameters=drone.getParameters().getParametersList();
  if (!droneParameters.isEmpty()) {
    for (    Parameter param : droneParameters) {
      if (param.name != null) {
        proxyParams.put(param.name,new com.o3dr.services.android.lib.drone.property.Parameter(param.name,param.value,param.type));
      }
    }
    try {
      final VehicleProfile profile=drone.getVehicleProfile();
      if (profile != null) {
        String metadataType=profile.getParameterMetadataType();
        if (metadataType != null) {
          ParameterMetadataLoader.load(getService().getApplicationContext(),metadataType,proxyParams);
        }
      }
    }
 catch (    IOException e) {
      Log.e(TAG,e.getMessage(),e);
    }
catch (    XmlPullParserException e) {
      Log.e(TAG,e.getMessage(),e);
    }
  }
  return new Parameters(new ArrayList<com.o3dr.services.android.lib.drone.property.Parameter>(proxyParams.values()));
}

Fixed version (ground truth):
private Parameters getParameters(){
  final Drone drone=this.droneMgr.getDrone();
  final Map<String,com.o3dr.services.android.lib.drone.property.Parameter> proxyParams=new HashMap<String,com.o3dr.services.android.lib.drone.property.Parameter>();
  List<Parameter> droneParameters=drone.getParameters().getParametersList();
  if (!droneParameters.isEmpty()) {
    for (    Parameter param : droneParameters) {
      if (param.name != null) {
        proxyParams.put(param.name,new com.o3dr.services.android.lib.drone.property.Parameter(param.name,param.value,param.type));
      }
    }
    try {
      final VehicleProfile profile=drone.getVehicleProfile();
      if (profile != null) {
        String metadataType=profile.getParameterMetadataType();
        if (metadataType != null) {
          ParameterMetadataLoader.load(this.context,metadataType,proxyParams);
        }
      }
    }
 catch (    IOException e) {
      Log.e(TAG,e.getMessage(),e);
    }
catch (    XmlPullParserException e) {
      Log.e(TAG,e.getMessage(),e);
    }
  }
  return new Parameters(new ArrayList<com.o3dr.services.android.lib.drone.property.Parameter>(proxyParams.values()));
}
Program: 94947
Project: 94947
Buggy source:
DroneApi(DroidPlannerService dpService,final Handler handler,MavLinkServiceApi mavlinkApi,IApiListener listener,String ownerId){
  this.context=dpService.getApplicationContext();
  this.droneHandler=new DroneInterfaces.Handler(){
    @Override public void removeCallbacks(    Runnable thread){
      handler.removeCallbacks(thread);
    }
    @Override public void post(    Runnable thread){
      handler.post(thread);
    }
    @Override public void postDelayed(    Runnable thread,    long timeout){
      handler.postDelayed(thread,timeout);
    }
  }
;
  this.ownerId=ownerId;
  serviceRef=new SoftReference<DroidPlannerService>(dpService);
  observersList=new ConcurrentLinkedQueue<IObserver>();
  mavlinkObserversList=new ConcurrentLinkedQueue<IMavlinkObserver>();
  this.droneMgr=new DroneManager(context,this.ownerId,handler,mavlinkApi);
  this.droneMgr.setDroneEventsListener(this);
  this.apiListener=listener;
  try {
    this.apiListener.asBinder().linkToDeath(this,0);
    checkForSelfRelease();
  }
 catch (  RemoteException e) {
    Log.e(TAG,e.getMessage(),e);
    dpService.releaseDroneApi(this);
  }
}

Fixed version (ground truth):
DroneApi(DroidPlannerService dpService,final Handler handler,MavLinkServiceApi mavlinkApi,IApiListener listener,String ownerId){
  this.context=dpService.getApplicationContext();
  this.droneHandler=new DroneInterfaces.Handler(){
    @Override public void removeCallbacks(    Runnable thread){
      handler.removeCallbacks(thread);
    }
    @Override public void post(    Runnable thread){
      handler.post(thread);
    }
    @Override public void postDelayed(    Runnable thread,    long timeout){
      handler.postDelayed(thread,timeout);
    }
  }
;
  this.ownerId=ownerId;
  observersList=new ConcurrentLinkedQueue<>();
  mavlinkObserversList=new ConcurrentLinkedQueue<>();
  this.droneMgr=new DroneManager(context,this.ownerId,handler,mavlinkApi);
  this.droneMgr.setDroneEventsListener(this);
  this.apiListener=listener;
  try {
    this.apiListener.asBinder().linkToDeath(this,0);
    checkForSelfRelease();
  }
 catch (  RemoteException e) {
    Log.e(TAG,e.getMessage(),e);
    dpService.releaseDroneApi(this.ownerId);
  }
}
Program: 94948
Project: 94948
Buggy source:
public void refreshDroneList(){
  DroneAccess droneAccess=parent.getDroneAccess();
  if (droneAccess != null) {
    List<DroneApi> dronesList=droneAccess.getDroneApiList();
    appConnectionAdapter.refreshDroneManagerList(dronesList);
  }
  boolean isEmpty=appConnectionAdapter.getItemCount() <= 0;
  defaultView.setVisibility(isEmpty ? View.VISIBLE : View.GONE);
}

Fixed version (ground truth):
public void refreshDroneList(){
  if (parent == null)   return;
  DroneAccess droneAccess=parent.getDroneAccess();
  if (droneAccess != null) {
    List<DroneApi> dronesList=droneAccess.getDroneApiList();
    appConnectionAdapter.refreshDroneManagerList(dronesList);
  }
  boolean isEmpty=appConnectionAdapter.getItemCount() <= 0;
  defaultView.setVisibility(isEmpty ? View.VISIBLE : View.GONE);
}
Program: 94949
Project: 94949
Buggy source:
@Override public void onEndReceivingParameters(List<Parameter> parameter){
  notifyAttributeUpdate(AttributeEvent.PARAMETERS_REFRESH_ENDED,null);
}

Fixed version (ground truth):
@Override public void onEndReceivingParameters(){
  notifyAttributeUpdate(AttributeEvent.PARAMETERS_REFRESH_ENDED,null);
}
Program: 94950
Project: 94950
Buggy source:
private Parameters getParameters(){
  final Drone drone=this.droneMgr.getDrone();
  final Map<String,com.o3dr.services.android.lib.drone.property.Parameter> proxyParams=new HashMap<String,com.o3dr.services.android.lib.drone.property.Parameter>();
  List<Parameter> droneParameters=drone.getParameters().getParametersList();
  if (!droneParameters.isEmpty()) {
    for (    Parameter param : droneParameters) {
      if (param.name != null) {
        proxyParams.put(param.name,new com.o3dr.services.android.lib.drone.property.Parameter(param.name,param.value,param.type));
      }
    }
    try {
      final VehicleProfile profile=drone.getVehicleProfile();
      if (profile != null) {
        String metadataType=profile.getParameterMetadataType();
        if (metadataType != null) {
          ParameterMetadataLoader.load(this.context,metadataType,proxyParams);
        }
      }
    }
 catch (    IOException e) {
      Log.e(TAG,e.getMessage(),e);
    }
catch (    XmlPullParserException e) {
      Log.e(TAG,e.getMessage(),e);
    }
  }
  return new Parameters(new ArrayList<com.o3dr.services.android.lib.drone.property.Parameter>(proxyParams.values()));
}

Fixed version (ground truth):
private Parameters getParameters(){
  final Drone drone=this.droneMgr.getDrone();
  final Map<String,com.o3dr.services.android.lib.drone.property.Parameter> proxyParams=new HashMap<>();
  Map<String,Parameter> droneParameters=drone.getParameters().getParameters();
  if (!droneParameters.isEmpty()) {
    for (    Parameter param : droneParameters.values()) {
      if (param.name != null) {
        proxyParams.put(param.name,new com.o3dr.services.android.lib.drone.property.Parameter(param.name,param.value,param.type));
      }
    }
    try {
      final VehicleProfile profile=drone.getVehicleProfile();
      if (profile != null) {
        String metadataType=profile.getParameterMetadataType();
        if (metadataType != null) {
          ParameterMetadataLoader.load(this.context,metadataType,proxyParams);
        }
      }
    }
 catch (    IOException|XmlPullParserException e) {
      Log.e(TAG,e.getMessage(),e);
    }
  }
  return new Parameters(new ArrayList<>(proxyParams.values()));
}
Program: 94951
Project: 94951
Buggy source:
@Override public void onEndReceivingParameters(List<Parameter> parameter){
  if (droneEventsListener != null) {
    droneEventsListener.onEndReceivingParameters(parameter);
  }
}

Fixed version (ground truth):
@Override public void onEndReceivingParameters(){
  if (droneEventsListener != null) {
    droneEventsListener.onEndReceivingParameters();
  }
}
Program: 94952
Project: 94952
Buggy source:
public void onEndReceivingParameters(List<Parameter> parameter);

Fixed version (ground truth):
public void onEndReceivingParameters();
Program: 94953
Project: 94953
Buggy source:
private void reRequestMissingParams(int howManyParams){
  for (int i=0; i < howManyParams; i++) {
    if (!parameters.containsKey(i)) {
      MavLinkParameters.readParameter(myDrone,i);
    }
  }
}

Fixed version (ground truth):
private void reRequestMissingParams(int howManyParams){
  for (int i=0; i < howManyParams; i++) {
    Boolean isPresent=paramsRollCall.get(i);
    if (isPresent == null || !isPresent) {
      MavLinkParameters.readParameter(myDrone,i);
    }
  }
}
Program: 94954
Project: 94954
Buggy source:
public void refreshParameters(){
  parameters.clear();
  parameterList.clear();
  if (parameterListener != null)   parameterListener.onBeginReceivingParameters();
  MavLinkParameters.requestParametersList(myDrone);
  resetWatchdog();
}

Fixed version (ground truth):
public void refreshParameters(){
  parameters.clear();
  paramsRollCall.clear();
  if (parameterListener != null)   parameterListener.onBeginReceivingParameters();
  MavLinkParameters.requestParametersList(myDrone);
  resetWatchdog();
}
Program: 94955
Project: 94955
Buggy source:
private void processReceivedParam(msg_param_value m_value){
  Parameter param=new Parameter(m_value);
  parameters.put((int)m_value.param_index,param);
  expectedParams=m_value.param_count;
  if (parameterListener != null)   parameterListener.onParameterReceived(param,m_value.param_index,m_value.param_count);
  if (parameters.size() >= m_value.param_count) {
    parameterList.clear();
    for (    int key : parameters.keySet()) {
      parameterList.add(parameters.get(key));
    }
    killWatchdog();
    myDrone.notifyDroneEvent(DroneEventsType.PARAMETERS_DOWNLOADED);
    if (parameterListener != null) {
      parameterListener.onEndReceivingParameters(parameterList);
    }
  }
 else {
    resetWatchdog();
  }
  myDrone.notifyDroneEvent(DroneEventsType.PARAMETER);
}

Fixed version (ground truth):
private void processReceivedParam(msg_param_value m_value){
  Parameter param=new Parameter(m_value);
  paramsRollCall.put((int)m_value.param_index,true);
  parameters.put(param.name.toLowerCase(Locale.US),param);
  expectedParams=m_value.param_count;
  if (parameterListener != null)   parameterListener.onParameterReceived(param,m_value.param_index,m_value.param_count);
  if (parameters.size() >= m_value.param_count) {
    killWatchdog();
    myDrone.notifyDroneEvent(DroneEventsType.PARAMETERS_DOWNLOADED);
    if (parameterListener != null) {
      parameterListener.onEndReceivingParameters();
    }
  }
 else {
    resetWatchdog();
  }
  myDrone.notifyDroneEvent(DroneEventsType.PARAMETER);
}
Program: 94956
Project: 94956
Buggy source:
public Parameter getParameter(String name){
  for (  int key : parameters.keySet()) {
    if (parameters.get(key).name.equalsIgnoreCase(name))     return parameters.get(key);
  }
  return null;
}

Fixed version (ground truth):
public Parameter getParameter(String name){
  if (name == null || name.length() == 0)   return null;
  return parameters.get(name.toLowerCase(Locale.US));
}