nus-yam/ex-repair huggingface dataset:
Program: 94762
Project: 94762
Buggy source:
private void destroyAutopilot(){
  if (drone == null)   return;
  drone.removeDroneListener(this);
  drone.getParameters().setParameterListener(null);
  drone.getMagnetometerCalibration().setListener(null);
  drone=null;
}

Fixed version (ground truth):
private void destroyAutopilot(){
  if (drone == null)   return;
  drone.removeDroneListener(this);
  final Parameters parameters=drone.getParameters();
  if (parameters != null)   parameters.setParameterListener(null);
  final MagnetometerCalibrationImpl magnetometer=drone.getMagnetometerCalibration();
  if (magnetometer != null)   magnetometer.setListener(null);
  drone=null;
}
Program: 94764
Project: 94764
Buggy source:
@Override public DroneAttribute getAttribute(String attributeType){
  if (drone == null)   return null;
switch (attributeType) {
case AttributeType.FOLLOW_STATE:
    return CommonApiUtils.getFollowState(followMe);
case AttributeType.RETURN_TO_ME_STATE:
  return returnToMe == null ? new ReturnToMeState() : returnToMe.getState();
case SoloAttributes.SOLO_STATE:
return SoloApiUtils.getSoloLinkState(this);
case SoloAttributes.SOLO_GOPRO_STATE:
return soloComp.getGoproState();
default :
final DroneAttribute droneAttribute=drone.getAttribute(attributeType);
if (drone instanceof ArduSolo && isCompanionComputerEnabled() && droneAttribute instanceof State) {
final State droneState=(State)droneAttribute;
droneState.addToVehicleUid("String_Node_Str",soloComp.getSoloMacAddress());
droneState.addToVehicleUid("String_Node_Str",soloComp.getControllerMacAddress());
}
return droneAttribute;
}
}

Fixed version (ground truth):
@Override public DroneAttribute getAttribute(String attributeType){
  if (drone == null)   return null;
switch (attributeType) {
case AttributeType.FOLLOW_STATE:
    return CommonApiUtils.getFollowState(followMe);
case AttributeType.RETURN_TO_ME_STATE:
  return returnToMe == null ? new ReturnToMeState() : returnToMe.getState();
case SoloAttributes.SOLO_STATE:
return SoloApiUtils.getSoloLinkState(this);
case SoloAttributes.SOLO_GOPRO_STATE:
return soloComp.getGoproState();
default :
final DroneAttribute droneAttribute=drone.getAttribute(attributeType);
if (drone instanceof ArduSolo && droneAttribute instanceof State) {
final State droneState=(State)droneAttribute;
droneState.addToVehicleUid("String_Node_Str",soloComp.getSoloMacAddress());
droneState.addToVehicleUid("String_Node_Str",soloComp.getControllerMacAddress());
}
return droneAttribute;
}
}
Program: 94765
Project: 94765
Buggy source:
VideoManager(Context context,Handler handler,ExecutorService asyncExecutor){
  super(context,new UdpConnection(handler,ControllerLinkManager.ARTOO_UDP_PORT,UDP_BUFFER_SIZE,true,42),handler,asyncExecutor);
  this.mediaCodecManager=new MediaCodecManager(handler);
}

Fixed version (ground truth):
VideoManager(Context context,Handler handler,ExecutorService asyncExecutor){
  super(context,new UdpConnection(handler,ControllerLinkManager.ARTOO_UDP_PORT,UDP_BUFFER_SIZE,true,16),handler,asyncExecutor);
  this.mediaCodecManager=new MediaCodecManager(handler);
}
Program: 94767
Project: 94767
Buggy source:
private void setMacAddress(String trimmedResponse){
  Timber.i("String_Node_Str" + trimmedResponse);
  macAddress.set(trimmedResponse);
  if (linkListener != null) {
    linkListener.onMacAddressUpdated();
  }
}

Fixed version (ground truth):
private void setMacAddress(String trimmedResponse){
  Timber.i("String_Node_Str",trimmedResponse);
  macAddress.set(trimmedResponse);
  if (linkListener != null) {
    linkListener.onMacAddressUpdated();
  }
}
Program: 94768
Project: 94768
Buggy source:
/** 
 * @deprecated Use {@link ControlApi#pauseAtCurrentLocation()} instead.
 */
public void pauseAtCurrentLocation(){
  ControlApi.getApi(this).pauseAtCurrentLocation();
}

Fixed version (ground truth):
/** 
 * @deprecated Use {@link ControlApi#pauseAtCurrentLocation(AbstractCommandListener)} instead.
 */
public void pauseAtCurrentLocation(){
  ControlApi.getApi(this).pauseAtCurrentLocation(null);
}
Program: 94769
Project: 94769
Buggy source:
/** 
 * @deprecated Use {@link ControlApi#goTo(LatLong,boolean)} instead.
 */
public void sendGuidedPoint(LatLong point,boolean force){
  ControlApi.getApi(this).goTo(point,force);
}

Fixed version (ground truth):
/** 
 * @deprecated Use {@link ControlApi#goTo(LatLong,boolean,AbstractCommandListener)} instead.
 */
public void sendGuidedPoint(LatLong point,boolean force){
  ControlApi.getApi(this).goTo(point,force,null);
}
Program: 94770
Project: 94770
Buggy source:
/** 
 * @deprecated Use {@link ControlApi#takeoff(double)} instead.
 */
public void doGuidedTakeoff(double altitude){
  ControlApi.getApi(this).takeoff(altitude);
}

Fixed version (ground truth):
/** 
 * @deprecated Use {@link ControlApi#takeoff(double,AbstractCommandListener)} instead.
 */
public void doGuidedTakeoff(double altitude){
  ControlApi.getApi(this).takeoff(altitude,null);
}
Program: 94771
Project: 94771
Buggy source:
/** 
 * @deprecated Use {@link VehicleApi#pauseAtCurrentLocation()} instead.
 */
public void pauseAtCurrentLocation(){
  VehicleApi.getApi(this).pauseAtCurrentLocation();
}

Fixed version (ground truth):
/** 
 * @deprecated Use {@link ControlApi#pauseAtCurrentLocation()} instead.
 */
public void pauseAtCurrentLocation(){
  ControlApi.getApi(this).pauseAtCurrentLocation();
}
Program: 94772
Project: 94772
Buggy source:
/** 
 * @deprecated Use {@link VehicleApi#sendGuidedPoint(LatLong,boolean)} instead.
 */
public void sendGuidedPoint(LatLong point,boolean force){
  VehicleApi.getApi(this).sendGuidedPoint(point,force);
}

Fixed version (ground truth):
/** 
 * @deprecated Use {@link ControlApi#goTo(LatLong,boolean)} instead.
 */
public void sendGuidedPoint(LatLong point,boolean force){
  ControlApi.getApi(this).goTo(point,force);
}
Program: 94773
Project: 94773
Buggy source:
/** 
 * @deprecated Use {@link VehicleApi#takeoff(double)} instead.
 */
public void doGuidedTakeoff(double altitude){
  VehicleApi.getApi(this).takeoff(altitude);
}

Fixed version (ground truth):
/** 
 * @deprecated Use {@link ControlApi#takeoff(double)} instead.
 */
public void doGuidedTakeoff(double altitude){
  ControlApi.getApi(this).takeoff(altitude);
}
Program: 94774
Project: 94774
Buggy source:
/** 
 * @deprecated Use {@link VehicleApi#setGuidedAltitude(double)} instead.
 */
public void setGuidedAltitude(double altitude){
  VehicleApi.getApi(this).setGuidedAltitude(altitude);
}

Fixed version (ground truth):
/** 
 * @deprecated Use {@link ControlApi#climbTo(double)} instead.
 */
public void setGuidedAltitude(double altitude){
  ControlApi.getApi(this).climbTo(altitude);
}
Program: 94775
Project: 94775
Buggy source:
public void onArmButtonTap(View view){
  State vehicleState=this.drone.getAttribute(AttributeType.STATE);
  if (vehicleState.isFlying()) {
    VehicleApi.getApi(this.drone).setVehicleMode(VehicleMode.COPTER_LAND,new SimpleCommandListener(){
      @Override public void onError(      int executionError){
        alertUser("String_Node_Str");
      }
      @Override public void onTimeout(){
        alertUser("String_Node_Str");
      }
    }
);
  }
 else   if (vehicleState.isArmed()) {
    VehicleApi.getApi(this.drone).takeoff(10,new AbstractCommandListener(){
      @Override public void onSuccess(){
        alertUser("String_Node_Str");
      }
      @Override public void onError(      int i){
        alertUser("String_Node_Str");
      }
      @Override public void onTimeout(){
        alertUser("String_Node_Str");
      }
    }
);
  }
 else   if (!vehicleState.isConnected()) {
    alertUser("String_Node_Str");
  }
 else {
    VehicleApi.getApi(this.drone).arm(true,false,new SimpleCommandListener(){
      @Override public void onError(      int executionError){
        alertUser("String_Node_Str");
      }
      @Override public void onTimeout(){
        alertUser("String_Node_Str");
      }
    }
);
  }
}

Fixed version (ground truth):
public void onArmButtonTap(View view){
  State vehicleState=this.drone.getAttribute(AttributeType.STATE);
  if (vehicleState.isFlying()) {
    VehicleApi.getApi(this.drone).setVehicleMode(VehicleMode.COPTER_LAND,new SimpleCommandListener(){
      @Override public void onError(      int executionError){
        alertUser("String_Node_Str");
      }
      @Override public void onTimeout(){
        alertUser("String_Node_Str");
      }
    }
);
  }
 else   if (vehicleState.isArmed()) {
    ControlApi.getApi(this.drone).takeoff(10,new AbstractCommandListener(){
      @Override public void onSuccess(){
        alertUser("String_Node_Str");
      }
      @Override public void onError(      int i){
        alertUser("String_Node_Str");
      }
      @Override public void onTimeout(){
        alertUser("String_Node_Str");
      }
    }
);
  }
 else   if (!vehicleState.isConnected()) {
    alertUser("String_Node_Str");
  }
 else {
    VehicleApi.getApi(this.drone).arm(true,false,new SimpleCommandListener(){
      @Override public void onError(      int executionError){
        alertUser("String_Node_Str");
      }
      @Override public void onTimeout(){
        alertUser("String_Node_Str");
      }
    }
);
  }
}
Program: 94776
Project: 94776
Buggy source:
public boolean areVersionsSet(){
  return !TextUtils.isEmpty(vehicleVersion.get()) && !TextUtils.isEmpty(pixhawkVersion.get()) && !TextUtils.isEmpty(gimbalVersion.get());
}

Fixed version (ground truth):
public boolean areVersionsSet(){
  return !TextUtils.isEmpty(vehicleVersion.get()) && !TextUtils.isEmpty(pixhawkVersion.get());
}
Program: 94777
Project: 94777
Buggy source:
public int getControllerMode(){
  return controllerMode;
}

Fixed version (ground truth):
@ControllerMode public int getControllerMode(){
  return controllerMode;
}
Program: 94778
Project: 94778
Buggy source:
protected SoloState(Parcel in){
  this.wifiSsid=in.readString();
  this.wifiPassword=in.readString();
  this.controllerVersion=in.readString();
  this.controllerMode=in.readInt();
  this.controllerFirmwareVersion=in.readString();
  this.vehicleVersion=in.readString();
  this.autopilotVersion=in.readString();
  this.isEUTxPowerCompliant=in.readByte() != 0;
  final int buttonCount=in.readInt();
  this.buttonSettings=new SparseArray<>(buttonCount);
  for (int i=0; i < buttonCount; i++) {
    final int dataSize=in.readInt();
    if (dataSize == 0)     continue;
    final ByteBuffer dataBuffer=ByteBuffer.allocate(dataSize);
    in.readByteArray(dataBuffer.array());
    final SoloButtonSetting button=(SoloButtonSetting)TLVMessageParser.parseTLVPacket(dataBuffer);
    buttonSettings.put(button.getButton(),button);
  }
  this.gimbalVersion=in.readString();
}

Fixed version (ground truth):
protected SoloState(Parcel in){
  this.wifiSsid=in.readString();
  this.wifiPassword=in.readString();
  this.controllerVersion=in.readString();
  this.controllerFirmwareVersion=in.readString();
  this.vehicleVersion=in.readString();
  this.autopilotVersion=in.readString();
  this.isEUTxPowerCompliant=in.readByte() != 0;
  final int buttonCount=in.readInt();
  this.buttonSettings=new SparseArray<>(buttonCount);
  for (int i=0; i < buttonCount; i++) {
    final int dataSize=in.readInt();
    if (dataSize == 0)     continue;
    final ByteBuffer dataBuffer=ByteBuffer.allocate(dataSize);
    in.readByteArray(dataBuffer.array());
    final SoloButtonSetting button=(SoloButtonSetting)TLVMessageParser.parseTLVPacket(dataBuffer);
    buttonSettings.put(button.getButton(),button);
  }
  this.gimbalVersion=in.readString();
  @ControllerMode final int tempMode=in.readInt();
  this.controllerMode=tempMode;
}
Program: 94779
Project: 94779
Buggy source:
@Override public void writeToParcel(Parcel dest,int flags){
  dest.writeString(this.wifiSsid);
  dest.writeString(this.wifiPassword);
  dest.writeString(this.controllerVersion);
  dest.writeInt(this.controllerMode);
  dest.writeString(this.controllerFirmwareVersion);
  dest.writeString(this.vehicleVersion);
  dest.writeString(this.autopilotVersion);
  dest.writeByte(isEUTxPowerCompliant ? (byte)1 : (byte)0);
  final int buttonCount=buttonSettings.size();
  dest.writeInt(buttonCount);
  for (int i=0; i < buttonCount; i++) {
    final SoloButtonSetting buttonSetting=buttonSettings.valueAt(i);
    if (buttonSetting == null) {
      dest.writeInt(0);
      continue;
    }
    final byte[] buttonData=buttonSetting.toBytes();
    dest.writeInt(buttonData.length);
    dest.writeByteArray(buttonData);
  }
  dest.writeString(this.gimbalVersion);
}

Fixed version (ground truth):
@Override public void writeToParcel(Parcel dest,int flags){
  dest.writeString(this.wifiSsid);
  dest.writeString(this.wifiPassword);
  dest.writeString(this.controllerVersion);
  dest.writeString(this.controllerFirmwareVersion);
  dest.writeString(this.vehicleVersion);
  dest.writeString(this.autopilotVersion);
  dest.writeByte(isEUTxPowerCompliant ? (byte)1 : (byte)0);
  final int buttonCount=buttonSettings.size();
  dest.writeInt(buttonCount);
  for (int i=0; i < buttonCount; i++) {
    final SoloButtonSetting buttonSetting=buttonSettings.valueAt(i);
    if (buttonSetting == null) {
      dest.writeInt(0);
      continue;
    }
    final byte[] buttonData=buttonSetting.toBytes();
    dest.writeInt(buttonData.length);
    dest.writeByteArray(buttonData);
  }
  dest.writeString(this.gimbalVersion);
  dest.writeInt(this.controllerMode);
}
Program: 94780
Project: 94780
Buggy source:
@Override public void onControllerModeUpdated(){
  final Bundle eventInfo=new Bundle();
  eventInfo.putInt(SoloEventExtras.EXTRA_SOLO_CONTROLLER_MODE,soloComp.getControllerMode());
  notifyDroneAttributeEvent(SoloEvents.SOLO_CONTROLLER_MODE,eventInfo,true);
}

Fixed version (ground truth):
@Override public void onControllerModeUpdated(){
  final Bundle eventInfo=new Bundle();
  eventInfo.putInt(SoloEventExtras.EXTRA_SOLO_CONTROLLER_MODE,soloComp.getControllerMode());
  notifyDroneAttributeEvent(SoloEvents.SOLO_CONTROLLER_MODE_UPDATED,eventInfo,true);
}
Program: 94781
Project: 94781
Buggy source:
public int getControllerMode(){
  return artooMgr.getControllerMode();
}

Fixed version (ground truth):
@SoloControllerMode.ControllerMode public int getControllerMode(){
  return artooMgr.getControllerMode();
}
Program: 94782
Project: 94782
Buggy source:
private void loadCurrentControllerMode(){
  postAsyncTask(getArtooMode());
}

Fixed version (ground truth):
private void loadCurrentControllerMode(){
  postAsyncTask(artooModeRetriever);
}
Program: 94783
Project: 94783
Buggy source:
public static SoloState getSoloLinkState(DroneManager droneManager){
  if (droneManager == null || !droneManager.isCompanionComputerEnabled())   return null;
  final SoloComp soloComp=droneManager.getSoloComp();
  final Pair<String,String> wifiSettings=soloComp.getWifiSettings();
  return new SoloState(soloComp.getAutopilotVersion(),soloComp.getControllerFirmwareVersion(),soloComp.getControllerVersion(),soloComp.getControllerMode(),soloComp.getVehicleVersion(),wifiSettings.second,wifiSettings.first,soloComp.isEUTxPowerCompliant(),soloComp.getButtonSettings(),soloComp.getGimbalVersion());
}

Fixed version (ground truth):
public static SoloState getSoloLinkState(DroneManager droneManager){
  if (droneManager == null || !droneManager.isCompanionComputerEnabled())   return null;
  final SoloComp soloComp=droneManager.getSoloComp();
  final Pair<String,String> wifiSettings=soloComp.getWifiSettings();
  return new SoloState(soloComp.getAutopilotVersion(),soloComp.getControllerFirmwareVersion(),soloComp.getControllerVersion(),soloComp.getVehicleVersion(),wifiSettings.second,wifiSettings.first,soloComp.isEUTxPowerCompliant(),soloComp.getButtonSettings(),soloComp.getGimbalVersion(),soloComp.getControllerMode());
}
Program: 94784
Project: 94784
Buggy source:
@Override public void onDroneEvent(DroneInterfaces.DroneEventsType event,MavLinkDrone drone){
switch (event) {
case HEARTBEAT_FIRST:
case CONNECTED:
    if (isCompanionComputerEnabled()) {
      if (!soloComp.isConnected()) {
        soloComp.start();
        return;
      }
 else {
        soloComp.refreshState();
      }
    }
  event=DroneInterfaces.DroneEventsType.CONNECTED;
break;
case HEARTBEAT_TIMEOUT:
if (isCompanionComputerEnabled() && soloComp.isConnected()) {
handler.postDelayed(disconnectSoloCompTask,HeartBeat.HEARTBEAT_NORMAL_TIMEOUT);
}
break;
case HEARTBEAT_RESTORED:
if (isCompanionComputerEnabled()) {
handler.removeCallbacks(disconnectSoloCompTask);
if (!soloComp.isConnected()) soloComp.start();
 else {
soloComp.refreshState();
}
}
break;
case DISCONNECTED:
if (isCompanionComputerEnabled()) {
if (soloComp.isConnected()) {
soloComp.stop();
return;
}
}
break;
}
if (connectedApps.isEmpty()) return;
for (DroneEventsListener droneEventsListener : connectedApps.values()) {
droneEventsListener.onDroneEvent(event,drone);
}
}

Fixed version (ground truth):
@Override public void onDroneEvent(DroneInterfaces.DroneEventsType event,MavLinkDrone drone){
switch (event) {
case HEARTBEAT_FIRST:
case CONNECTED:
    if (isCompanionComputerEnabled()) {
      if (!soloComp.isConnected()) {
        soloComp.start();
        return;
      }
    }
  event=DroneInterfaces.DroneEventsType.CONNECTED;
break;
case HEARTBEAT_TIMEOUT:
if (isCompanionComputerEnabled() && soloComp.isConnected()) {
handler.postDelayed(disconnectSoloCompTask,HeartBeat.HEARTBEAT_NORMAL_TIMEOUT);
}
break;
case HEARTBEAT_RESTORED:
if (isCompanionComputerEnabled()) {
handler.removeCallbacks(disconnectSoloCompTask);
if (!soloComp.isConnected()) soloComp.start();
 else {
soloComp.refreshState();
}
}
break;
case DISCONNECTED:
if (isCompanionComputerEnabled()) {
if (soloComp.isConnected()) {
soloComp.stop();
return;
}
}
break;
}
if (connectedApps.isEmpty()) return;
for (DroneEventsListener droneEventsListener : connectedApps.values()) {
droneEventsListener.onDroneEvent(event,drone);
}
}
Program: 94785
Project: 94785
Buggy source:
@Override public void refreshState(){
  Timber.d("String_Node_Str");
  startVideoManager();
  loadSololinkWifiInfo();
  refreshControllerVersions();
  loadCurrentEUTxPowerComplianceMode();
  updateControllerModeIfPossible();
}

Fixed version (ground truth):
@Override public void refreshState(){
  Timber.d("String_Node_Str");
  startVideoManager();
  loadSololinkWifiInfo();
  refreshControllerVersions();
  loadCurrentEUTxPowerComplianceMode();
}
Program: 94786
Project: 94786
Buggy source:
private void onVersionsUpdated(){
  if (linkListener != null && areVersionsSet())   linkListener.onVersionsUpdated();
  updateControllerModeIfPossible();
}

Fixed version (ground truth):
private void onVersionsUpdated(){
  if (linkListener != null && areVersionsSet())   linkListener.onVersionsUpdated();
}
Program: 94787
Project: 94787
Buggy source:
@Override public void executeAction(Action action,ICommandListener listener) throws RemoteException {
  if (action == null)   return;
  final String type=action.getType();
  if (type == null)   return;
  Bundle data=action.getData();
  if (data != null)   data.setClassLoader(context.getClassLoader());
switch (type) {
case ConnectionActions.ACTION_CONNECT:
    ConnectionParameter parameter=data.getParcelable(ConnectionActions.EXTRA_CONNECT_PARAMETER);
  connect(parameter);
break;
case ConnectionActions.ACTION_DISCONNECT:
disconnect();
break;
case SoloCameraActions.ACTION_START_VIDEO_STREAM:
{
final Surface videoSurface=data.getParcelable(SoloCameraActions.EXTRA_VIDEO_DISPLAY);
final String videoTag=data.getString(SoloCameraActions.EXTRA_VIDEO_TAG,"String_Node_Str");
SoloApiUtils.startVideoStream(getDroneManager(),ownerId + videoTag,videoSurface,listener);
break;
}
case SoloCameraActions.ACTION_STOP_VIDEO_STREAM:
{
final String videoTag=data.getString(SoloCameraActions.EXTRA_VIDEO_TAG,"String_Node_Str");
SoloApiUtils.stopVideoStream(getDroneManager(),ownerId + videoTag,listener);
break;
}
case MissionActions.ACTION_BUILD_COMPLEX_MISSION_ITEM:
final MavLinkDrone drone=droneMgr == null ? null : droneMgr.getDrone();
CommonApiUtils.buildComplexMissionItem(drone,data);
break;
default :
droneMgr.executeAsyncAction(action,listener);
break;
}
}

Fixed version (ground truth):
@Override public void executeAction(Action action,ICommandListener listener) throws RemoteException {
  if (action == null)   return;
  final String type=action.getType();
  if (type == null)   return;
  Bundle data=action.getData();
  if (data != null)   data.setClassLoader(context.getClassLoader());
switch (type) {
case ConnectionActions.ACTION_CONNECT:
    ConnectionParameter parameter=data.getParcelable(ConnectionActions.EXTRA_CONNECT_PARAMETER);
  connect(parameter);
break;
case ConnectionActions.ACTION_DISCONNECT:
disconnect();
break;
case SoloCameraActions.ACTION_START_VIDEO_STREAM:
{
final Surface videoSurface=data.getParcelable(SoloCameraActions.EXTRA_VIDEO_DISPLAY);
final String videoTag=data.getString(SoloCameraActions.EXTRA_VIDEO_TAG,"String_Node_Str");
SoloApiUtils.startVideoStream(getDroneManager(),ownerId,videoTag,videoSurface,listener);
break;
}
case SoloCameraActions.ACTION_STOP_VIDEO_STREAM:
{
final String videoTag=data.getString(SoloCameraActions.EXTRA_VIDEO_TAG,"String_Node_Str");
SoloApiUtils.stopVideoStream(getDroneManager(),ownerId,videoTag,listener);
break;
}
case MissionActions.ACTION_BUILD_COMPLEX_MISSION_ITEM:
final MavLinkDrone drone=droneMgr == null ? null : droneMgr.getDrone();
CommonApiUtils.buildComplexMissionItem(drone,data);
break;
default :
droneMgr.executeAsyncAction(action,listener);
break;
}
}
Program: 94788
Project: 94788
Buggy source:
public void disconnect(String appId) throws ConnectionException {
  if (TextUtils.isEmpty(appId))   return;
  Log.d(TAG,"String_Node_Str" + appId);
  DroneEventsListener listener=connectedApps.remove(appId);
  if (listener != null) {
    mavClient.removeLoggingFile(appId);
    listener.onDroneEvent(DroneInterfaces.DroneEventsType.DISCONNECTED,drone);
    notifyDisconnected(appId,listener);
  }
  if (mavClient.isConnected() && connectedApps.isEmpty()) {
    mavClient.closeConnection();
  }
}

Fixed version (ground truth):
public void disconnect(String appId) throws ConnectionException {
  if (TextUtils.isEmpty(appId))   return;
  if (isCompanionComputerEnabled())   soloComp.tryStoppingVideoStream(appId);
  Log.d(TAG,"String_Node_Str" + appId);
  DroneEventsListener listener=connectedApps.remove(appId);
  if (listener != null) {
    mavClient.removeLoggingFile(appId);
    listener.onDroneEvent(DroneInterfaces.DroneEventsType.DISCONNECTED,drone);
    notifyDisconnected(appId,listener);
  }
  if (mavClient.isConnected() && connectedApps.isEmpty()) {
    mavClient.closeConnection();
  }
}
Program: 94789
Project: 94789
Buggy source:
public void stopVideoStream(String ownerId,final ICommandListener listener){
  Timber.d("String_Node_Str",ownerId,videoOwnerId.get());
  if (TextUtils.isEmpty(ownerId)) {
    Timber.w("String_Node_Str");
    postErrorEvent(CommandExecutionError.COMMAND_DENIED,listener);
    return;
  }
  final String currentVideoOwner=videoOwnerId.get();
  if (NO_VIDEO_OWNER.equals(currentVideoOwner)) {
    Timber.d("String_Node_Str");
    postSuccessEvent(listener);
    return;
  }
  if (ownerId.equals(currentVideoOwner) && videoOwnerId.compareAndSet(currentVideoOwner,NO_VIDEO_OWNER)) {
    Timber.d("String_Node_Str",videoOwnerId.get());
    artooMgr.stopDecoding(new DecoderListener(){
      @Override public void onDecodingStarted(){
      }
      @Override public void onDecodingError(){
        postSuccessEvent(listener);
      }
      @Override public void onDecodingEnded(){
        postSuccessEvent(listener);
      }
    }
);
    artooMgr.stopVideoManager();
  }
 else {
    postErrorEvent(CommandExecutionError.COMMAND_DENIED,listener);
  }
}

Fixed version (ground truth):
public void stopVideoStream(String appId,String currentVideoTag,final ICommandListener listener){
  Timber.d("String_Node_Str",appId,videoOwnerId.get());
  if (TextUtils.isEmpty(appId)) {
    Timber.w("String_Node_Str");
    postErrorEvent(CommandExecutionError.COMMAND_DENIED,listener);
    return;
  }
  final String currentVideoOwner=videoOwnerId.get();
  if (NO_VIDEO_OWNER.equals(currentVideoOwner)) {
    Timber.d("String_Node_Str");
    postSuccessEvent(listener);
    return;
  }
  if (currentVideoTag == null)   currentVideoTag="String_Node_Str";
  if (appId.equals(currentVideoOwner) && currentVideoTag.equals(videoTagRef.get()) && videoOwnerId.compareAndSet(currentVideoOwner,NO_VIDEO_OWNER)) {
    videoTagRef.set("String_Node_Str");
    Timber.d("String_Node_Str",currentVideoOwner);
    artooMgr.stopDecoding(new DecoderListener(){
      @Override public void onDecodingStarted(){
      }
      @Override public void onDecodingError(){
        postSuccessEvent(listener);
      }
      @Override public void onDecodingEnded(){
        postSuccessEvent(listener);
      }
    }
);
    artooMgr.stopVideoManager();
  }
 else {
    postErrorEvent(CommandExecutionError.COMMAND_DENIED,listener);
  }
}
Program: 94790
Project: 94790
Buggy source:
public void start(){
  if (!isAvailable()) {
    return;
  }
  artooMgr.start(this);
  soloLinkMgr.start(this);
}

Fixed version (ground truth):
public void start(){
  if (!isAvailable()) {
    return;
  }
  resetVideoOwner();
  artooMgr.start(this);
  soloLinkMgr.start(this);
}
Program: 94791
Project: 94791
Buggy source:
private void resetVideoOwner(){
  Timber.d("String_Node_Str",videoOwnerId.get());
  videoOwnerId.set(NO_VIDEO_OWNER);
  artooMgr.stopDecoding(null);
}

Fixed version (ground truth):
private void resetVideoOwner(){
  Timber.d("String_Node_Str",videoTagRef.get(),videoOwnerId.get());
  videoTagRef.set("String_Node_Str");
  videoOwnerId.set(NO_VIDEO_OWNER);
  artooMgr.stopDecoding(null);
}
Program: 94792
Project: 94792
Buggy source:
public void stop(){
  artooMgr.stop();
  soloLinkMgr.stop();
}

Fixed version (ground truth):
public void stop(){
  resetVideoOwner();
  artooMgr.stop();
  soloLinkMgr.stop();
}
Program: 94793
Project: 94793
Buggy source:
public void startVideoStream(String ownerId,Surface videoSurface,final ICommandListener listener){
  Timber.d("String_Node_Str",ownerId,videoOwnerId.get());
  if (TextUtils.isEmpty(ownerId)) {
    postErrorEvent(CommandExecutionError.COMMAND_DENIED,listener);
    return;
  }
  if (videoSurface == null) {
    postErrorEvent(CommandExecutionError.COMMAND_FAILED,listener);
    return;
  }
  if (ownerId.equals(videoOwnerId.get())) {
    postSuccessEvent(listener);
    return;
  }
  if (videoOwnerId.compareAndSet(NO_VIDEO_OWNER,ownerId)) {
    artooMgr.startVideoManager();
    Timber.d("String_Node_Str");
    artooMgr.startDecoding(videoSurface,new DecoderListener(){
      @Override public void onDecodingStarted(){
        Timber.d("String_Node_Str");
        postSuccessEvent(listener);
      }
      @Override public void onDecodingError(){
        Timber.d("String_Node_Str");
        postErrorEvent(CommandExecutionError.COMMAND_FAILED,listener);
        resetVideoOwner();
      }
      @Override public void onDecodingEnded(){
        Timber.d("String_Node_Str");
        resetVideoOwner();
      }
    }
);
  }
 else {
    postErrorEvent(CommandExecutionError.COMMAND_DENIED,listener);
  }
}

Fixed version (ground truth):
public void startVideoStream(String appId,String newVideoTag,Surface videoSurface,final ICommandListener listener){
  Timber.d("String_Node_Str",appId,videoOwnerId.get());
  if (TextUtils.isEmpty(appId)) {
    postErrorEvent(CommandExecutionError.COMMAND_DENIED,listener);
    return;
  }
  if (videoSurface == null) {
    postErrorEvent(CommandExecutionError.COMMAND_FAILED,listener);
    return;
  }
  if (newVideoTag == null)   newVideoTag="String_Node_Str";
  if (appId.equals(videoOwnerId.get())) {
    String currentVideoTag=videoTagRef.get();
    if (currentVideoTag == null)     currentVideoTag="String_Node_Str";
    if (newVideoTag.equals(currentVideoTag)) {
      postSuccessEvent(listener);
      return;
    }
  }
  if (videoOwnerId.compareAndSet(NO_VIDEO_OWNER,appId)) {
    videoTagRef.set(newVideoTag);
    artooMgr.startVideoManager();
    Timber.d("String_Node_Str");
    artooMgr.startDecoding(videoSurface,new DecoderListener(){
      @Override public void onDecodingStarted(){
        Timber.d("String_Node_Str");
        postSuccessEvent(listener);
      }
      @Override public void onDecodingError(){
        Timber.d("String_Node_Str");
        postErrorEvent(CommandExecutionError.COMMAND_FAILED,listener);
        resetVideoOwner();
      }
      @Override public void onDecodingEnded(){
        Timber.d("String_Node_Str");
        resetVideoOwner();
      }
    }
);
  }
 else {
    postErrorEvent(CommandExecutionError.COMMAND_DENIED,listener);
  }
}
Program: 94794
Project: 94794
Buggy source:
public static void stopVideoStream(DroneManager droneManager,String ownerId,ICommandListener listener){
  if (!isSoloLinkFeatureAvailable(droneManager,listener))   return;
  final SoloComp soloComp=droneManager.getSoloComp();
  soloComp.stopVideoStream(ownerId,listener);
}

Fixed version (ground truth):
public static void stopVideoStream(DroneManager droneManager,String appId,String videoTag,ICommandListener listener){
  if (!isSoloLinkFeatureAvailable(droneManager,listener))   return;
  final SoloComp soloComp=droneManager.getSoloComp();
  soloComp.stopVideoStream(appId,videoTag,listener);
}
Program: 94795
Project: 94795
Buggy source:
public static void startVideoStream(DroneManager droneManager,String ownerId,Surface videoSurface,ICommandListener listener){
  if (!isSoloLinkFeatureAvailable(droneManager,listener))   return;
  final SoloComp soloComp=droneManager.getSoloComp();
  soloComp.startVideoStream(ownerId,videoSurface,listener);
}

Fixed version (ground truth):
public static void startVideoStream(DroneManager droneManager,String appId,String videoTag,Surface videoSurface,ICommandListener listener){
  if (!isSoloLinkFeatureAvailable(droneManager,listener))   return;
  final SoloComp soloComp=droneManager.getSoloComp();
  soloComp.startVideoStream(appId,videoTag,videoSurface,listener);
}
Program: 94796
Project: 94796
Buggy source:
public void stopDecoding(DecoderListener listener){
  Timber.i("String_Node_Str");
  this.decoderListenerRef.set(listener);
  if (!isDecoding.get()) {
    if (listener != null) {
      notifyDecodingEnded();
    }
  }
 else {
    if (decodedFirstFrame.get()) {
      if (processInputData.compareAndSet(true,false))       sendCompletionFlag.set(true);
    }
 else {
      handler.post(stopSafely);
    }
  }
}

Fixed version (ground truth):
public void stopDecoding(DecoderListener listener){
  Timber.i("String_Node_Str");
  this.decoderListenerRef.set(listener);
  if (!isDecoding.get()) {
    if (listener != null) {
      notifyDecodingEnded();
    }
  }
 else {
    if (decodedFirstFrame.get()) {
      if (processInputData.compareAndSet(true,false)) {
        sendCompletionFlag.set(!processNALUChunk(naluChunkAssembler.getEndOfStream()));
      }
    }
 else {
      handler.post(stopSafely);
    }
  }
}
Program: 94797
Project: 94797
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 ArduCopter(context,mavClient,dpHandler,dpPrefs,new AndroidApWarningParser(),new LogMessageListener(){
    @Override public void onMessageLogged(    int logLevel,    String message){
    }
  }
);
}

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 ArduCopter(context,mavClient,dpHandler,dpPrefs,new AndroidApWarningParser(),new LogMessageListener(){
    @Override public void onMessageLogged(    int logLevel,    String message){
    }
  }
,new DroneInterfaces.AttributeEventListener(){
    @Override public void onAttributeEvent(    String attributeEvent,    Bundle eventInfo){
    }
  }
);
}
Program: 94798
Project: 94798
Buggy source:
@Override public void executeAction(Action action,ICommandListener listener) throws RemoteException {
  if (action == null)   return;
  final String type=action.getType();
  if (type == null)   return;
  Bundle data=action.getData();
  if (data != null)   data.setClassLoader(context.getClassLoader());
switch (type) {
case ConnectionActions.ACTION_CONNECT:
    ConnectionParameter parameter=data.getParcelable(ConnectionActions.EXTRA_CONNECT_PARAMETER);
  connect(parameter);
break;
case ConnectionActions.ACTION_DISCONNECT:
disconnect();
break;
case SoloLinkActions.ACTION_START_VIDEO_STREAM:
{
final Surface videoSurface=data.getParcelable(SoloLinkActions.EXTRA_VIDEO_DISPLAY);
final String videoTag=data.getString(SoloLinkActions.EXTRA_VIDEO_TAG,"String_Node_Str");
SoloLinkApiUtils.startVideoStream(getDroneManager(),ownerId + videoTag,videoSurface,listener);
break;
}
case SoloLinkActions.ACTION_STOP_VIDEO_STREAM:
{
final String videoTag=data.getString(SoloLinkActions.EXTRA_VIDEO_TAG,"String_Node_Str");
SoloLinkApiUtils.stopVideoStream(getDroneManager(),ownerId + videoTag,listener);
break;
}
default :
droneMgr.executeAsyncAction(action,listener);
break;
}
}

Fixed version (ground truth):
@Override public void executeAction(Action action,ICommandListener listener) throws RemoteException {
  if (action == null)   return;
  final String type=action.getType();
  if (type == null)   return;
  Bundle data=action.getData();
  if (data != null)   data.setClassLoader(context.getClassLoader());
switch (type) {
case ConnectionActions.ACTION_CONNECT:
    ConnectionParameter parameter=data.getParcelable(ConnectionActions.EXTRA_CONNECT_PARAMETER);
  connect(parameter);
break;
case ConnectionActions.ACTION_DISCONNECT:
disconnect();
break;
case SoloLinkActions.ACTION_START_VIDEO_STREAM:
{
final Surface videoSurface=data.getParcelable(SoloLinkActions.EXTRA_VIDEO_DISPLAY);
final String videoTag=data.getString(SoloLinkActions.EXTRA_VIDEO_TAG,"String_Node_Str");
SoloLinkApiUtils.startVideoStream(getDroneManager(),ownerId + videoTag,videoSurface,listener);
break;
}
case SoloLinkActions.ACTION_STOP_VIDEO_STREAM:
{
final String videoTag=data.getString(SoloLinkActions.EXTRA_VIDEO_TAG,"String_Node_Str");
SoloLinkApiUtils.stopVideoStream(getDroneManager(),ownerId + videoTag,listener);
break;
}
case MissionActions.ACTION_BUILD_COMPLEX_MISSION_ITEM:
final MavLinkDrone drone=droneMgr == null ? null : droneMgr.getDrone();
CommonApiUtils.buildComplexMissionItem(drone,data);
break;
default :
droneMgr.executeAsyncAction(action,listener);
break;
}
}
Program: 94801
Project: 94801
Buggy source:
private void handleHeartbeatType(int type){
switch (type) {
case MAV_TYPE.MAV_TYPE_FIXED_WING:
    droneMgr.onVehicleTypeReceived(FirmwareType.ARDU_PLANE);
  break;
case MAV_TYPE.MAV_TYPE_GROUND_ROVER:
case MAV_TYPE.MAV_TYPE_SURFACE_BOAT:
droneMgr.onVehicleTypeReceived(FirmwareType.ARDU_ROVER);
break;
}
}

Fixed version (ground truth):
private void handleHeartbeatType(int type){
switch (type) {
case MAV_TYPE.MAV_TYPE_FIXED_WING:
    droneMgr.onVehicleTypeReceived(FirmwareType.ARDU_PLANE);
  break;
case MAV_TYPE.MAV_TYPE_GENERIC:
case MAV_TYPE.MAV_TYPE_QUADROTOR:
case MAV_TYPE.MAV_TYPE_COAXIAL:
case MAV_TYPE.MAV_TYPE_HELICOPTER:
case MAV_TYPE.MAV_TYPE_HEXAROTOR:
case MAV_TYPE.MAV_TYPE_OCTOROTOR:
case MAV_TYPE.MAV_TYPE_TRICOPTER:
droneMgr.onVehicleTypeReceived(FirmwareType.ARDU_COPTER);
break;
case MAV_TYPE.MAV_TYPE_GROUND_ROVER:
case MAV_TYPE.MAV_TYPE_SURFACE_BOAT:
droneMgr.onVehicleTypeReceived(FirmwareType.ARDU_ROVER);
break;
}
}
Program: 94802
Project: 94802
Buggy source:
@Override public Bundle getAttribute(String type) throws RemoteException {
  final DroneAttribute attribute=droneMgr.getAttribute(type);
  if (attribute == null)   return null;
  Bundle carrier=new Bundle();
  carrier.putParcelable(type,attribute);
  return carrier;
}

Fixed version (ground truth):
@Override public Bundle getAttribute(String type) throws RemoteException {
  if (droneMgr == null)   return null;
  final DroneAttribute attribute=droneMgr.getAttribute(type);
  if (attribute == null)   return null;
  Bundle carrier=new Bundle();
  carrier.putParcelable(type,attribute);
  return carrier;
}
Program: 94803
Project: 94803
Buggy source:
@Override public DroneAttribute getAttribute(String attributeType){
  if (drone == null)   return null;
switch (attributeType) {
case AttributeType.FOLLOW_STATE:
    return CommonApiUtils.getFollowState(getFollowMe());
case AttributeType.CAMERA:
  return CommonApiUtils.getCameraProxy(drone,cameraDetails);
default :
return drone.getAttribute(attributeType);
}
}

Fixed version (ground truth):
@Override public DroneAttribute getAttribute(String attributeType){
  if (drone == null)   return null;
switch (attributeType) {
case AttributeType.FOLLOW_STATE:
    return CommonApiUtils.getFollowState(followMe);
case AttributeType.CAMERA:
  return CommonApiUtils.getCameraProxy(drone,cameraDetails);
default :
return drone.getAttribute(attributeType);
}
}
Program: 94805
Project: 94805
Buggy source:
public State(MavLinkDrone myDrone,Clock clock,Handler handler,AutopilotWarningParser warningParser){
  super(myDrone);
  this.clock=clock;
  this.handler=handler;
  this.warningParser=warningParser;
  this.errorId=warningParser.getDefaultWarning();
  resetFlightStartTime();
}

Fixed version (ground truth):
public State(MavLinkDrone myDrone,Handler handler,AutopilotWarningParser warningParser){
  super(myDrone);
  this.handler=handler;
  this.warningParser=warningParser;
  this.errorId=warningParser.getDefaultWarning();
  resetFlightStartTime();
}
Program: 94806
Project: 94806
Buggy source:
private void resetFlightStartTime(){
  startTime=clock.elapsedRealtime();
}

Fixed version (ground truth):
private void resetFlightStartTime(){
  startTime=SystemClock.elapsedRealtime();
}
Program: 94807
Project: 94807
Buggy source:
@Override public void onConnected(){
  if (isConnected()) {
    drone.notifyDroneEvent(DroneInterfaces.DroneEventsType.CONNECTED);
  }
}

Fixed version (ground truth):
@Override public void onConnected(){
  if (isConnected()) {
    notifyDroneEvent(DroneInterfaces.DroneEventsType.CONNECTED);
  }
}
Program: 94808
Project: 94808
Buggy source:
@Override public void onDisconnected(){
  drone.notifyDroneEvent(DroneInterfaces.DroneEventsType.DISCONNECTED);
}

Fixed version (ground truth):
@Override public void onDisconnected(){
  notifyDroneEvent(DroneInterfaces.DroneEventsType.DISCONNECTED);
}
Program: 94809
Project: 94809
Buggy source:
/** 
 * Causes the Runnable to be added to the message queue.
 * @param action Runnabl that will be executed.
 */
public void post(Runnable action){
  if (action == null)   return;
  handler.post(action);
}

Fixed version (ground truth):
/** 
 * Causes the Runnable to be added to the message queue.
 * @param action Runnabl that will be executed.
 */
public void post(Runnable action){
  if (handler == null || action == null)   return;
  handler.post(action);
}
Program: 94810
Project: 94810
Buggy source:
@Override public void run(){
  if (drone.getState().getMode() != ApmModes.ROTOR_AUTO) {
    if (forceModeChange) {
      changeVehicleMode(drone,VehicleMode.COPTER_AUTO,new AbstractCommandListener(){
        @Override public void onSuccess(){
          sendCommandRunnable.run();
        }
        @Override public void onError(        int executionError){
          postErrorEvent(executionError,listener);
        }
        @Override public void onTimeout(){
          postTimeoutEvent(listener);
        }
      }
);
    }
 else {
      postErrorEvent(CommandExecutionError.COMMAND_DENIED,listener);
    }
    return;
  }
 else {
    sendCommandRunnable.run();
  }
}

Fixed version (ground truth):
@Override public void run(){
  if (drone.getState().getMode() != ApmModes.ROTOR_AUTO) {
    if (forceModeChange) {
      changeVehicleMode(drone,VehicleMode.COPTER_AUTO,new AbstractCommandListener(){
        @Override public void onSuccess(){
          sendCommandRunnable.run();
        }
        @Override public void onError(        int executionError){
          postErrorEvent(executionError,listener);
        }
        @Override public void onTimeout(){
          postTimeoutEvent(listener);
        }
      }
);
    }
 else {
      postErrorEvent(CommandExecutionError.COMMAND_FAILED,listener);
    }
    return;
  }
 else {
    sendCommandRunnable.run();
  }
}
Program: 94812
Project: 94812
Buggy source:
private void notifyAttributeUpdate(String attributeEvent,Bundle extrasBundle){
  if (observersList.isEmpty())   return;
  if (attributeEvent != null) {
    for (    IObserver observer : observersList) {
      try {
        observer.onAttributeUpdated(attributeEvent,extrasBundle);
      }
 catch (      RemoteException e) {
        Log.e(TAG,e.getMessage(),e);
        try {
          removeAttributesObserver(observer);
        }
 catch (        RemoteException e1) {
          Log.e(TAG,e1.getMessage(),e1);
        }
      }
    }
  }
}

Fixed version (ground truth):
private void notifyAttributeUpdate(String attributeEvent,Bundle extrasBundle){
  if (observersList.isEmpty())   return;
  if (attributeEvent != null) {
    for (    IObserver observer : observersList) {
      try {
        observer.onAttributeUpdated(attributeEvent,extrasBundle);
      }
 catch (      RemoteException e) {
        Timber.e(e,e.getMessage());
        try {
          removeAttributesObserver(observer);
        }
 catch (        RemoteException e1) {
          Timber.e(e,e1.getMessage());
        }
      }
    }
  }
}
Program: 94813
Project: 94813
Buggy source:
private void notifyConnectionFailed(ConnectionResult result){
  if (result != null) {
    try {
      apiListener.onConnectionFailed(result);
      return;
    }
 catch (    RemoteException e) {
      Log.w(TAG,"String_Node_Str",e);
    }
    checkForSelfRelease();
  }
}

Fixed version (ground truth):
private void notifyConnectionFailed(ConnectionResult result){
  if (result != null) {
    try {
      apiListener.onConnectionFailed(result);
      return;
    }
 catch (    RemoteException e) {
      Timber.w(e,"String_Node_Str");
    }
    checkForSelfRelease();
  }
}
Program: 94814
Project: 94814
Buggy source:
@Override public void onReceivedMavLinkMessage(MAVLinkMessage msg){
  if (mavlinkObserversList.isEmpty())   return;
  if (msg != null) {
    final MavlinkMessageWrapper msgWrapper=new MavlinkMessageWrapper(msg);
    for (    IMavlinkObserver observer : mavlinkObserversList) {
      try {
        observer.onMavlinkMessageReceived(msgWrapper);
      }
 catch (      RemoteException e) {
        Log.e(TAG,e.getMessage(),e);
        try {
          removeMavlinkObserver(observer);
        }
 catch (        RemoteException e1) {
          Log.e(TAG,e1.getMessage(),e1);
        }
      }
    }
  }
}

Fixed version (ground truth):
@Override public void onReceivedMavLinkMessage(MAVLinkMessage msg){
  if (mavlinkObserversList.isEmpty())   return;
  if (msg != null) {
    final MavlinkMessageWrapper msgWrapper=new MavlinkMessageWrapper(msg);
    for (    IMavlinkObserver observer : mavlinkObserversList) {
      try {
        observer.onMavlinkMessageReceived(msgWrapper);
      }
 catch (      RemoteException e) {
        Timber.e(e,e.getMessage());
        try {
          removeMavlinkObserver(observer);
        }
 catch (        RemoteException e1) {
          Timber.e(e1,e1.getMessage());
        }
      }
    }
  }
}
Program: 94815
Project: 94815
Buggy source:
void destroy(){
  Log.d(TAG,"String_Node_Str" + this.ownerId);
  this.observersList.clear();
  this.mavlinkObserversList.clear();
  this.apiListener.asBinder().unlinkToDeath(this,0);
  try {
    this.service.disconnectDroneManager(this.droneMgr,this.ownerId);
  }
 catch (  ConnectionException e) {
    Log.e(TAG,e.getMessage(),e);
  }
}

Fixed version (ground truth):
void destroy(){
  Timber.d("String_Node_Str",this.ownerId);
  this.observersList.clear();
  this.mavlinkObserversList.clear();
  try {
    this.apiListener.asBinder().unlinkToDeath(this,0);
  }
 catch (  NoSuchElementException e) {
    Timber.e(e,e.getMessage());
  }
  try {
    this.service.disconnectDroneManager(this.droneMgr,this.ownerId);
  }
 catch (  ConnectionException e) {
    Timber.e(e,e.getMessage());
  }
}
Program: 94816
Project: 94816
Buggy source:
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));
  }
}

Fixed version (ground truth):
private void checkForSelfRelease(){
  if (!apiListener.asBinder().pingBinder()) {
    Timber.w("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: 94817
Project: 94817
Buggy source:
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);
  }
}

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) {
    Timber.e(e,e.getMessage());
    dpService.releaseDroneApi(this.ownerId);
  }
}
Program: 94818
Project: 94818
Buggy source:
public static void sendCalibrationAckMessage(int count,Drone drone){
  msg_command_ack msg=new msg_command_ack();
  msg.command=(short)count;
  msg.result=MAV_CMD_ACK.MAV_CMD_ACK_OK;
  drone.getMavClient().sendMavPacket(msg.pack());
}

Fixed version (ground truth):
public static void sendCalibrationAckMessage(int count,Drone drone){
  msg_command_ack msg=new msg_command_ack();
  msg.command=count;
  msg.result=MAV_CMD_ACK.MAV_CMD_ACK_OK;
  drone.getMavClient().sendMavPacket(msg.pack());
}