nus-yam/ex-repair huggingface dataset:
Program: 94010
Project: 94010
Buggy source:
public void closeServer(){
  if (m_native == null) {
    m_mngr.ASSERT(false,"String_Node_Str");
  }
 else {
    final BluetoothGattServer native_local=m_native;
    m_native=null;
    native_local.clearServices();
    native_local.close();
  }
}

Fixed version (ground truth):
public void closeServer(){
  if (m_native == null) {
    m_mngr.ASSERT(false,"String_Node_Str");
  }
 else {
    final BluetoothGattServer native_local=m_native;
    m_native=null;
    native_local.close();
  }
}
Program: 94011
Project: 94011
Buggy source:
public P_NativeServerWrapper(BleServer server){
  m_server=server;
  m_logger=m_server.getManager().getLogger();
  m_mngr=m_server.getManager();
  if (server.isNull()) {
    m_name=BleDevice.NULL_STRING();
    m_native=null;
  }
 else {
    m_name="String_Node_Str";
  }
}

Fixed version (ground truth):
public P_NativeServerWrapper(BleServer server){
  m_server=server;
  m_mngr=m_server.getManager();
  if (server.isNull()) {
    m_name=BleDevice.NULL_STRING();
    m_native=null;
  }
 else {
    m_name="String_Node_Str";
  }
}
Program: 94013
Project: 94013
Buggy source:
void onConnecting(boolean definitelyExplicit,boolean isReconnect,final Object[] extraBondingStates){
  m_lastConnectOrDisconnectWasUserExplicit=definitelyExplicit;
  if (is_internal(CONNECTING)) {
    P_Task_Connect task=getTaskQueue().getCurrent(P_Task_Connect.class,this);
    boolean mostDefinitelyExplicit=task != null && task.isExplicit();
    m_mngr.ASSERT(definitelyExplicit || mostDefinitelyExplicit);
    stateTracker_main().update(E_Intent.INTENTIONAL,BleStatuses.GATT_STATUS_NOT_APPLICABLE,extraBondingStates);
  }
 else {
    final E_Intent intent;
    if (definitelyExplicit && !isReconnect) {
      m_reconnectMngr_longTerm.stop();
      intent=E_Intent.INTENTIONAL;
      stateTracker().update(intent,BluetoothGatt.GATT_SUCCESS,RECONNECTING_LONG_TERM,false,CONNECTING,true,CONNECTING_OVERALL,true,DISCONNECTED,false,ADVERTISING,false,extraBondingStates);
    }
 else {
      intent=lastConnectDisconnectIntent();
      stateTracker().update(intent,BluetoothGatt.GATT_SUCCESS,CONNECTING,true,CONNECTING_OVERALL,true,DISCONNECTED,false,ADVERTISING,false,extraBondingStates);
    }
    if (stateTracker() != stateTracker_main()) {
      stateTracker_main().update(intent,BleStatuses.GATT_STATUS_NOT_APPLICABLE,extraBondingStates);
    }
  }
}

Fixed version (ground truth):
void onConnecting(boolean definitelyExplicit,boolean isReconnect,final Object[] extraBondingStates,final boolean bleConnect){
  m_lastConnectOrDisconnectWasUserExplicit=definitelyExplicit;
  if (bleConnect && is_internal(CONNECTING)) {
    P_Task_Connect task=getTaskQueue().getCurrent(P_Task_Connect.class,this);
    boolean mostDefinitelyExplicit=task != null && task.isExplicit();
    m_mngr.ASSERT(definitelyExplicit || mostDefinitelyExplicit);
    stateTracker_main().update(E_Intent.INTENTIONAL,BleStatuses.GATT_STATUS_NOT_APPLICABLE,extraBondingStates);
  }
 else {
    final E_Intent intent;
    if (definitelyExplicit && !isReconnect) {
      m_reconnectMngr_longTerm.stop();
      intent=E_Intent.INTENTIONAL;
      stateTracker().update(intent,BluetoothGatt.GATT_SUCCESS,RECONNECTING_LONG_TERM,false,CONNECTING,bleConnect,CONNECTING_OVERALL,true,DISCONNECTED,false,ADVERTISING,false,extraBondingStates);
    }
 else {
      intent=lastConnectDisconnectIntent();
      stateTracker().update(intent,BluetoothGatt.GATT_SUCCESS,CONNECTING,bleConnect,CONNECTING_OVERALL,true,DISCONNECTED,false,ADVERTISING,false,extraBondingStates);
    }
    if (stateTracker() != stateTracker_main()) {
      stateTracker_main().update(intent,BleStatuses.GATT_STATUS_NOT_APPLICABLE,UNBONDED,stateTracker().is(UNBONDED),BONDING,stateTracker().is(BONDING),BONDED,stateTracker().is(BONDED));
    }
  }
}
Program: 94014
Project: 94014
Buggy source:
private void connect_private(BleTransaction.Auth authenticationTxn,BleTransaction.Init initTxn,boolean isReconnect){
  if (is_internal(INITIALIZED)) {
    m_mngr.ASSERT(false,"String_Node_Str");
    return;
  }
  m_txnMngr.onConnect(authenticationTxn,initTxn);
  final Object[] extraBondingStates;
  if (is(UNBONDED)) {
    final boolean tryBondingWhileDisconnected_manageOnDisk=BleDeviceConfig.bool(conf_device().tryBondingWhileDisconnected_manageOnDisk,conf_mngr().tryBondingWhileDisconnected_manageOnDisk);
    final boolean doPreBond=getManager().m_diskOptionsMngr.loadNeedsBonding(getMacAddress(),tryBondingWhileDisconnected_manageOnDisk);
    if (doPreBond) {
      bond_justAddTheTask(E_TransactionLockBehavior.PASSES);
      extraBondingStates=P_BondManager.OVERRIDE_BONDING_STATES;
    }
 else {
      extraBondingStates=P_BondManager.OVERRIDE_EMPTY_STATES;
    }
  }
 else {
    extraBondingStates=P_BondManager.OVERRIDE_EMPTY_STATES;
  }
  m_queue.add(new P_Task_Connect(this,m_taskStateListener));
  onConnecting(true,isReconnect,extraBondingStates);
}

Fixed version (ground truth):
private void connect_private(BleTransaction.Auth authenticationTxn,BleTransaction.Init initTxn,final boolean isReconnect){
  if (is_internal(INITIALIZED)) {
    m_mngr.ASSERT(false,"String_Node_Str");
    return;
  }
  m_txnMngr.onConnect(authenticationTxn,initTxn);
  final Object[] extraBondingStates;
  if (is(UNBONDED)) {
    final boolean tryBondingWhileDisconnected_manageOnDisk=BleDeviceConfig.bool(conf_device().tryBondingWhileDisconnected_manageOnDisk,conf_mngr().tryBondingWhileDisconnected_manageOnDisk);
    final boolean doPreBond=getManager().m_diskOptionsMngr.loadNeedsBonding(getMacAddress(),tryBondingWhileDisconnected_manageOnDisk);
    if (doPreBond) {
      bond_justAddTheTask(E_TransactionLockBehavior.PASSES);
      extraBondingStates=P_BondManager.OVERRIDE_BONDING_STATES;
    }
 else {
      extraBondingStates=P_BondManager.OVERRIDE_EMPTY_STATES;
    }
  }
 else {
    extraBondingStates=P_BondManager.OVERRIDE_EMPTY_STATES;
  }
  onConnecting(true,isReconnect,extraBondingStates,false);
  if (!is_internal(CONNECTING_OVERALL)) {
    return;
  }
  m_queue.add(new P_Task_Connect(this,m_taskStateListener));
  onConnecting(true,isReconnect,extraBondingStates,true);
}
Program: 94015
Project: 94015
Buggy source:
/** 
 * The gattStatus returned, if applicable, from native callbacks like   {@link BluetoothGattCallback#onConnectionStateChange(BluetoothGatt,int,int)}or   {@link BluetoothGattCallback#onServicesDiscovered(BluetoothGatt,int)}. If not applicable, for example if   {@link ConnectionFailEvent#reason()} is {@link Status#EXPLICIT_DISCONNECT}, then this is set to  {@link BleDeviceConfig#GATT_STATUS_NOT_APPLICABLE}.  <br><br> See   {@link ReadWriteEvent#gattStatus()} for more information about gatt status codes in general.
 * @see ReadWriteEvent#gattStatus
 */
public int gattStatus(){
  return m_gattStatus;
}

Fixed version (ground truth):
/** 
 * The gattStatus returned, if applicable, from native callbacks like   {@link BluetoothGattCallback#onConnectionStateChange(BluetoothGatt,int,int)}or   {@link BluetoothGattCallback#onServicesDiscovered(BluetoothGatt,int)}. If not applicable, for example if   {@link ConnectionFailEvent#reason()} is {@link Status#EXPLICIT_DISCONNECT}, then this is set to  {@link BleStatuses#GATT_STATUS_NOT_APPLICABLE}.  <br><br> See   {@link ReadWriteEvent#gattStatus()} for more information about gatt status codes in general.
 * @see ReadWriteEvent#gattStatus
 */
public int gattStatus(){
  return m_gattStatus;
}
Program: 94017
Project: 94017
Buggy source:
/** 
 * Returns the device's name and current state for logging and debugging purposes.
 */
@Override public String toString(){
  if (isNull()) {
    return "String_Node_Str";
  }
 else {
    return getName_debug() + "String_Node_Str" + m_stateTracker.toString();
  }
}

Fixed version (ground truth):
/** 
 * Returns the device's name and current state for logging and debugging purposes.
 */
@Override public String toString(){
  if (isNull()) {
    return NULL_STRING();
  }
 else {
    return getName_debug() + "String_Node_Str" + m_stateTracker.toString();
  }
}
Program: 94018
Project: 94018
Buggy source:
/** 
 * Kicks off an OTA transaction if it's not already taking place and the device is   {@link BleDeviceState#INITIALIZED}. This will put the device into the   {@link BleDeviceState#PERFORMING_OTA} state if <code>true</code> is returned.<br><br> TIP: Use the  {@link TimeEstimator} class to let your users know roughly how much time it will take for the ota to complete.
 * @return	{@link Boolean#TRUE} if firmware update has started, otherwise {@link Boolean#FALSE} if device is either already{@link BleDeviceState#PERFORMING_OTA} or is not {@link BleDeviceState#INITIALIZED}.
 * @see BleManagerConfig#includeOtaReadWriteTimesInAverage
 * @see BleManagerConfig#autoScanDuringOta
 */
public boolean performOta(BleTransaction.Ota txn){
  if (isNull())   return false;
  if (is(PERFORMING_OTA))   return false;
  if (!is(INITIALIZED))   return false;
  m_txnMngr.startOta(txn);
  return true;
}

Fixed version (ground truth):
/** 
 * Kicks off an "over the air" long-term transaction if it's not already taking place and the device is   {@link BleDeviceState#INITIALIZED}. This will put the device into the   {@link BleDeviceState#PERFORMING_OTA} state if <code>true</code> is returned.You can use this to do firmware updates, file transfers, etc. <br><br> TIP: Use the  {@link TimeEstimator} class to let your users know roughly how much time it will take for the ota to complete.
 * @return	{@link Boolean#TRUE} if firmware update has started, otherwise {@link Boolean#FALSE} if device is either already{@link BleDeviceState#PERFORMING_OTA} or is not {@link BleDeviceState#INITIALIZED}.
 * @see BleManagerConfig#includeOtaReadWriteTimesInAverage
 * @see BleManagerConfig#autoScanDuringOta
 */
public boolean performOta(BleTransaction.Ota txn){
  if (isNull())   return false;
  if (is(PERFORMING_OTA))   return false;
  if (!is(INITIALIZED))   return false;
  m_txnMngr.startOta(txn);
  return true;
}
Program: 94019
Project: 94019
Buggy source:
/** 
 * Return this from   {@link ReconnectFilter#onEvent(ReconnectFilter.ReconnectEvent)} to stop a reconnect attempt loop.Note that  {@link BleDevice#disconnect()} will also stop any ongoing reconnect loop.
 */
public static Please stopRetrying(){
  return new Please(STOP);
}

Fixed version (ground truth):
/** 
 * Return this from   {@link ReconnectRequestFilter#onEvent(ReconnectRequestFilter.ReconnectRequestEvent)} to stop a reconnect attempt loop.Note that  {@link BleDevice#disconnect()} will also stop any ongoing reconnect loop.
 */
public static Please stopRetrying(){
  return new Please(STOP);
}
Program: 94020
Project: 94020
Buggy source:
/** 
 * Return this from   {@link ReconnectFilter#onEvent(ReconnectFilter.ReconnectEvent)} to retry after the given amount of time.
 */
public static Please retryIn(Interval interval){
  return new Please(interval != null ? interval : INSTANTLY);
}

Fixed version (ground truth):
/** 
 * Return this from   {@link ReconnectRequestFilter#onEvent(ReconnectRequestFilter.ReconnectRequestEvent)} to retry after the given amount of time.
 */
public static Please retryIn(Interval interval){
  return new Please(interval != null ? interval : INSTANTLY);
}
Program: 94021
Project: 94021
Buggy source:
/** 
 * Return this from   {@link ReconnectFilter#onEvent(ReconnectFilter.ReconnectEvent)} to instantly reconnect.
 */
public static Please retryInstantly(){
  return new Please(INSTANTLY);
}

Fixed version (ground truth):
/** 
 * Return this from   {@link ReconnectRequestFilter#onEvent(ReconnectRequestFilter.ReconnectRequestEvent)} to instantly reconnect.
 */
public static Please retryInstantly(){
  return new Please(INSTANTLY);
}
Program: 94022
Project: 94022
Buggy source:
/** 
 * The previous   {@link Interval} returned from {@link ReconnectFilter#onEvent(ReconnectEvent)}, or   {@link Interval#ZERO}for the first invocation.
 */
public Interval previousDelay(){
  return m_previousDelay;
}

Fixed version (ground truth):
/** 
 * The previous   {@link Interval} returned from {@link ReconnectRequestFilter#onEvent(ReconnectRequestEvent)}, or   {@link Interval#ZERO}for the first invocation.
 */
public Interval previousDelay(){
  return m_previousDelay;
}
Program: 94023
Project: 94023
Buggy source:
/** 
 * Returns the more detailed information about why the connection failed. This is passed to   {@link BleDevice.ConnectionFailListener#onEvent(com.idevicesinc.sweetblue.BleDevice.ConnectionFailListener.ConnectionFailEvent)}before the call is made to   {@link ReconnectFilter#onEvent(ReconnectEvent)}. For the first call to   {@link ReconnectFilter#onEvent(ReconnectEvent)}, right after a spontaneous disconnect occurred, the connection didn't fail, so   {@link ConnectionFailListener.ConnectionFailEvent#isNull()} will return <code>true</code>.
 */
public ConnectionFailListener.ConnectionFailEvent connectionFailInfo(){
  return m_connectionFailInfo;
}

Fixed version (ground truth):
/** 
 * Returns the more detailed information about why the connection failed. This is passed to   {@link BleDevice.ConnectionFailListener#onEvent(com.idevicesinc.sweetblue.BleDevice.ConnectionFailListener.ConnectionFailEvent)}before the call is made to   {@link ReconnectRequestFilter#onEvent(ReconnectRequestEvent)}. For the first call to   {@link ReconnectRequestFilter#onEvent(ReconnectRequestEvent)}, right after a spontaneous disconnect occurred, the connection didn't fail, so   {@link ConnectionFailListener.ConnectionFailEvent#isNull()} will return <code>true</code>.
 */
public ConnectionFailListener.ConnectionFailEvent connectionFailInfo(){
  return m_connectionFailInfo;
}
Program: 94024
Project: 94024
Buggy source:
void BleDevice(BleManager mngr,BluetoothDevice device_native,String normalizedName,String nativeName,BleDeviceOrigin origin,BleDeviceConfig config_nullable){
  m_mngr=mngr;
  m_origin=origin;
  setConfig(config_nullable);
  m_nativeWrapper=new P_NativeDeviceWrapper(this,device_native,normalizedName,nativeName);
  m_queue=m_mngr.getTaskQueue();
  m_listeners=new P_BleDevice_Listeners(this);
  m_logger=m_mngr.getLogger();
  m_serviceMngr=new P_ServiceManager(this);
  m_stateTracker=new P_DeviceStateTracker(this);
  m_stateTracker.set(E_Intent.IMPLICIT,BleDeviceState.UNDISCOVERED,true,BleDeviceState.DISCONNECTED,true);
  m_pollMngr=new P_PollManager(this);
  m_txnMngr=new P_TransactionManager(this);
  m_taskStateListener=m_listeners.m_taskStateListener;
  m_reconnectMngr=new P_ReconnectManager(this);
  m_connectionFailMngr=new P_ConnectionFailManager(this,m_reconnectMngr);
  m_rssiPollMngr=new P_RssiPollManager(this);
  m_bondMngr=new P_BondManager(this);
  m_dummyDisconnectTask=new P_Task_Disconnect(this,null,false,PE_TaskPriority.FOR_EXPLICIT_BONDING_AND_CONNECTING);
}

Fixed version (ground truth):
void BleDevice(BleManager mngr,BluetoothDevice device_native,String normalizedName,String nativeName,BleDeviceOrigin origin,BleDeviceConfig config_nullable){
  m_mngr=mngr;
  m_origin=origin;
  setConfig(config_nullable);
  m_nativeWrapper=new P_NativeDeviceWrapper(this,device_native,normalizedName,nativeName);
  m_queue=m_mngr.getTaskQueue();
  m_listeners=new P_BleDevice_Listeners(this);
  m_logger=m_mngr.getLogger();
  m_serviceMngr=new P_ServiceManager(this);
  m_stateTracker=new P_DeviceStateTracker(this);
  m_bondMngr=new P_BondManager(this);
  m_stateTracker.set(E_Intent.IMPLICIT,BleDeviceState.UNDISCOVERED,true,BleDeviceState.DISCONNECTED,true);
  m_pollMngr=new P_PollManager(this);
  m_txnMngr=new P_TransactionManager(this);
  m_taskStateListener=m_listeners.m_taskStateListener;
  m_reconnectMngr=new P_ReconnectManager(this);
  m_connectionFailMngr=new P_ConnectionFailManager(this,m_reconnectMngr);
  m_rssiPollMngr=new P_RssiPollManager(this);
  m_dummyDisconnectTask=new P_Task_Disconnect(this,null,false,PE_TaskPriority.FOR_EXPLICIT_BONDING_AND_CONNECTING);
}
Program: 94025
Project: 94025
Buggy source:
/** 
 * Same as   {@link #RETRY_WITH_AUTOCONNECT_TRUE} but forces <code>autoConnect=false</code>.
 */
@Advanced public static Please retryWithAutoConnectFalse(){
  return new Please(PE_Please.RETRY_WITH_AUTOCONNECT_FALSE);
}

Fixed version (ground truth):
/** 
 * Opposite of  {@link #retryWithAutoConnectTrue()}.
 */
@Advanced public static Please retryWithAutoConnectFalse(){
  return new Please(PE_Please.RETRY_WITH_AUTOCONNECT_FALSE);
}
Program: 94026
Project: 94026
Buggy source:
/** 
 * Same as   {@link #RETRY}, but <code>autoConnect=true</code> will be passed to   {@link BluetoothDevice#connectGatt(Context,boolean,android.bluetooth.BluetoothGattCallback)}. See more discussion at   {@link BleDeviceConfig#alwaysUseAutoConnect}.
 */
@Advanced public static Please retryWithAutoConnectTrue(){
  return new Please(PE_Please.RETRY_WITH_AUTOCONNECT_TRUE);
}

Fixed version (ground truth):
/** 
 * Same as   {@link #retry()}, but <code>autoConnect=true</code> will be passed to   {@link BluetoothDevice#connectGatt(Context,boolean,android.bluetooth.BluetoothGattCallback)}. See more discussion at   {@link BleDeviceConfig#alwaysUseAutoConnect}.
 */
@Advanced public static Please retryWithAutoConnectTrue(){
  return new Please(PE_Please.RETRY_WITH_AUTOCONNECT_TRUE);
}
Program: 94027
Project: 94027
Buggy source:
/** 
 * Kicks off an OTA transaction if it's not already taking place and the device is   {@link BleDeviceState#INITIALIZED}. This will put the device into the   {@link BleDeviceState#PERFORMING_OTA} state.<br><br> TIP: Use the  {@link TimeEstimator} class to let your users know roughly how much time it will take for the ota to complete.
 * @return	{@link Boolean#TRUE} if firmware update has started, otherwise {@link Boolean#FALSE} if device is either already{@link BleDeviceState#PERFORMING_OTA} or is not {@link BleDeviceState#INITIALIZED}.
 * @see BleManagerConfig#includeOtaReadWriteTimesInAverage
 * @see BleManagerConfig#autoScanDuringOta
 */
public boolean performOta(BleTransaction.Ota txn){
  if (is(PERFORMING_OTA))   return false;
  if (!is(INITIALIZED))   return false;
  m_txnMngr.onOta(txn);
  return true;
}

Fixed version (ground truth):
/** 
 * Kicks off an OTA transaction if it's not already taking place and the device is   {@link BleDeviceState#INITIALIZED}. This will put the device into the   {@link BleDeviceState#PERFORMING_OTA} state.<br><br> TIP: Use the  {@link TimeEstimator} class to let your users know roughly how much time it will take for the ota to complete.
 * @return	{@link Boolean#TRUE} if firmware update has started, otherwise {@link Boolean#FALSE} if device is either already{@link BleDeviceState#PERFORMING_OTA} or is not {@link BleDeviceState#INITIALIZED}.
 * @see BleManagerConfig#includeOtaReadWriteTimesInAverage
 * @see BleManagerConfig#autoScanDuringOta
 */
public boolean performOta(BleTransaction.Ota txn){
  if (is(PERFORMING_OTA))   return false;
  if (!is(INITIALIZED))   return false;
  m_txnMngr.startOta(txn);
  return true;
}
Program: 94028
Project: 94028
Buggy source:
/** 
 * Same as   {@link #ASSERT(boolean)} but with an added message.
 */
@Advanced public boolean ASSERT(boolean condition,String message){
  if (!condition) {
    Exception dummyException=null;
    message=message != null ? message : "String_Node_Str";
    if (m_config.loggingEnabled || m_assertionListener != null) {
      dummyException=new Exception();
    }
    if (m_config.loggingEnabled) {
      Log.e(BleManager.class.getSimpleName(),"String_Node_Str" + message,dummyException);
    }
    if (m_assertionListener != null) {
      Info info=new Info(this,message,dummyException.getStackTrace());
      m_assertionListener.onAssertFailed(info);
    }
    return false;
  }
  return true;
}

Fixed version (ground truth):
/** 
 * Same as   {@link #ASSERT(boolean)} but with an added message.
 */
@Advanced public boolean ASSERT(boolean condition,String message){
  if (!condition) {
    Exception dummyException=null;
    message=message != null ? message : "String_Node_Str";
    if (m_config.loggingEnabled || m_assertionListener != null) {
      dummyException=new Exception();
    }
    if (m_config.loggingEnabled) {
      Log.e(BleManager.class.getSimpleName(),"String_Node_Str" + message,dummyException);
    }
    if (m_assertionListener != null) {
      AssertListener.Info info=new AssertListener.Info(this,message,dummyException.getStackTrace());
      m_assertionListener.onAssertFailed(info);
    }
    return false;
  }
  return true;
}
Program: 94029
Project: 94029
Buggy source:
/** 
 * Acknowledges the discovery if there's an overlap between the given advertisedServices and the   {@link Collection} passed into {@link BleManagerConfig.DefaultScanFilter#DefaultAdvertisingFilter(Collection)}.
 */
@Override public Please onScanResult(Result result){
  if (Utils.haveMatchingIds(result.advertisedServices(),m_whitelist)) {
    return Please.acknowledge();
  }
 else {
    return Please.ignore();
  }
}

Fixed version (ground truth):
/** 
 * Acknowledges the discovery if there's an overlap between the given advertisedServices and the   {@link Collection} passed into {@link BleManagerConfig.DefaultScanFilter#DefaultScanFilter(Collection)}.
 */
@Override public Please onScanResult(Result result){
  if (Utils.haveMatchingIds(result.advertisedServices(),m_whitelist)) {
    return Please.acknowledge();
  }
 else {
    return Please.ignore();
  }
}
Program: 94030
Project: 94030
Buggy source:
/** 
 * Returns true for certain Sony and Motorola products, which may have problems managing bonding state and so this method is used to set   {@link #autoUnbond_onStateEnter}.
 */
public static boolean phoneHasBondingIssues(){
  return Utils.isManufacturer("String_Node_Str") || Utils.isManufacturer("String_Node_Str") && Utils.isProduct("String_Node_Str");
}

Fixed version (ground truth):
/** 
 * Returns true for certain Sony and Motorola products, which may have problems managing bonding state and so this method is used in   {@link BleDeviceConfig.DefaultBondFilter}. 
 */
public static boolean phoneHasBondingIssues(){
  return Utils.isManufacturer("String_Node_Str") || Utils.isManufacturer("String_Node_Str") && Utils.isProduct("String_Node_Str");
}
Program: 94031
Project: 94031
Buggy source:
/** 
 * Convenience method that does a bitwise OR of the given states to   {@link #autoUnbond_stateEnter}.
 */
public void autoUnbondWhenEntering(BleDeviceState... states){
  autoUnbond_stateEnter=autoUnbond_stateEnter != null ? autoUnbond_stateEnter : 0x0;
  for (int i=0; i < states.length; i++) {
    autoUnbond_stateEnter|=states[i].bit();
  }
}

Fixed version (ground truth):
/** 
 * Convenience method that does a bitwise OR of the given states to   {@link #autoUnbond_onStateEnter}.
 */
public void autoUnbondWhenEntering(BleDeviceState... states){
  autoUnbond_onStateEnter=autoUnbond_onStateEnter != null ? autoUnbond_onStateEnter : 0x0;
  for (int i=0; i < states.length; i++) {
    autoUnbond_onStateEnter|=states[i].bit();
  }
}
Program: 94032
Project: 94032
Buggy source:
/** 
 * Convenience method that does a bitwise OR of the given states to   {@link #autoUnbond_stateExit}.
 */
public void autoUnbondWhenExiting(BleDeviceState... states){
  autoUnbond_stateExit=autoUnbond_stateExit != null ? autoUnbond_stateExit : 0x0;
  for (int i=0; i < states.length; i++) {
    autoUnbond_stateExit|=states[i].bit();
  }
}

Fixed version (ground truth):
/** 
 * Convenience method that does a bitwise OR of the given states to   {@link #autoUnbond_onStateExit}.
 */
public void autoUnbondWhenExiting(BleDeviceState... states){
  autoUnbond_onStateExit=autoUnbond_onStateExit != null ? autoUnbond_onStateExit : 0x0;
  for (int i=0; i < states.length; i++) {
    autoUnbond_onStateExit|=states[i].bit();
  }
}
Program: 94033
Project: 94033
Buggy source:
static boolean autoUnbond(final int oldStateBits,final int newStateBits,final BleDeviceConfig conf_device,final BleManagerConfig conf_mngr){
  final int autoUnbond_stateEnter=integerOrZero(integer(conf_device.autoUnbond_stateEnter,conf_mngr.autoUnbond_stateEnter));
  final int autoUnbond_stateExit=integerOrZero(integer(conf_device.autoUnbond_stateExit,conf_mngr.autoUnbond_stateExit));
  return autoBondOrUnbond(oldStateBits,newStateBits,autoUnbond_stateEnter,autoUnbond_stateExit);
}

Fixed version (ground truth):
static boolean autoUnbond(final int oldStateBits,final int newStateBits,final BleDeviceConfig conf_device,final BleManagerConfig conf_mngr){
  final int autoUnbond_stateEnter=integerOrZero(integer(conf_device.autoUnbond_onStateEnter,conf_mngr.autoUnbond_onStateEnter));
  final int autoUnbond_stateExit=integerOrZero(integer(conf_device.autoUnbond_onStateExit,conf_mngr.autoUnbond_onStateExit));
  return autoBondOrUnbond(oldStateBits,newStateBits,autoUnbond_stateEnter,autoUnbond_stateExit);
}
Program: 94034
Project: 94034
Buggy source:
static boolean autoBond(final int oldStateBits,final int newStateBits,final BleDeviceConfig conf_device,final BleManagerConfig conf_mngr){
  final int autoBond_stateEnter=integerOrZero(integer(conf_device.autoBond_stateEnter,conf_mngr.autoBond_stateEnter));
  final int autoBond_stateExit=integerOrZero(integer(conf_device.autoBond_stateExit,conf_mngr.autoBond_stateExit));
  return autoBondOrUnbond(oldStateBits,newStateBits,autoBond_stateEnter,autoBond_stateExit);
}

Fixed version (ground truth):
static boolean autoBond(final int oldStateBits,final int newStateBits,final BleDeviceConfig conf_device,final BleManagerConfig conf_mngr){
  final int autoBond_stateEnter=integerOrZero(integer(conf_device.autoBond_onStateEnter,conf_mngr.autoBond_onStateEnter));
  final int autoBond_stateExit=integerOrZero(integer(conf_device.autoBond_onStateExit,conf_mngr.autoBond_onStateExit));
  return autoBondOrUnbond(oldStateBits,newStateBits,autoBond_stateEnter,autoBond_stateExit);
}
Program: 94035
Project: 94035
Buggy source:
/** 
 * Returns true for certain Sony and Motorola products, which may have problems managing bonding state and so this method is used to set   {@link #autoUnbond_stateEnter}.
 */
public boolean phoneHasBondingIssues(){
  return Utils.isManufacturer("String_Node_Str") || Utils.isManufacturer("String_Node_Str") && Utils.isProduct("String_Node_Str");
}

Fixed version (ground truth):
/** 
 * Returns true for certain Sony and Motorola products, which may have problems managing bonding state and so this method is used to set   {@link #autoUnbond_onStateEnter}.
 */
public boolean phoneHasBondingIssues(){
  return Utils.isManufacturer("String_Node_Str") || Utils.isManufacturer("String_Node_Str") && Utils.isProduct("String_Node_Str");
}
Program: 94036
Project: 94036
Buggy source:
/** 
 * Convenience method that does a bitwise OR of the given states to   {@link #autoBond_stateExit}.
 */
public void autoBondWhenExiting(BleDeviceState... states){
  autoBond_stateExit=autoBond_stateExit != null ? autoBond_stateExit : 0x0;
  for (int i=0; i < states.length; i++) {
    autoBond_stateExit|=states[i].bit();
  }
}

Fixed version (ground truth):
/** 
 * Convenience method that does a bitwise OR of the given states to   {@link #autoBond_onStateExit}.
 */
public void autoBondWhenExiting(BleDeviceState... states){
  autoBond_onStateExit=autoBond_onStateExit != null ? autoBond_onStateExit : 0x0;
  for (int i=0; i < states.length; i++) {
    autoBond_onStateExit|=states[i].bit();
  }
}
Program: 94037
Project: 94037
Buggy source:
/** 
 * Convenience method that does a bitwise OR of the given states to   {@link #autoBond_stateEnter}.
 */
public void autoBondWhenEntering(BleDeviceState... states){
  autoBond_stateEnter=autoBond_stateEnter != null ? autoBond_stateEnter : 0x0;
  for (int i=0; i < states.length; i++) {
    autoBond_stateEnter|=states[i].bit();
  }
}

Fixed version (ground truth):
/** 
 * Convenience method that does a bitwise OR of the given states to   {@link #autoBond_onStateEnter}.
 */
public void autoBondWhenEntering(BleDeviceState... states){
  autoBond_onStateEnter=autoBond_onStateEnter != null ? autoBond_onStateEnter : 0x0;
  for (int i=0; i < states.length; i++) {
    autoBond_onStateEnter|=states[i].bit();
  }
}
Program: 94038
Project: 94038
Buggy source:
public PA_Task(BleManager manager,I_StateListener listener,double timeout){
  m_device=null;
  m_manager=manager;
  m_maxRetries=0;
  m_timeout=timeout;
  m_logger=m_manager.getLogger();
  m_timeCreated=System.currentTimeMillis();
  if (listener == null && this instanceof I_StateListener) {
    m_stateListener=(I_StateListener)this;
  }
 else {
    m_stateListener=listener;
  }
}

Fixed version (ground truth):
public PA_Task(BleManager manager,I_StateListener listener,double timeout){
  m_device=null;
  m_manager=manager;
  m_timeout=timeout;
  m_logger=m_manager.getLogger();
  m_timeCreated=System.currentTimeMillis();
  if (listener == null && this instanceof I_StateListener) {
    m_stateListener=(I_StateListener)this;
  }
 else {
    m_stateListener=listener;
  }
}
Program: 94039
Project: 94039
Buggy source:
void resetTimeout(double newTimeout){
synchronized (this) {
    m_timeout=newTimeout;
    m_resettableTimeExecuting=0.0;
  }
}

Fixed version (ground truth):
void resetTimeout(double newTimeout){
synchronized (this) {
    m_timeout=newTimeout;
    m_resetableExecuteStartTime=System.currentTimeMillis();
  }
}
Program: 94040
Project: 94040
Buggy source:
void onAddedToQueue(P_TaskQueue queue){
  m_queue=queue;
  setState(PE_TaskState.QUEUED);
  m_retryCount=0;
  m_updateCount=0;
  m_addedToQueueTime=m_addedToQueueTime == -1.0 ? m_queue.getTime() : m_addedToQueueTime;
}

Fixed version (ground truth):
void onAddedToQueue(P_TaskQueue queue){
  m_queue=queue;
  setState(PE_TaskState.QUEUED);
  m_updateCount=0;
  m_addedToQueueTime=m_addedToQueueTime == -1.0 ? m_queue.getTime() : m_addedToQueueTime;
}
Program: 94041
Project: 94041
Buggy source:
void arm(Handler executeHandler){
  setState(PE_TaskState.ARMED);
  m_executeHandler=executeHandler;
  m_totalTimeArmedAndExecuting=0.0;
  m_resettableTimeExecuting=0.0;
  m_retryCount=0;
  m_updateCount=0;
}

Fixed version (ground truth):
void arm(Handler executeHandler){
  setState(PE_TaskState.ARMED);
  m_executeHandler=executeHandler;
  m_totalTimeArmedAndExecuting=0.0;
  m_resetableExecuteStartTime=System.currentTimeMillis();
  m_updateCount=0;
}
Program: 94042
Project: 94042
Buggy source:
private void execute_wrapper(){
  m_timeExecuted=System.currentTimeMillis();
  execute();
}

Fixed version (ground truth):
private void execute_wrapper(){
  m_resetableExecuteStartTime=System.currentTimeMillis();
  m_timeExecuted=System.currentTimeMillis();
  execute();
}
Program: 94043
Project: 94043
Buggy source:
protected void softlyCancel(){
  m_maxRetries=0;
  m_queue.tryEndingTask(this,PE_TaskState.SOFTLY_CANCELLED);
}

Fixed version (ground truth):
protected void softlyCancel(){
  m_queue.tryEndingTask(this,PE_TaskState.SOFTLY_CANCELLED);
}
Program: 94044
Project: 94044
Buggy source:
void update_internal(double timeStep){
synchronized (this) {
    m_totalTimeArmedAndExecuting+=timeStep;
    m_updateCount++;
    if (m_totalTimeArmedAndExecuting >= m_executionDelay) {
      if (m_state == PE_TaskState.ARMED) {
        if (m_updateCount > 1) {
          if (m_softlyCancelled) {
            softlyCancel();
            return;
          }
          if (isExecutable()) {
            setState(PE_TaskState.EXECUTING);
            if (executeOnSeperateThread()) {
              m_executeHandler.post(m_executeRunnable);
            }
 else {
              execute_wrapper();
            }
            return;
          }
 else {
            failWithoutRetry();
            return;
          }
        }
      }
 else       if (m_state == PE_TaskState.EXECUTING) {
        m_resettableTimeExecuting+=timeStep;
        if (!Interval.isDisabled(m_timeout) && m_timeout != Interval.INFINITE.secs()) {
          if (m_resettableTimeExecuting >= m_timeout) {
            timeout();
            return;
          }
        }
      }
    }
    this.update(timeStep);
  }
}

Fixed version (ground truth):
void update_internal(double timeStep){
synchronized (this) {
    m_totalTimeArmedAndExecuting+=timeStep;
    m_updateCount++;
    if (m_totalTimeArmedAndExecuting >= m_executionDelay) {
      if (m_state == PE_TaskState.ARMED) {
        if (m_updateCount > 1) {
          if (m_softlyCancelled) {
            softlyCancel();
            return;
          }
          if (isExecutable()) {
            setState(PE_TaskState.EXECUTING);
            if (executeOnSeperateThread()) {
              m_executeHandler.post(m_executeRunnable);
            }
 else {
              execute_wrapper();
            }
            return;
          }
 else {
            failWithoutRetry();
            return;
          }
        }
      }
 else       if (m_state == PE_TaskState.EXECUTING) {
        if (!Interval.isDisabled(m_timeout) && m_timeout != Interval.INFINITE.secs()) {
          double timeExecuting=(System.currentTimeMillis() - m_resetableExecuteStartTime) / 1000.0;
          if (timeExecuting >= m_timeout) {
            timeout();
            return;
          }
        }
      }
    }
    this.update(timeStep);
  }
}
Program: 94045
Project: 94045
Buggy source:
protected void failWithoutRetry(){
  m_maxRetries=0;
  fail();
}

Fixed version (ground truth):
protected void failWithoutRetry(){
  fail();
}
Program: 94047
Project: 94047
Buggy source:
/** 
 * Creates a new   {@link BleDevice} or returns an existing one if the macAddress matches.{@link DiscoveryListener#onDeviceDiscovered(BleDevice)} will be called if a new deviceis created.
 */
public BleDevice newDevice(String macAddress,String name){
  final BleDevice existingDevice=this.getDevice(macAddress);
  if (existingDevice != null)   return existingDevice;
  final BluetoothDevice device_native=getNative().getAdapter().getRemoteDevice(macAddress);
  if (device_native == null)   return null;
  final String name_normalized=Utils.normalizeDeviceName(name);
  final BleDevice newDevice=newDevice_private(device_native,name_normalized,name,BleDevice.Origin.EXPLICIT);
  onDiscovered_wrapItUp(newDevice,true,null,null,0);
  return newDevice;
}

Fixed version (ground truth):
/** 
 * Creates a new   {@link BleDevice} or returns an existing one if the macAddress matches.{@link DiscoveryListener#onDiscoveryEvent(DiscoveryEvent)} will be called if a new deviceis created.
 */
public BleDevice newDevice(String macAddress,String name){
  final BleDevice existingDevice=this.getDevice(macAddress);
  if (existingDevice != null)   return existingDevice;
  final BluetoothDevice device_native=getNative().getAdapter().getRemoteDevice(macAddress);
  if (device_native == null)   return null;
  final String name_normalized=Utils.normalizeDeviceName(name);
  final BleDevice newDevice=newDevice_private(device_native,name_normalized,name,BleDevice.Origin.EXPLICIT);
  onDiscovered_wrapItUp(newDevice,true,null,null,0);
  return newDevice;
}
Program: 94048
Project: 94048
Buggy source:
/** 
 * Forcefully undiscovers a device, disconnecting it first if needed and removing it from this manager's internal list.  {@link BleManager.DiscoveryListener_Full#onDeviceUndiscovered(BleDevice)} will be called.No clear use case has been thought of but the method is here just in case anyway.
 * @return	true if the device was undiscovered, false if device is already {@link BleDeviceState#UNDISCOVERED} or managerdoesn't contain an instance, checked referentially, not through  {@link BleDevice#equals(BleDevice)} (i.e. by mac address).
 */
public boolean undiscover(BleDevice device){
  if (device == null)   return false;
  if (!hasDevice(device))   return false;
  if (device.is(BleDeviceState.UNDISCOVERED))   return false;
  if (device.is(BleDeviceState.CONNECTED)) {
    device.disconnect();
  }
  m_deviceMngr.undiscoverAndRemove(device,m_discoveryListener,E_Intent.EXPLICIT);
  return true;
}

Fixed version (ground truth):
/** 
 * Forcefully undiscovers a device, disconnecting it first if needed and removing it from this manager's internal list.  {@link BleManager.DiscoveryListener#onDiscoveryEvent(DiscoveryEvent)} with {@link LifeCycle#UNDISCOVERED} will be called.No clear use case has been thought of but the method is here just in case anyway.
 * @return	true if the device was undiscovered, false if device is already {@link BleDeviceState#UNDISCOVERED} or managerdoesn't contain an instance, checked referentially, not through  {@link BleDevice#equals(BleDevice)} (i.e. by mac address).
 */
public boolean undiscover(BleDevice device){
  if (device == null)   return false;
  if (!hasDevice(device))   return false;
  if (device.is(BleDeviceState.UNDISCOVERED))   return false;
  if (device.is(BleDeviceState.CONNECTED)) {
    device.disconnect();
  }
  m_deviceMngr.undiscoverAndRemove(device,m_discoveryListener,E_Intent.EXPLICIT);
  return true;
}
Program: 94049
Project: 94049
Buggy source:
/** 
 * Get a UUID string by transforming shorthand ids into long form ids.
 * @param shorthandIf Short of long form UUID string for a service/characteristic
 * @return UUID string.
 */
public static String uuidStringFromShorthand(String shorthandUuid){
  if (shorthandUuid.length() <= SHORTHAND_LENGTH) {
    long l=Long.parseLong(shorthandUuid,16);
    shorthandUuid=String.format("String_Node_Str" + SHORTHAND_LENGTH + "String_Node_Str",l);
    String result=shorthandUuid + SHORTHAND_UUID_TEMPLATE.substring(SHORTHAND_LENGTH);
    return result;
  }
 else {
    return shorthandUuid;
  }
}

Fixed version (ground truth):
/** 
 * Get a UUID string by transforming shorthand ids into long form ids.
 * @param shorthandUuid Short of long form UUID string for a service/characteristic
 * @return UUID string.
 */
public static String uuidStringFromShorthand(String shorthandUuid){
  if (shorthandUuid.length() <= SHORTHAND_LENGTH) {
    long l=Long.parseLong(shorthandUuid,16);
    shorthandUuid=String.format("String_Node_Str" + SHORTHAND_LENGTH + "String_Node_Str",l);
    String result=shorthandUuid + SHORTHAND_UUID_TEMPLATE.substring(SHORTHAND_LENGTH);
    return result;
  }
 else {
    return shorthandUuid;
  }
}
Program: 94050
Project: 94050
Buggy source:
public void onCharacteristicWrite(BluetoothGatt gatt,UUID uuid,int status){
  getManager().ASSERT(gatt == getDevice().getNativeGatt());
  if (!this.isFor(uuid))   return;
  if (!acknowledgeCallback(status))   return;
  if (Utils.isSuccess(status)) {
    if (weBeChunkin()) {
      if (m_offset >= m_data.length) {
        if (!getDevice().getNativeGatt().executeReliableWrite()) {
          fail(Status.REMOTE_GATT_FAILURE,Target.CHARACTERISTIC,uuid,Result.NON_APPLICABLE_UUID);
          return;
        }
      }
 else {
        writeNextChunk();
        resetTimeout(TIMEOUT_DEFAULT);
      }
    }
 else {
      succeed();
    }
  }
 else {
    fail(Status.REMOTE_GATT_FAILURE,Target.CHARACTERISTIC,uuid,Result.NON_APPLICABLE_UUID);
  }
}

Fixed version (ground truth):
public void onCharacteristicWrite(BluetoothGatt gatt,UUID uuid,int status){
  getManager().ASSERT(gatt == getDevice().getNativeGatt());
  if (!this.isFor(uuid))   return;
  if (!acknowledgeCallback(status))   return;
  if (Utils.isSuccess(status)) {
    if (weBeChunkin()) {
      if (m_offset >= m_data.length) {
        if (!gatt.executeReliableWrite()) {
          fail(Status.REMOTE_GATT_FAILURE,Target.CHARACTERISTIC,uuid,Result.NON_APPLICABLE_UUID);
          return;
        }
      }
 else {
        writeNextChunk();
        resetTimeout(TIMEOUT_DEFAULT);
      }
    }
 else {
      succeed();
    }
  }
 else {
    if (weBeChunkin()) {
      gatt.abortReliableWrite();
    }
    fail(Status.REMOTE_GATT_FAILURE,Target.CHARACTERISTIC,uuid,Result.NON_APPLICABLE_UUID);
  }
}
Program: 94051
Project: 94051
Buggy source:
public void onReliableWriteCompleted(BluetoothGatt gatt,int status){
  if (Utils.isSuccess(status)) {
    succeed();
  }
 else {
    fail(Status.REMOTE_GATT_FAILURE,Target.CHARACTERISTIC,m_char_native.getUuid(),Result.NON_APPLICABLE_UUID);
  }
}

Fixed version (ground truth):
public void onReliableWriteCompleted(BluetoothGatt gatt,int status){
  if (Utils.isSuccess(status)) {
    succeed();
  }
 else {
    abortReliableWriteIfNeeded();
    fail(Status.REMOTE_GATT_FAILURE,Target.CHARACTERISTIC,m_char_native.getUuid(),Result.NON_APPLICABLE_UUID);
  }
}
Program: 94052
Project: 94052
Buggy source:
@Override public void onStateChange(PA_Task task,PE_TaskState state){
  if (state == PE_TaskState.TIMED_OUT) {
    m_logger.w(m_logger.charName(m_characteristic.getUuid()) + "String_Node_Str");
    if (m_readWriteListener != null) {
      m_readWriteListener.onReadOrWriteComplete(newResult(Status.TIMED_OUT,Target.CHARACTERISTIC,m_characteristic.getUuid(),Result.NON_APPLICABLE_UUID));
    }
    getManager().uhOh(UhOh.WRITE_TIMED_OUT);
  }
 else   if (state == PE_TaskState.SOFTLY_CANCELLED) {
    if (m_readWriteListener != null) {
      m_readWriteListener.onReadOrWriteComplete(newResult(Status.CANCELLED,Target.CHARACTERISTIC,m_characteristic.getUuid(),Result.NON_APPLICABLE_UUID));
    }
  }
}

Fixed version (ground truth):
@Override public void onStateChange(PA_Task task,PE_TaskState state){
  if (state == PE_TaskState.TIMED_OUT) {
    m_logger.w(m_logger.charName(m_characteristic.getUuid()) + "String_Node_Str");
    abortReliableWriteIfNeeded();
    if (m_readWriteListener != null) {
      m_readWriteListener.onReadOrWriteComplete(newResult(Status.TIMED_OUT,Target.CHARACTERISTIC,m_characteristic.getUuid(),Result.NON_APPLICABLE_UUID));
    }
    getManager().uhOh(UhOh.WRITE_TIMED_OUT);
  }
 else   if (state == PE_TaskState.SOFTLY_CANCELLED) {
    abortReliableWriteIfNeeded();
    if (m_readWriteListener != null) {
      m_readWriteListener.onReadOrWriteComplete(newResult(Status.CANCELLED,Target.CHARACTERISTIC,m_characteristic.getUuid(),Result.NON_APPLICABLE_UUID));
    }
  }
}
Program: 94053
Project: 94053
Buggy source:
public static boolean isSuccess(int gattStatus){
  return gattStatus == 0 || gattStatus == 1;
}

Fixed version (ground truth):
public static boolean isSuccess(int gattStatus){
  return gattStatus == 0;
}
Program: 94054
Project: 94054
Buggy source:
private void onNativeBondStateChanged_private(int previousState,int newState){
  if (newState == BluetoothDevice.ERROR) {
    P_TaskQueue queue=m_device.getTaskQueue();
    queue.fail(P_Task_Bond.class,m_device);
    queue.fail(P_Task_Unbond.class,m_device);
  }
 else   if (newState == BluetoothDevice.BOND_NONE) {
    m_queue.fail(P_Task_Bond.class,m_device);
    if (!m_queue.succeed(P_Task_Unbond.class,m_device)) {
      m_device.onNativeUnbond();
    }
  }
 else   if (newState == BluetoothDevice.BOND_BONDING) {
    m_device.onNativeBonding();
    if (!m_queue.isCurrent(P_Task_Bond.class,m_device)) {
      m_queue.add(new P_Task_Bond(m_device,false,false,m_taskStateListener,PE_TaskPriority.FOR_IMPLICIT_BONDING_CONNECTING));
    }
    m_queue.fail(P_Task_Unbond.class,m_device);
  }
 else   if (newState == BluetoothDevice.BOND_BONDED) {
    m_queue.fail(P_Task_Unbond.class,m_device);
    if (!m_queue.succeed(P_Task_Bond.class,m_device)) {
      m_device.onNativeBond();
    }
  }
}

Fixed version (ground truth):
private void onNativeBondStateChanged_private(int previousState,int newState){
  if (newState == BluetoothDevice.ERROR) {
    P_TaskQueue queue=m_device.getTaskQueue();
    queue.fail(P_Task_Bond.class,m_device);
    queue.fail(P_Task_Unbond.class,m_device);
  }
 else   if (newState == BluetoothDevice.BOND_NONE) {
    m_queue.fail(P_Task_Bond.class,m_device);
    if (!m_queue.succeed(P_Task_Unbond.class,m_device)) {
      m_device.onNativeUnbond();
    }
  }
 else   if (newState == BluetoothDevice.BOND_BONDING) {
    m_device.onNativeBonding();
    if (!m_queue.isCurrent(P_Task_Bond.class,m_device)) {
      m_queue.add(new P_Task_Bond(m_device,false,false,m_taskStateListener,PE_TaskPriority.FOR_IMPLICIT_BONDING_AND_CONNECTING));
    }
    m_queue.fail(P_Task_Unbond.class,m_device);
  }
 else   if (newState == BluetoothDevice.BOND_BONDED) {
    m_queue.fail(P_Task_Unbond.class,m_device);
    if (!m_queue.succeed(P_Task_Bond.class,m_device)) {
      m_device.onNativeBond();
    }
  }
}
Program: 94056
Project: 94056
Buggy source:
public P_Task_Connect(BleDevice device,I_StateListener listener,boolean explicit,PE_TaskPriority priority){
  super(device,listener,TIMEOUT_CONNECTION);
  m_explicit=explicit;
  m_priority=priority == null ? PE_TaskPriority.FOR_EXPLICIT_BONDING_CONNECTING : priority;
}

Fixed version (ground truth):
public P_Task_Connect(BleDevice device,I_StateListener listener,boolean explicit,PE_TaskPriority priority){
  super(device,listener,TIMEOUT_CONNECTION);
  m_explicit=explicit;
  m_priority=priority == null ? PE_TaskPriority.FOR_EXPLICIT_BONDING_AND_CONNECTING : priority;
}
Program: 94057
Project: 94057
Buggy source:
public P_Task_Disconnect(BleDevice device,I_StateListener listener,boolean explicit,PE_TaskPriority priority){
  super(device,listener);
  m_priority=priority == null ? PE_TaskPriority.FOR_EXPLICIT_BONDING_CONNECTING : priority;
  m_explicit=explicit;
}

Fixed version (ground truth):
public P_Task_Disconnect(BleDevice device,I_StateListener listener,boolean explicit,PE_TaskPriority priority){
  super(device,listener);
  m_priority=priority == null ? PE_TaskPriority.FOR_EXPLICIT_BONDING_AND_CONNECTING : priority;
  m_explicit=explicit;
}
Program: 94058
Project: 94058
Buggy source:
@Override public boolean isInterruptableBy(PA_Task otherTask){
  if (otherTask instanceof P_Task_Read || otherTask instanceof P_Task_Write) {
    if (otherTask.getPriority().ordinal() > PE_TaskPriority.FOR_NORMAL_READS_WRITES.ordinal()) {
      return true;
    }
 else     if (otherTask.getPriority().ordinal() >= this.getPriority().ordinal()) {
      return this.getTotalTimeExecuting() >= getMinimumScanTime();
    }
  }
 else {
    return otherTask.getPriority().ordinal() > this.getPriority().ordinal();
  }
  return super.isInterruptableBy(otherTask);
}

Fixed version (ground truth):
@Override public boolean isInterruptableBy(PA_Task otherTask){
  if (otherTask instanceof P_Task_Read || otherTask instanceof P_Task_Write || otherTask instanceof P_Task_ReadRssi) {
    if (otherTask.getPriority().ordinal() > PE_TaskPriority.FOR_NORMAL_READS_WRITES.ordinal()) {
      return true;
    }
 else     if (otherTask.getPriority().ordinal() >= this.getPriority().ordinal()) {
      return this.getTotalTimeExecuting() >= getMinimumScanTime();
    }
  }
 else {
    return otherTask.getPriority().ordinal() > this.getPriority().ordinal();
  }
  return super.isInterruptableBy(otherTask);
}
Program: 94059
Project: 94059
Buggy source:
@Override public boolean isInterruptableBy(PA_Task task){
  if (task instanceof PA_Task_ReadOrWrite) {
    PA_Task_ReadOrWrite task_cast=(PA_Task_ReadOrWrite)task;
    if (this.getDevice() == task_cast.getDevice() && this.getTxn() == task_cast.getTxn()) {
      return true;
    }
  }
  return super.isInterruptableBy(task);
}

Fixed version (ground truth):
@Override public boolean isInterruptableBy(PA_Task task){
  if (task instanceof PA_Task_Transactionable) {
    PA_Task_Transactionable task_cast=(PA_Task_Transactionable)task;
    if (this.getDevice() == task_cast.getDevice() && this.getTxn() == task_cast.getTxn()) {
      return true;
    }
  }
  return super.isInterruptableBy(task);
}
Program: 94060
Project: 94060
Buggy source:
@Override public PE_TaskPriority getPriority(){
  return PE_TaskPriority.FOR_EXPLICIT_BONDING_CONNECTING;
}

Fixed version (ground truth):
@Override public PE_TaskPriority getPriority(){
  return PE_TaskPriority.FOR_EXPLICIT_BONDING_AND_CONNECTING;
}
Program: 94061
Project: 94061
Buggy source:
public static SpotifyError fromRetrofitError(RetrofitError error){
  ErrorResponse errorResponse=(ErrorResponse)error.getBodyAs(ErrorResponse.class);
  if (errorResponse != null && errorResponse.error != null) {
    String message=errorResponse.error.status + "String_Node_Str" + errorResponse.error.message;
    return new SpotifyError(error,errorResponse.error,message);
  }
 else {
    return new SpotifyError(error);
  }
}

Fixed version (ground truth):
public static SpotifyError fromRetrofitError(RetrofitError error){
  ErrorResponse errorResponse=null;
  try {
    errorResponse=(ErrorResponse)error.getBodyAs(ErrorResponse.class);
  }
 catch (  Exception e) {
    e.printStackTrace();
  }
  if (errorResponse != null && errorResponse.error != null) {
    String message=errorResponse.error.status + "String_Node_Str" + errorResponse.error.message;
    return new SpotifyError(error,errorResponse.error,message);
  }
 else {
    return new SpotifyError(error);
  }
}