nus-yam/ex-repair huggingface dataset:
Program: 162639
Project: 162639
Buggy source:
/** 
 * Tells the <code>BeaconService</code> to stop looking for beacons that match the passed <code>Region</code> object.  Note that the Region's unique identifier is used to match it to an existing monitored Region.
 * @param region
 * @see BeaconManager#setMonitorNotifier(MonitorNotifier)
 * @see BeaconManager#startMonitoringBeaconsInRegion(Region region)
 * @see MonitorNotifier
 * @see Region
 */
@TargetApi(18) public void stopMonitoringBeaconsInRegion(Region region) throws RemoteException {
  if (android.os.Build.VERSION.SDK_INT < 18) {
    LogManager.w(TAG,"String_Node_Str");
    return;
  }
  if (serviceMessenger == null) {
    throw new RemoteException("String_Node_Str");
  }
  Message msg=Message.obtain(null,BeaconService.MSG_STOP_MONITORING,0,0);
  StartRMData obj=new StartRMData(region,callbackPackageName(),this.getScanPeriod(),this.getBetweenScanPeriod(),this.mBackgroundMode);
  msg.obj=obj;
  serviceMessenger.send(msg);
synchronized (monitoredRegions) {
    Region regionToRemove=null;
    for (    Region monitoredRegion : monitoredRegions) {
      if (region.getUniqueId().equals(monitoredRegion.getUniqueId())) {
        regionToRemove=monitoredRegion;
      }
    }
    monitoredRegions.remove(regionToRemove);
  }
}

Fixed version (ground truth):
/** 
 * Tells the <code>BeaconService</code> to stop looking for beacons that match the passed <code>Region</code> object.  Note that the Region's unique identifier is used to match it to an existing monitored Region.
 * @param region
 * @see BeaconManager#setMonitorNotifier(MonitorNotifier)
 * @see BeaconManager#startMonitoringBeaconsInRegion(Region region)
 * @see MonitorNotifier
 * @see Region
 */
@TargetApi(18) public void stopMonitoringBeaconsInRegion(Region region) throws RemoteException {
  if (android.os.Build.VERSION.SDK_INT < 18) {
    LogManager.w(TAG,"String_Node_Str");
    return;
  }
  if (serviceMessenger == null) {
    throw new RemoteException("String_Node_Str");
  }
  Message msg=Message.obtain(null,BeaconService.MSG_STOP_MONITORING,0,0);
  StartRMData obj=new StartRMData(region,callbackPackageName(),this.getScanPeriod(),this.getBetweenScanPeriod(),this.mBackgroundMode);
  msg.obj=obj;
  serviceMessenger.send(msg);
}
Program: 162640
Project: 162640
Buggy source:
/** 
 * @return the list of regions currently being monitored
 */
public Collection<Region> getMonitoredRegions(){
synchronized (this.monitoredRegions) {
    return new ArrayList<Region>(this.monitoredRegions);
  }
}

Fixed version (ground truth):
/** 
 * @return the list of regions currently being monitored
 */
public Collection<Region> getMonitoredRegions(){
  return MonitoringStatus.getInstanceForApplication(mContext).regions();
}
Program: 162641
Project: 162641
Buggy source:
/** 
 * Tells the <code>BeaconService</code> to start looking for beacons that match the passed <code>Region</code> object.  Note that the Region's unique identifier must be retained to later call the stopMonitoringBeaconsInRegion method.
 * @param region
 * @see BeaconManager#setMonitorNotifier(MonitorNotifier)
 * @see BeaconManager#stopMonitoringBeaconsInRegion(Region region)
 * @see MonitorNotifier
 * @see Region
 */
@TargetApi(18) public void startMonitoringBeaconsInRegion(Region region) throws RemoteException {
  if (android.os.Build.VERSION.SDK_INT < 18) {
    LogManager.w(TAG,"String_Node_Str");
    return;
  }
  if (serviceMessenger == null) {
    throw new RemoteException("String_Node_Str");
  }
  LogManager.d(TAG,"String_Node_Str" + region + "String_Node_Str"+ region.getUniqueId());
  Message msg=Message.obtain(null,BeaconService.MSG_START_MONITORING,0,0);
  StartRMData obj=new StartRMData(region,callbackPackageName(),this.getScanPeriod(),this.getBetweenScanPeriod(),this.mBackgroundMode);
  msg.obj=obj;
  serviceMessenger.send(msg);
synchronized (monitoredRegions) {
    this.requestStateForRegion(region);
    monitoredRegions.add(region);
  }
}

Fixed version (ground truth):
/** 
 * Tells the <code>BeaconService</code> to start looking for beacons that match the passed <code>Region</code> object.  Note that the Region's unique identifier must be retained to later call the stopMonitoringBeaconsInRegion method.
 * @param region
 * @see BeaconManager#setMonitorNotifier(MonitorNotifier)
 * @see BeaconManager#stopMonitoringBeaconsInRegion(Region region)
 * @see MonitorNotifier
 * @see Region
 */
@TargetApi(18) public void startMonitoringBeaconsInRegion(Region region) throws RemoteException {
  if (android.os.Build.VERSION.SDK_INT < 18) {
    LogManager.w(TAG,"String_Node_Str");
    return;
  }
  if (serviceMessenger == null) {
    throw new RemoteException("String_Node_Str");
  }
  LogManager.d(TAG,"String_Node_Str" + region + "String_Node_Str"+ region.getUniqueId());
  Message msg=Message.obtain(null,BeaconService.MSG_START_MONITORING,0,0);
  StartRMData obj=new StartRMData(region,callbackPackageName(),this.getScanPeriod(),this.getBetweenScanPeriod(),this.mBackgroundMode);
  msg.obj=obj;
  serviceMessenger.send(msg);
  this.requestStateForRegion(region);
}
Program: 162642
Project: 162642
Buggy source:
@Override public void onDestroy(){
  LogManager.e(TAG,"String_Node_Str");
  if (android.os.Build.VERSION.SDK_INT < 18) {
    LogManager.w(TAG,"String_Node_Str");
    return;
  }
  bluetoothCrashResolver.stop();
  LogManager.i(TAG,"String_Node_Str");
  handler.removeCallbacksAndMessages(null);
  mCycledScanner.stop();
  monitoringStatus.stopStatusPreservation();
}

Fixed version (ground truth):
@Override public void onDestroy(){
  LogManager.e(TAG,"String_Node_Str");
  if (android.os.Build.VERSION.SDK_INT < 18) {
    LogManager.w(TAG,"String_Node_Str");
    return;
  }
  bluetoothCrashResolver.stop();
  LogManager.i(TAG,"String_Node_Str");
  handler.removeCallbacksAndMessages(null);
  mCycledScanner.stop();
  mCycledScanner.destroy();
  monitoringStatus.stopStatusPreservation();
}
Program: 162643
Project: 162643
Buggy source:
public void startMonitoringBeaconsInRegion(Region region,Callback callback){
  LogManager.d(TAG,"String_Node_Str");
  monitoringStatus.addRegion(region);
  LogManager.d(TAG,"String_Node_Str",monitoringStatus.regionsCount());
  mCycledScanner.start();
}

Fixed version (ground truth):
public void startMonitoringBeaconsInRegion(Region region,Callback callback){
  LogManager.d(TAG,"String_Node_Str");
  monitoringStatus.addRegion(region,callback);
  LogManager.d(TAG,"String_Node_Str",monitoringStatus.regionsCount());
  mCycledScanner.start();
}
Program: 162644
Project: 162644
Buggy source:
/** 
 * Tries making the callback, first via messenger, then via intent
 * @param context
 * @param dataName
 * @param data
 * @return false if it callback cannot be made
 */
public boolean call(Context context,String dataName,Parcelable data){
  if (intent != null) {
    LogManager.d(TAG,"String_Node_Str",intent.getComponent());
    intent.putExtra(dataName,data);
    context.startService(intent);
    return true;
  }
  return false;
}

Fixed version (ground truth):
/** 
 * Tries making the callback, first via messenger, then via intent
 * @param context
 * @param dataName
 * @param data
 * @return false if it callback cannot be made
 */
public boolean call(Context context,String dataName,Parcelable data){
  if (intent == null) {
    initializeIntent();
  }
  if (intent != null) {
    LogManager.d(TAG,"String_Node_Str",intent.getComponent());
    intent.putExtra(dataName,data);
    context.startService(intent);
    return true;
  }
  return false;
}
Program: 162645
Project: 162645
Buggy source:
public synchronized void addRegion(Region region){
  if (getRegionsStateMap().containsKey(region)) {
    for (    Region existingRegion : getRegionsStateMap().keySet()) {
      if (existingRegion.equals(region)) {
        if (existingRegion.hasSameIdentifiers(region)) {
          return;
        }
 else {
          LogManager.d(TAG,"String_Node_Str" + region.getUniqueId());
          LogManager.d(TAG,"String_Node_Str" + existingRegion);
          LogManager.d(TAG,"String_Node_Str" + region);
          LogManager.d(TAG,"String_Node_Str");
          getRegionsStateMap().remove(region);
          break;
        }
      }
    }
  }
  getRegionsStateMap().put(region,new RegionMonitoringState(new Callback(mContext.getPackageName())));
  saveMonitoringStatusIfOn();
}

Fixed version (ground truth):
public synchronized void addRegion(Region region,Callback callback){
  if (getRegionsStateMap().containsKey(region)) {
    for (    Region existingRegion : getRegionsStateMap().keySet()) {
      if (existingRegion.equals(region)) {
        if (existingRegion.hasSameIdentifiers(region)) {
          return;
        }
 else {
          LogManager.d(TAG,"String_Node_Str" + region.getUniqueId());
          LogManager.d(TAG,"String_Node_Str" + existingRegion);
          LogManager.d(TAG,"String_Node_Str" + region);
          LogManager.d(TAG,"String_Node_Str");
          getRegionsStateMap().remove(region);
          break;
        }
      }
    }
  }
  getRegionsStateMap().put(region,new RegionMonitoringState(callback));
  saveMonitoringStatusIfOn();
}
Program: 162646
Project: 162646
Buggy source:
protected BluetoothAdapter getBluetoothAdapter(){
  if (mBluetoothAdapter == null) {
    final BluetoothManager bluetoothManager=(BluetoothManager)mContext.getApplicationContext().getSystemService(Context.BLUETOOTH_SERVICE);
    mBluetoothAdapter=bluetoothManager.getAdapter();
    if (mBluetoothAdapter == null) {
      LogManager.w(TAG,"String_Node_Str");
    }
  }
  return mBluetoothAdapter;
}

Fixed version (ground truth):
protected BluetoothAdapter getBluetoothAdapter(){
  try {
    if (mBluetoothAdapter == null) {
      final BluetoothManager bluetoothManager=(BluetoothManager)mContext.getApplicationContext().getSystemService(Context.BLUETOOTH_SERVICE);
      mBluetoothAdapter=bluetoothManager.getAdapter();
      if (mBluetoothAdapter == null) {
        LogManager.w(TAG,"String_Node_Str");
      }
    }
  }
 catch (  SecurityException e) {
    LogManager.e(TAG,"String_Node_Str");
  }
  return mBluetoothAdapter;
}
Program: 162647
Project: 162647
Buggy source:
private void finishScanCycle(){
  LogManager.d(TAG,"String_Node_Str");
  mCycledLeScanCallback.onCycleEnd();
  if (mScanning) {
    if (getBluetoothAdapter() != null) {
      if (getBluetoothAdapter().isEnabled()) {
        long now=System.currentTimeMillis();
        if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.N && mBetweenScanPeriod + mScanPeriod < ANDROID_N_MIN_SCAN_CYCLE_MILLIS && now - mLastScanStopTime < ANDROID_N_MIN_SCAN_CYCLE_MILLIS) {
          LogManager.d(TAG,"String_Node_Str" + "String_Node_Str" + "String_Node_Str" + (ANDROID_N_MIN_SCAN_CYCLE_MILLIS - (now - mLastScanStopTime)) + "String_Node_Str");
        }
 else {
          try {
            LogManager.d(TAG,"String_Node_Str");
            finishScan();
            mLastScanStopTime=now;
          }
 catch (          Exception e) {
            LogManager.w(e,TAG,"String_Node_Str");
          }
        }
        mLastScanCycleEndTime=SystemClock.elapsedRealtime();
      }
 else {
        LogManager.d(TAG,"String_Node_Str");
      }
    }
    mNextScanCycleStartTime=getNextScanStartTime();
    if (mScanningEnabled) {
      scanLeDevice(true);
    }
  }
  if (!mScanningEnabled) {
    LogManager.d(TAG,"String_Node_Str");
    mScanCyclerStarted=false;
    cancelWakeUpAlarm();
  }
}

Fixed version (ground truth):
private void finishScanCycle(){
  LogManager.d(TAG,"String_Node_Str");
  try {
    mCycledLeScanCallback.onCycleEnd();
    if (mScanning) {
      if (getBluetoothAdapter() != null) {
        if (getBluetoothAdapter().isEnabled()) {
          long now=System.currentTimeMillis();
          if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.N && mBetweenScanPeriod + mScanPeriod < ANDROID_N_MIN_SCAN_CYCLE_MILLIS && now - mLastScanStopTime < ANDROID_N_MIN_SCAN_CYCLE_MILLIS) {
            LogManager.d(TAG,"String_Node_Str" + "String_Node_Str" + "String_Node_Str" + (ANDROID_N_MIN_SCAN_CYCLE_MILLIS - (now - mLastScanStopTime)) + "String_Node_Str");
          }
 else {
            try {
              LogManager.d(TAG,"String_Node_Str");
              finishScan();
              mLastScanStopTime=now;
            }
 catch (            Exception e) {
              LogManager.w(e,TAG,"String_Node_Str");
            }
          }
          mLastScanCycleEndTime=SystemClock.elapsedRealtime();
        }
 else {
          LogManager.d(TAG,"String_Node_Str");
        }
      }
      mNextScanCycleStartTime=getNextScanStartTime();
      if (mScanningEnabled) {
        scanLeDevice(true);
      }
    }
    if (!mScanningEnabled) {
      LogManager.d(TAG,"String_Node_Str");
      mScanCyclerStarted=false;
      cancelWakeUpAlarm();
    }
  }
 catch (  SecurityException e) {
    LogManager.w(TAG,"String_Node_Str");
  }
}
Program: 162649
Project: 162649
Buggy source:
protected CycledLeScanner(Context context,long scanPeriod,long betweenScanPeriod,boolean backgroundFlag,CycledLeScanCallback cycledLeScanCallback,BluetoothCrashResolver crashResolver){
  mScanPeriod=scanPeriod;
  mBetweenScanPeriod=betweenScanPeriod;
  mContext=context;
  mCycledLeScanCallback=cycledLeScanCallback;
  mBluetoothCrashResolver=crashResolver;
  mBackgroundFlag=backgroundFlag;
}

Fixed version (ground truth):
protected CycledLeScanner(Context context,long scanPeriod,long betweenScanPeriod,boolean backgroundFlag,CycledLeScanCallback cycledLeScanCallback,BluetoothCrashResolver crashResolver){
  mScanPeriod=scanPeriod;
  mBetweenScanPeriod=betweenScanPeriod;
  mContext=context;
  mCycledLeScanCallback=cycledLeScanCallback;
  mBluetoothCrashResolver=crashResolver;
  mBackgroundFlag=backgroundFlag;
  mScanThread=new HandlerThread("String_Node_Str");
  mScanThread.start();
  mScanHandler=new Handler(mScanThread.getLooper());
}
Program: 162650
Project: 162650
Buggy source:
/** 
 * Specifies a class to remove from the array of <code>MonitorNotifier</code>.
 * @param notifier
 * @see MonitorNotifier
 * @see #startMonitoringBeaconsInRegion(Region region)
 * @see Region
 */
public boolean removeMonitoreNotifier(MonitorNotifier notifier){
synchronized (monitorNotifiers) {
    return monitorNotifiers.remove(notifier);
  }
}

Fixed version (ground truth):
/** 
 * @see #removeMonitorNotifier
 * @deprecated Misspelled. Replaced by {@link #removeMonitorNotifier}
 */
@Deprecated public boolean removeMonitoreNotifier(MonitorNotifier notifier){
  return removeMonitorNotifier(notifier);
}
Program: 162651
Project: 162651
Buggy source:
/** 
 * Specifies a class that should be called each time the <code>BeaconService</code> sees or stops seeing a Region of beacons. <p/> Permits to register severals <code>MonitorNotifier</code> objects. <p/> Unregister the notifier using (@link #removeMonitoreNotifier)
 * @param notifier
 * @see MonitorNotifier
 * @see #startMonitoringBeaconsInRegion(Region region)
 * @see Region
 */
public void addMonitorNotifier(MonitorNotifier notifier){
  if (notifier != null) {
synchronized (monitorNotifiers) {
      monitorNotifiers.add(notifier);
    }
  }
}

Fixed version (ground truth):
/** 
 * Specifies a class that should be called each time the <code>BeaconService</code> sees or stops seeing a Region of beacons. <p/> Permits to register several <code>MonitorNotifier</code> objects. <p/> Unregister the notifier using   {@link #removeMonitoreNotifier}
 * @param notifier The {@link MonitorNotifier} to register.
 * @see MonitorNotifier
 * @see #startMonitoringBeaconsInRegion(Region)
 * @see Region
 */
public void addMonitorNotifier(MonitorNotifier notifier){
  if (notifier != null) {
synchronized (monitorNotifiers) {
      monitorNotifiers.add(notifier);
    }
  }
}
Program: 162652
Project: 162652
Buggy source:
/** 
 * Specifies a class that should be called each time the <code>BeaconService</code> sees or stops seeing a Region of beacons. <p/> IMPORTANT:  Only one MonitorNotifier may be active for a given application.  If two different activities or services set different MonitorNotifier instances, the last one set will receive all the notifications.
 * @param notifier
 * @see MonitorNotifier
 * @see #startMonitoringBeaconsInRegion(Region region)
 * @see Region
 * @deprecated replaced by (@link #addMonitorNotifier)
 */
@Deprecated public void setMonitorNotifier(MonitorNotifier notifier){
synchronized (monitorNotifiers) {
    monitorNotifiers.clear();
  }
  addMonitorNotifier(notifier);
}

Fixed version (ground truth):
/** 
 * Specifies a class that should be called each time the <code>BeaconService</code> sees or stops seeing a Region of beacons. <p/> IMPORTANT:  Only one MonitorNotifier may be active for a given application.  If two different activities or services set different MonitorNotifier instances, the last one set will receive all the notifications.
 * @param notifier The {@link MonitorNotifier} to register.
 * @see MonitorNotifier
 * @see #startMonitoringBeaconsInRegion(Region)
 * @see Region
 * @deprecated replaced by {@link #addMonitorNotifier}
 */
@Deprecated public void setMonitorNotifier(MonitorNotifier notifier){
synchronized (monitorNotifiers) {
    monitorNotifiers.clear();
  }
  addMonitorNotifier(notifier);
}
Program: 162653
Project: 162653
Buggy source:
/** 
 * Remove all the Monitor Notifers
 */
public void removeAllMonitorNotifiers(){
synchronized (monitorNotifiers) {
    monitorNotifiers.clear();
  }
}

Fixed version (ground truth):
/** 
 * Remove all the Monitor Notifiers.
 */
public void removeAllMonitorNotifiers(){
synchronized (monitorNotifiers) {
    monitorNotifiers.clear();
  }
}
Program: 162654
Project: 162654
Buggy source:
/** 
 * Specifies a class that should be called each time the <code>BeaconService</code> gets ranging data, which is nominally once per second when beacons are detected. <p/> IMPORTANT:  Only one RangeNotifier may be active for a given application.  If two different activities or services set different RangeNotifier instances, the last one set will receive all the notifications.
 * @param notifier
 * @see RangeNotifier
 * @deprecated replaced by (@link #addRangeNotifier)
 */
@Deprecated public void setRangeNotifier(RangeNotifier notifier){
synchronized (rangeNotifiers) {
    rangeNotifiers.clear();
  }
  addRangeNotifier(notifier);
}

Fixed version (ground truth):
/** 
 * Specifies a class that should be called each time the <code>BeaconService</code> gets ranging data, which is nominally once per second when beacons are detected. <p/> IMPORTANT:  Only one RangeNotifier may be active for a given application.  If two different activities or services set different RangeNotifier instances, the last one set will receive all the notifications.
 * @param notifier The {@link RangeNotifier} to register.
 * @see RangeNotifier
 * @deprecated replaced by (@link #addRangeNotifier)
 */
@Deprecated public void setRangeNotifier(RangeNotifier notifier){
synchronized (rangeNotifiers) {
    rangeNotifiers.clear();
  }
  addRangeNotifier(notifier);
}
Program: 162655
Project: 162655
Buggy source:
/** 
 * Specifies a class to remove from the array of <code>RangeNotifier</code>
 * @param notifier
 * @see RangeNotifier
 */
public boolean removeRangeNotifier(RangeNotifier notifier){
synchronized (rangeNotifiers) {
    return rangeNotifiers.remove(notifier);
  }
}

Fixed version (ground truth):
/** 
 * Specifies a class to remove from the array of <code>RangeNotifier</code>
 * @param notifier The {@link RangeNotifier} to unregister.
 * @see RangeNotifier
 */
public boolean removeRangeNotifier(RangeNotifier notifier){
synchronized (rangeNotifiers) {
    return rangeNotifiers.remove(notifier);
  }
}
Program: 162656
Project: 162656
Buggy source:
/** 
 * Turns off saving the state of monitored regions to persistent storage so it is retained over app restarts.  Defaults to enabled.  When enabled, there will not be an "extra" region entry event when the app starts up and a beacon for a monitored region was previously visible within the past 15 minutes.  Note that there is a limit to 50 monitored regions that may be perisisted.  If more than 50 regions are monitored, state is not persisted for any.
 * @param enabled
 */
public void setRegionStatePeristenceEnabled(boolean enabled){
  if (enabled) {
    MonitoringStatus.getInstanceForApplication(mContext).startStatusPreservation();
  }
 else {
    MonitoringStatus.getInstanceForApplication(mContext).stopStatusPreservation();
  }
}

Fixed version (ground truth):
/** 
 * @see #setRegionStatePersistenceEnabled
 * @deprecated Misspelled. Replaced by {@link #setRegionStatePersistenceEnabled}
 */
@Deprecated public void setRegionStatePeristenceEnabled(boolean enabled){
  setRegionStatePersistenceEnabled(enabled);
}
Program: 162657
Project: 162657
Buggy source:
/** 
 * Remove all the Range Notifiers
 */
public void removeAllRangeNotifiers(){
synchronized (rangeNotifiers) {
    rangeNotifiers.clear();
  }
}

Fixed version (ground truth):
/** 
 * Remove all the Range Notifiers.
 */
public void removeAllRangeNotifiers(){
synchronized (rangeNotifiers) {
    rangeNotifiers.clear();
  }
}
Program: 162658
Project: 162658
Buggy source:
/** 
 * Specifies a class that should be called each time the <code>BeaconService</code> gets ranging data, which is nominally once per second when beacons are detected. <p/> Permits to register several <code>RangeNotifier</code> objects. <p/> The notifier must be unregistered using (@link #removeRangeNotifier)
 * @param notifier
 * @see RangeNotifier
 */
public void addRangeNotifier(RangeNotifier notifier){
  if (notifier != null) {
synchronized (rangeNotifiers) {
      rangeNotifiers.add(notifier);
    }
  }
}

Fixed version (ground truth):
/** 
 * Specifies a class that should be called each time the <code>BeaconService</code> gets ranging data, which is nominally once per second when beacons are detected. <p/> Permits to register several <code>RangeNotifier</code> objects. <p/> The notifier must be unregistered using (@link #removeRangeNotifier)
 * @param notifier The {@link RangeNotifier} to register.
 * @see RangeNotifier
 */
public void addRangeNotifier(RangeNotifier notifier){
  if (notifier != null) {
synchronized (rangeNotifiers) {
      rangeNotifiers.add(notifier);
    }
  }
}
Program: 162659
Project: 162659
Buggy source:
/** 
 * Tells the <code>BeaconService</code> to start looking for beacons that match the passed <code>Region</code> object.  Note that the Region's unique identifier must be retained to later call the stopMonitoringBeaconsInRegion method.
 * @param region
 * @see BeaconManager#setMonitorNotifier(MonitorNotifier)
 * @see BeaconManager#stopMonitoringBeaconsInRegion(Region region)
 * @see MonitorNotifier
 * @see Region
 */
@TargetApi(18) public void startMonitoringBeaconsInRegion(Region region) throws RemoteException {
  if (android.os.Build.VERSION.SDK_INT < 18) {
    LogManager.w(TAG,"String_Node_Str");
    return;
  }
  if (serviceMessenger == null) {
    throw new RemoteException("String_Node_Str");
  }
  Message msg=Message.obtain(null,BeaconService.MSG_START_MONITORING,0,0);
  StartRMData obj=new StartRMData(region,callbackPackageName(),this.getScanPeriod(),this.getBetweenScanPeriod(),this.mBackgroundMode);
  msg.obj=obj;
  serviceMessenger.send(msg);
synchronized (monitoredRegions) {
    this.requestStateForRegion(region);
    monitoredRegions.add(region);
  }
}

Fixed version (ground truth):
/** 
 * Tells the <code>BeaconService</code> to start looking for beacons that match the passed <code>Region</code> object.  Note that the Region's unique identifier must be retained to later call the stopMonitoringBeaconsInRegion method.
 * @param region
 * @see BeaconManager#setMonitorNotifier(MonitorNotifier)
 * @see BeaconManager#stopMonitoringBeaconsInRegion(Region region)
 * @see MonitorNotifier
 * @see Region
 */
@TargetApi(18) public void startMonitoringBeaconsInRegion(Region region) throws RemoteException {
  if (android.os.Build.VERSION.SDK_INT < 18) {
    LogManager.w(TAG,"String_Node_Str");
    return;
  }
  if (serviceMessenger == null) {
    throw new RemoteException("String_Node_Str");
  }
  LogManager.d(TAG,"String_Node_Str" + region + "String_Node_Str"+ region.getUniqueId());
  Message msg=Message.obtain(null,BeaconService.MSG_START_MONITORING,0,0);
  StartRMData obj=new StartRMData(region,callbackPackageName(),this.getScanPeriod(),this.getBetweenScanPeriod(),this.mBackgroundMode);
  msg.obj=obj;
  serviceMessenger.send(msg);
synchronized (monitoredRegions) {
    this.requestStateForRegion(region);
    monitoredRegions.add(region);
  }
}
Program: 162660
Project: 162660
Buggy source:
/** 
 * Requests the current in/out state on the specified region. If the region is being monitored, this will cause an asynchronous callback on the `MonitorNotifier`'s `didDetermineStateForRegion` method.  If it is not a monitored region, it will be ignored.
 * @param region
 */
public void requestStateForRegion(Region region){
  MonitoringStatus status=MonitoringStatus.getInstanceForApplication(mContext);
  RegionMonitoringState stateObj=status.stateOf(region);
  int state=MonitorNotifier.OUTSIDE;
  if (stateObj != null && stateObj.isInside()) {
    state=MonitorNotifier.INSIDE;
  }
synchronized (monitorNotifiers) {
    for (    MonitorNotifier notifier : monitorNotifiers) {
      notifier.didDetermineStateForRegion(state,region);
    }
  }
}

Fixed version (ground truth):
/** 
 * Requests the current in/out state on the specified region. If the region is being monitored, this will cause an asynchronous callback on the `MonitorNotifier`'s `didDetermineStateForRegion` method.  If it is not a monitored region, it will be ignored.
 * @param region
 */
public void requestStateForRegion(Region region){
  MonitoringStatus status=MonitoringStatus.getInstanceForApplication(mContext);
  RegionMonitoringState stateObj=status.stateOf(region);
  int state=MonitorNotifier.OUTSIDE;
  if (stateObj != null && stateObj.getInside()) {
    state=MonitorNotifier.INSIDE;
  }
synchronized (monitorNotifiers) {
    for (    MonitorNotifier notifier : monitorNotifiers) {
      notifier.didDetermineStateForRegion(state,region);
    }
  }
}
Program: 162662
Project: 162662
Buggy source:
@Override public void onDestroy(){
  LogManager.e(TAG,"String_Node_Str");
  if (android.os.Build.VERSION.SDK_INT < 18) {
    LogManager.w(TAG,"String_Node_Str");
    return;
  }
  bluetoothCrashResolver.stop();
  LogManager.i(TAG,"String_Node_Str");
  handler.removeCallbacksAndMessages(null);
  mCycledScanner.stop();
  monitoringStatus.stopStatusPreservationOnProcessDestruction();
}

Fixed version (ground truth):
@Override public void onDestroy(){
  LogManager.e(TAG,"String_Node_Str");
  if (android.os.Build.VERSION.SDK_INT < 18) {
    LogManager.w(TAG,"String_Node_Str");
    return;
  }
  bluetoothCrashResolver.stop();
  LogManager.i(TAG,"String_Node_Str");
  handler.removeCallbacksAndMessages(null);
  mCycledScanner.stop();
  monitoringStatus.stopStatusPreservation();
}
Program: 162663
Project: 162663
Buggy source:
public synchronized void updateNewlyOutside(){
  Iterator<Region> monitoredRegionIterator=regions().iterator();
  boolean needsMonitoringStateSaving=false;
  while (monitoredRegionIterator.hasNext()) {
    Region region=monitoredRegionIterator.next();
    RegionMonitoringState state=stateOf(region);
    if (state.isNewlyOutside()) {
      needsMonitoringStateSaving=true;
      LogManager.d(TAG,"String_Node_Str",region);
      state.getCallback().call(mContext,"String_Node_Str",new MonitoringData(state.isInside(),region));
    }
  }
  if (needsMonitoringStateSaving) {
    saveMonitoringStatusIfOn();
  }
 else {
    updateMonitoringStatusTime(System.currentTimeMillis());
  }
}

Fixed version (ground truth):
public synchronized void updateNewlyOutside(){
  Iterator<Region> monitoredRegionIterator=regions().iterator();
  boolean needsMonitoringStateSaving=false;
  while (monitoredRegionIterator.hasNext()) {
    Region region=monitoredRegionIterator.next();
    RegionMonitoringState state=stateOf(region);
    if (state.markOutsideIfExpired()) {
      needsMonitoringStateSaving=true;
      LogManager.d(TAG,"String_Node_Str",region);
      state.getCallback().call(mContext,"String_Node_Str",new MonitoringData(state.getInside(),region));
    }
  }
  if (needsMonitoringStateSaving) {
    saveMonitoringStatusIfOn();
  }
 else {
    updateMonitoringStatusTime(System.currentTimeMillis());
  }
}
Program: 162664
Project: 162664
Buggy source:
public synchronized void updateNewlyInsideInRegionsContaining(Beacon beacon){
  List<Region> matchingRegions=regionsMatchingTo(beacon);
  boolean needsMonitoringStateSaving=false;
  for (  Region region : matchingRegions) {
    RegionMonitoringState state=mRegionsStatesMap.get(region);
    if (state != null && state.markInside()) {
      needsMonitoringStateSaving=true;
      state.getCallback().call(mContext,"String_Node_Str",new MonitoringData(state.isInside(),region));
    }
  }
  if (needsMonitoringStateSaving) {
    saveMonitoringStatusIfOn();
  }
 else {
    updateMonitoringStatusTime(System.currentTimeMillis());
  }
}

Fixed version (ground truth):
public synchronized void updateNewlyInsideInRegionsContaining(Beacon beacon){
  List<Region> matchingRegions=regionsMatchingTo(beacon);
  boolean needsMonitoringStateSaving=false;
  for (  Region region : matchingRegions) {
    RegionMonitoringState state=mRegionsStatesMap.get(region);
    if (state != null && state.markInside()) {
      needsMonitoringStateSaving=true;
      state.getCallback().call(mContext,"String_Node_Str",new MonitoringData(state.getInside(),region));
    }
  }
  if (needsMonitoringStateSaving) {
    saveMonitoringStatusIfOn();
  }
 else {
    updateMonitoringStatusTime(System.currentTimeMillis());
  }
}
Program: 162665
Project: 162665
Buggy source:
public synchronized void addRegion(Region region){
  if (mRegionsStatesMap.containsKey(region))   return;
  mRegionsStatesMap.put(region,new RegionMonitoringState(new Callback(mContext.getPackageName())));
  saveMonitoringStatusIfOn();
}

Fixed version (ground truth):
public synchronized void addRegion(Region region){
  if (mRegionsStatesMap.containsKey(region)) {
    for (    Region existingRegion : mRegionsStatesMap.keySet()) {
      if (existingRegion.equals(region)) {
        if (existingRegion.hasSameIdentifiers(region)) {
          return;
        }
 else {
          LogManager.d(TAG,"String_Node_Str" + region.getUniqueId());
          LogManager.d(TAG,"String_Node_Str" + existingRegion);
          LogManager.d(TAG,"String_Node_Str" + region);
          LogManager.d(TAG,"String_Node_Str");
        }
      }
    }
    return;
  }
  mRegionsStatesMap.put(region,new RegionMonitoringState(new Callback(mContext.getPackageName())));
  saveMonitoringStatusIfOn();
}
Program: 162666
Project: 162666
Buggy source:
public MonitoringStatus(Context context){
  this.mContext=context;
  long millisSinceLastMonitor=System.currentTimeMillis() - getLastMonitoringStatusUpdateTime();
  if (millisSinceLastMonitor > MAX_STATUS_PRESERVATION_FILE_AGE_TO_RESTORE_SECS * 1000) {
    LogManager.d(TAG,"String_Node_Str" + millisSinceLastMonitor);
  }
 else {
    restoreMonitoringStatus();
  }
}

Fixed version (ground truth):
public MonitoringStatus(Context context){
  this.mContext=context;
  long millisSinceLastMonitor=System.currentTimeMillis() - getLastMonitoringStatusUpdateTime();
  if (millisSinceLastMonitor > MAX_STATUS_PRESERVATION_FILE_AGE_TO_RESTORE_SECS * 1000) {
    LogManager.d(TAG,"String_Node_Str" + millisSinceLastMonitor);
  }
 else {
    restoreMonitoringStatus();
    LogManager.d(TAG,"String_Node_Str");
  }
}
Program: 162667
Project: 162667
Buggy source:
protected void restoreMonitoringStatus(){
  FileInputStream inputStream=null;
  ObjectInputStream objectInputStream=null;
  try {
    inputStream=mContext.openFileInput(STATUS_PRESERVATION_FILE_NAME);
    objectInputStream=new ObjectInputStream(inputStream);
    Map<Region,RegionMonitoringState> obj=(Map<Region,RegionMonitoringState>)objectInputStream.readObject();
    mRegionsStatesMap.putAll(obj);
  }
 catch (  IOException|ClassNotFoundException|ClassCastException e) {
    if (e instanceof InvalidClassException) {
      LogManager.d(TAG,"String_Node_Str");
    }
 else     LogManager.e(TAG,"String_Node_Str",e.getMessage());
  }
 finally {
    if (null != inputStream) {
      try {
        inputStream.close();
      }
 catch (      IOException ignored) {
      }
    }
    if (objectInputStream != null) {
      try {
        objectInputStream.close();
      }
 catch (      IOException ignored) {
      }
    }
  }
}

Fixed version (ground truth):
protected void restoreMonitoringStatus(){
  FileInputStream inputStream=null;
  ObjectInputStream objectInputStream=null;
  try {
    inputStream=mContext.openFileInput(STATUS_PRESERVATION_FILE_NAME);
    objectInputStream=new ObjectInputStream(inputStream);
    Map<Region,RegionMonitoringState> obj=(Map<Region,RegionMonitoringState>)objectInputStream.readObject();
    LogManager.d(TAG,"String_Node_Str" + obj.size() + "String_Node_Str");
    for (    Region region : obj.keySet()) {
      LogManager.d(TAG,"String_Node_Str" + region + "String_Node_Str"+ region.getUniqueId()+ "String_Node_Str"+ obj.get(region));
    }
    mRegionsStatesMap.putAll(obj);
  }
 catch (  IOException|ClassNotFoundException|ClassCastException e) {
    if (e instanceof InvalidClassException) {
      LogManager.d(TAG,"String_Node_Str");
    }
 else     LogManager.e(TAG,"String_Node_Str",e.getMessage());
  }
 finally {
    if (null != inputStream) {
      try {
        inputStream.close();
      }
 catch (      IOException ignored) {
      }
    }
    if (objectInputStream != null) {
      try {
        objectInputStream.close();
      }
 catch (      IOException ignored) {
      }
    }
  }
}
Program: 162670
Project: 162670
Buggy source:
private void loadModelMap(){
  boolean mapLoaded=false;
  if (mRemoteUpdateUrlString != null) {
    mapLoaded=loadModelMapFromFile();
    if (!mapLoaded) {
      requestModelMapFromWeb();
    }
  }
  if (!mapLoaded) {
    loadDefaultModelMap();
  }
  mDistanceCalculator=findCalculatorForModel(mRequestedModel);
}

Fixed version (ground truth):
private void loadModelMap(){
  boolean mapLoaded=false;
  if (mRemoteUpdateUrlString != null) {
    mapLoaded=loadModelMapFromFile();
    if (!mapLoaded) {
      requestModelMapFromWeb();
    }
  }
  if (!mapLoaded) {
    loadDefaultModelMap();
  }
  mDistanceCalculator=findCalculatorForModelWithLock(mRequestedModel);
}
Program: 162671
Project: 162671
Buggy source:
@Override public void onComplete(String body,Exception ex,int code){
  if (ex != null) {
    LogManager.w(TAG,"String_Node_Str",ex,mRemoteUpdateUrlString);
  }
 else   if (code != 200) {
    LogManager.w(TAG,"String_Node_Str" + "String_Node_Str",mRemoteUpdateUrlString,code);
  }
 else {
    LogManager.d(TAG,"String_Node_Str");
    try {
      buildModelMap(body);
      if (saveJson(body)) {
        loadModelMapFromFile();
        mDistanceCalculator=findCalculatorForModel(mRequestedModel);
        LogManager.i(TAG,"String_Node_Str");
      }
    }
 catch (    JSONException e) {
      LogManager.w(e,TAG,"String_Node_Str");
    }
  }
}

Fixed version (ground truth):
@Override public void onComplete(String body,Exception ex,int code){
  if (ex != null) {
    LogManager.w(TAG,"String_Node_Str",ex,mRemoteUpdateUrlString);
  }
 else   if (code != 200) {
    LogManager.w(TAG,"String_Node_Str" + "String_Node_Str",mRemoteUpdateUrlString,code);
  }
 else {
    LogManager.d(TAG,"String_Node_Str");
    try {
      buildModelMapWithLock(body);
      if (saveJson(body)) {
        loadModelMapFromFile();
        mDistanceCalculator=findCalculatorForModelWithLock(mRequestedModel);
        LogManager.i(TAG,"String_Node_Str");
      }
    }
 catch (    JSONException e) {
      LogManager.w(e,TAG,"String_Node_Str");
    }
  }
}
Program: 162672
Project: 162672
Buggy source:
@TargetApi(Build.VERSION_CODES.HONEYCOMB) private void requestModelMapFromWeb(){
  if (mContext.checkCallingOrSelfPermission("String_Node_Str") != PackageManager.PERMISSION_GRANTED) {
    LogManager.w(TAG,"String_Node_Str");
    return;
  }
  new ModelSpecificDistanceUpdater(mContext,mRemoteUpdateUrlString,new ModelSpecificDistanceUpdater.CompletionHandler(){
    @Override public void onComplete(    String body,    Exception ex,    int code){
      if (ex != null) {
        LogManager.w(TAG,"String_Node_Str",ex,mRemoteUpdateUrlString);
      }
 else       if (code != 200) {
        LogManager.w(TAG,"String_Node_Str" + "String_Node_Str",mRemoteUpdateUrlString,code);
      }
 else {
        LogManager.d(TAG,"String_Node_Str");
        try {
          buildModelMap(body);
          if (saveJson(body)) {
            loadModelMapFromFile();
            mDistanceCalculator=findCalculatorForModel(mRequestedModel);
            LogManager.i(TAG,"String_Node_Str");
          }
        }
 catch (        JSONException e) {
          LogManager.w(e,TAG,"String_Node_Str");
        }
      }
    }
  }
).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}

Fixed version (ground truth):
@TargetApi(Build.VERSION_CODES.HONEYCOMB) private void requestModelMapFromWeb(){
  if (mContext.checkCallingOrSelfPermission("String_Node_Str") != PackageManager.PERMISSION_GRANTED) {
    LogManager.w(TAG,"String_Node_Str");
    return;
  }
  new ModelSpecificDistanceUpdater(mContext,mRemoteUpdateUrlString,new ModelSpecificDistanceUpdater.CompletionHandler(){
    @Override public void onComplete(    String body,    Exception ex,    int code){
      if (ex != null) {
        LogManager.w(TAG,"String_Node_Str",ex,mRemoteUpdateUrlString);
      }
 else       if (code != 200) {
        LogManager.w(TAG,"String_Node_Str" + "String_Node_Str",mRemoteUpdateUrlString,code);
      }
 else {
        LogManager.d(TAG,"String_Node_Str");
        try {
          buildModelMapWithLock(body);
          if (saveJson(body)) {
            loadModelMapFromFile();
            mDistanceCalculator=findCalculatorForModelWithLock(mRequestedModel);
            LogManager.i(TAG,"String_Node_Str");
          }
        }
 catch (        JSONException e) {
          LogManager.w(e,TAG,"String_Node_Str");
        }
      }
    }
  }
).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}
Program: 162673
Project: 162673
Buggy source:
/** 
 * Obtains the best possible <code>DistanceCalculator</code> for the Android device passed as an argument
 */
public ModelSpecificDistanceCalculator(Context context,String remoteUpdateUrlString,AndroidModel model){
  mRequestedModel=model;
  mRemoteUpdateUrlString=remoteUpdateUrlString;
  mContext=context;
  loadModelMap();
  mDistanceCalculator=findCalculatorForModel(model);
}

Fixed version (ground truth):
/** 
 * Obtains the best possible <code>DistanceCalculator</code> for the Android device passed as an argument
 */
public ModelSpecificDistanceCalculator(Context context,String remoteUpdateUrlString,AndroidModel model){
  mRequestedModel=model;
  mRemoteUpdateUrlString=remoteUpdateUrlString;
  mContext=context;
  loadModelMap();
  mDistanceCalculator=findCalculatorForModelWithLock(model);
}
Program: 162674
Project: 162674
Buggy source:
private boolean loadModelMapFromFile(){
  File file=new File(mContext.getFilesDir(),CONFIG_FILE);
  FileInputStream inputStream=null;
  BufferedReader reader=null;
  StringBuilder sb=new StringBuilder();
  try {
    inputStream=new FileInputStream(file);
    reader=new BufferedReader(new InputStreamReader(inputStream));
    String line;
    while ((line=reader.readLine()) != null) {
      sb.append(line).append("String_Node_Str");
    }
  }
 catch (  FileNotFoundException fnfe) {
    return false;
  }
catch (  IOException e) {
    LogManager.e(e,TAG,"String_Node_Str",file);
    return false;
  }
 finally {
    if (reader != null) {
      try {
        reader.close();
      }
 catch (      Exception e2) {
      }
    }
    if (inputStream != null) {
      try {
        inputStream.close();
      }
 catch (      Exception e2) {
      }
    }
  }
  try {
    buildModelMap(sb.toString());
    return true;
  }
 catch (  JSONException e) {
    LogManager.e(TAG,"String_Node_Str",e,mRemoteUpdateUrlString,sb.toString());
    return false;
  }
}

Fixed version (ground truth):
private boolean loadModelMapFromFile(){
  File file=new File(mContext.getFilesDir(),CONFIG_FILE);
  FileInputStream inputStream=null;
  BufferedReader reader=null;
  StringBuilder sb=new StringBuilder();
  try {
    inputStream=new FileInputStream(file);
    reader=new BufferedReader(new InputStreamReader(inputStream));
    String line;
    while ((line=reader.readLine()) != null) {
      sb.append(line).append("String_Node_Str");
    }
  }
 catch (  FileNotFoundException fnfe) {
    return false;
  }
catch (  IOException e) {
    LogManager.e(e,TAG,"String_Node_Str",file);
    return false;
  }
 finally {
    if (reader != null) {
      try {
        reader.close();
      }
 catch (      Exception e2) {
      }
    }
    if (inputStream != null) {
      try {
        inputStream.close();
      }
 catch (      Exception e2) {
      }
    }
  }
  try {
    buildModelMapWithLock(sb.toString());
    return true;
  }
 catch (  JSONException e) {
    LogManager.e(TAG,"String_Node_Str",e,mRemoteUpdateUrlString,sb.toString());
    return false;
  }
}
Program: 162675
Project: 162675
Buggy source:
private void loadModelMap(){
  boolean mapLoaded=false;
  if (mRemoteUpdateUrlString != null) {
    mapLoaded=loadModelMapFromFile();
    if (!mapLoaded) {
      requestModelMapFromWeb();
    }
  }
  if (!mapLoaded) {
    loadDefaultModelMap();
  }
  mDistanceCalculator=findCalculatorForModel(mRequestedModel);
}

Fixed version (ground truth):
private void loadModelMap(){
  boolean mapLoaded=false;
  if (mRemoteUpdateUrlString != null) {
    mapLoaded=loadModelMapFromFile();
    if (!mapLoaded) {
      requestModelMapFromWeb();
    }
  }
  if (!mapLoaded) {
    loadDefaultModelMap();
  }
  mDistanceCalculator=findCalculatorForModelWithLock(mRequestedModel);
}
Program: 162676
Project: 162676
Buggy source:
@Override public void onComplete(String body,Exception ex,int code){
  if (ex != null) {
    LogManager.w(TAG,"String_Node_Str",ex,mRemoteUpdateUrlString);
  }
 else   if (code != 200) {
    LogManager.w(TAG,"String_Node_Str" + "String_Node_Str",mRemoteUpdateUrlString,code);
  }
 else {
    LogManager.d(TAG,"String_Node_Str");
    try {
      buildModelMap(body);
      if (saveJson(body)) {
        loadModelMapFromFile();
        mDistanceCalculator=findCalculatorForModel(mRequestedModel);
        LogManager.i(TAG,"String_Node_Str");
      }
    }
 catch (    JSONException e) {
      LogManager.w(e,TAG,"String_Node_Str");
    }
  }
}

Fixed version (ground truth):
@Override public void onComplete(String body,Exception ex,int code){
  if (ex != null) {
    LogManager.w(TAG,"String_Node_Str",ex,mRemoteUpdateUrlString);
  }
 else   if (code != 200) {
    LogManager.w(TAG,"String_Node_Str" + "String_Node_Str",mRemoteUpdateUrlString,code);
  }
 else {
    LogManager.d(TAG,"String_Node_Str");
    try {
      buildModelMapWithLock(body);
      if (saveJson(body)) {
        loadModelMapFromFile();
        mDistanceCalculator=findCalculatorForModelWithLock(mRequestedModel);
        LogManager.i(TAG,"String_Node_Str");
      }
    }
 catch (    JSONException e) {
      LogManager.w(e,TAG,"String_Node_Str");
    }
  }
}
Program: 162677
Project: 162677
Buggy source:
@TargetApi(Build.VERSION_CODES.HONEYCOMB) private void requestModelMapFromWeb(){
  if (mContext.checkCallingOrSelfPermission("String_Node_Str") != PackageManager.PERMISSION_GRANTED) {
    LogManager.w(TAG,"String_Node_Str");
    return;
  }
  new ModelSpecificDistanceUpdater(mContext,mRemoteUpdateUrlString,new ModelSpecificDistanceUpdater.CompletionHandler(){
    @Override public void onComplete(    String body,    Exception ex,    int code){
      if (ex != null) {
        LogManager.w(TAG,"String_Node_Str",ex,mRemoteUpdateUrlString);
      }
 else       if (code != 200) {
        LogManager.w(TAG,"String_Node_Str" + "String_Node_Str",mRemoteUpdateUrlString,code);
      }
 else {
        LogManager.d(TAG,"String_Node_Str");
        try {
          buildModelMap(body);
          if (saveJson(body)) {
            loadModelMapFromFile();
            mDistanceCalculator=findCalculatorForModel(mRequestedModel);
            LogManager.i(TAG,"String_Node_Str");
          }
        }
 catch (        JSONException e) {
          LogManager.w(e,TAG,"String_Node_Str");
        }
      }
    }
  }
).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}

Fixed version (ground truth):
@TargetApi(Build.VERSION_CODES.HONEYCOMB) private void requestModelMapFromWeb(){
  if (mContext.checkCallingOrSelfPermission("String_Node_Str") != PackageManager.PERMISSION_GRANTED) {
    LogManager.w(TAG,"String_Node_Str");
    return;
  }
  new ModelSpecificDistanceUpdater(mContext,mRemoteUpdateUrlString,new ModelSpecificDistanceUpdater.CompletionHandler(){
    @Override public void onComplete(    String body,    Exception ex,    int code){
      if (ex != null) {
        LogManager.w(TAG,"String_Node_Str",ex,mRemoteUpdateUrlString);
      }
 else       if (code != 200) {
        LogManager.w(TAG,"String_Node_Str" + "String_Node_Str",mRemoteUpdateUrlString,code);
      }
 else {
        LogManager.d(TAG,"String_Node_Str");
        try {
          buildModelMapWithLock(body);
          if (saveJson(body)) {
            loadModelMapFromFile();
            mDistanceCalculator=findCalculatorForModelWithLock(mRequestedModel);
            LogManager.i(TAG,"String_Node_Str");
          }
        }
 catch (        JSONException e) {
          LogManager.w(e,TAG,"String_Node_Str");
        }
      }
    }
  }
).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}
Program: 162678
Project: 162678
Buggy source:
/** 
 * Obtains the best possible <code>DistanceCalculator</code> for the Android device passed as an argument
 */
public ModelSpecificDistanceCalculator(Context context,String remoteUpdateUrlString,AndroidModel model){
  mRequestedModel=model;
  mRemoteUpdateUrlString=remoteUpdateUrlString;
  mContext=context;
  loadModelMap();
  mDistanceCalculator=findCalculatorForModel(model);
}

Fixed version (ground truth):
/** 
 * Obtains the best possible <code>DistanceCalculator</code> for the Android device passed as an argument
 */
public ModelSpecificDistanceCalculator(Context context,String remoteUpdateUrlString,AndroidModel model){
  mRequestedModel=model;
  mRemoteUpdateUrlString=remoteUpdateUrlString;
  mContext=context;
  loadModelMap();
  mDistanceCalculator=findCalculatorForModelWithLock(model);
}
Program: 162679
Project: 162679
Buggy source:
private boolean loadModelMapFromFile(){
  File file=new File(mContext.getFilesDir(),CONFIG_FILE);
  FileInputStream inputStream=null;
  BufferedReader reader=null;
  StringBuilder sb=new StringBuilder();
  try {
    inputStream=new FileInputStream(file);
    reader=new BufferedReader(new InputStreamReader(inputStream));
    String line;
    while ((line=reader.readLine()) != null) {
      sb.append(line).append("String_Node_Str");
    }
  }
 catch (  FileNotFoundException fnfe) {
    return false;
  }
catch (  IOException e) {
    LogManager.e(e,TAG,"String_Node_Str",file);
    return false;
  }
 finally {
    if (reader != null) {
      try {
        reader.close();
      }
 catch (      Exception e2) {
      }
    }
    if (inputStream != null) {
      try {
        inputStream.close();
      }
 catch (      Exception e2) {
      }
    }
  }
  try {
    buildModelMap(sb.toString());
    return true;
  }
 catch (  JSONException e) {
    LogManager.e(TAG,"String_Node_Str",e,mRemoteUpdateUrlString,sb.toString());
    return false;
  }
}

Fixed version (ground truth):
private boolean loadModelMapFromFile(){
  File file=new File(mContext.getFilesDir(),CONFIG_FILE);
  FileInputStream inputStream=null;
  BufferedReader reader=null;
  StringBuilder sb=new StringBuilder();
  try {
    inputStream=new FileInputStream(file);
    reader=new BufferedReader(new InputStreamReader(inputStream));
    String line;
    while ((line=reader.readLine()) != null) {
      sb.append(line).append("String_Node_Str");
    }
  }
 catch (  FileNotFoundException fnfe) {
    return false;
  }
catch (  IOException e) {
    LogManager.e(e,TAG,"String_Node_Str",file);
    return false;
  }
 finally {
    if (reader != null) {
      try {
        reader.close();
      }
 catch (      Exception e2) {
      }
    }
    if (inputStream != null) {
      try {
        inputStream.close();
      }
 catch (      Exception e2) {
      }
    }
  }
  try {
    buildModelMapWithLock(sb.toString());
    return true;
  }
 catch (  JSONException e) {
    LogManager.e(TAG,"String_Node_Str",e,mRemoteUpdateUrlString,sb.toString());
    return false;
  }
}