nus-yam/ex-repair huggingface dataset:
Program: 162681
Project: 162681
Buggy source:
private static Identifier parseHex(String identifierString){
  String str=identifierString.length() % 2 == 0 ? "String_Node_Str" : "String_Node_Str";
  str+=identifierString.toUpperCase();
  byte[] result=new byte[str.length() / 2];
  for (int i=0; i < result.length; i++) {
    result[i]=(byte)(Integer.parseInt(str.substring(i * 2,i * 2 + 2),16) & 0xFF);
  }
  return new Identifier(result);
}

Fixed version (ground truth):
private static Identifier parseHex(String identifierString,int desiredByteLength){
  String str=identifierString.length() % 2 == 0 ? "String_Node_Str" : "String_Node_Str";
  str+=identifierString.toUpperCase();
  if (desiredByteLength > 0 && desiredByteLength < str.length() / 2) {
    str=str.substring(str.length() - desiredByteLength * 2);
  }
  if (desiredByteLength > 0 && desiredByteLength > str.length() / 2) {
    int extraCharsToAdd=desiredByteLength * 2 - str.length();
    StringBuilder sb=new StringBuilder();
    while (sb.length() < extraCharsToAdd) {
      sb.append("String_Node_Str");
    }
    str=sb.toString() + str;
  }
  byte[] result=new byte[str.length() / 2];
  for (int i=0; i < result.length; i++) {
    result[i]=(byte)(Integer.parseInt(str.substring(i * 2,i * 2 + 2),16) & 0xFF);
  }
  return new Identifier(result);
}
Program: 162682
Project: 162682
Buggy source:
/** 
 * Takes the passed string and tries to figure out what format it is in. Then turns the string into plain bytes and constructs an Identifier. Known bug: This method happily parses UUIDs without dashes (normally invalid). Although the bug is left unfixed for backward compatibility, please check your UUIDs or even better, use  {@link #fromUuid(java.util.UUID)} directly, which is safe.Allowed formats: <ul> <li>UUID: 2F234454-CF6D-4A0F-ADF2-F4911BA9FFA6 (16 bytes)</li> <li>Hexadecimal: 0x000000000003 (variable length)</li> <li>Decimal: 1337 (2 bytes)</li> </ul>
 * @param stringValue string to parse
 * @return             Identifier representing the specified value
 * @throws IllegalArgumentException if the passed string cannot be parsed
 * @throws NullPointerException if the passed string is <code>null</code>
 * @see                <a href="https://www.ietf.org/rfc/rfc4122.txt">RFC 4122 on UUIDs</a>
 */
public static Identifier parse(String stringValue){
  if (stringValue == null) {
    throw new NullPointerException("String_Node_Str");
  }
  if (HEX_PATTERN.matcher(stringValue).matches()) {
    return parseHex(stringValue.substring(2));
  }
  if (UUID_PATTERN.matcher(stringValue).matches()) {
    return parseHex(stringValue.replace("String_Node_Str","String_Node_Str"));
  }
  if (DECIMAL_PATTERN.matcher(stringValue).matches()) {
    int value=-1;
    try {
      value=Integer.valueOf(stringValue);
    }
 catch (    Throwable t) {
      throw new IllegalArgumentException("String_Node_Str",t);
    }
    return fromInt(value);
  }
  throw new IllegalArgumentException("String_Node_Str");
}

Fixed version (ground truth):
/** 
 * Variant of the parse method that allows specifying the byte length of the identifier.
 * @see #parse(String)
 * @param stringValue
 * @param desiredByteLength
 * @return
 */
public static Identifier parse(String stringValue,int desiredByteLength){
  if (stringValue == null) {
    throw new NullPointerException("String_Node_Str");
  }
  if (HEX_PATTERN.matcher(stringValue).matches()) {
    return parseHex(stringValue.substring(2),desiredByteLength);
  }
  if (UUID_PATTERN.matcher(stringValue).matches()) {
    return parseHex(stringValue.replace("String_Node_Str","String_Node_Str"),desiredByteLength);
  }
  if (DECIMAL_PATTERN.matcher(stringValue).matches()) {
    int value=-1;
    try {
      value=Integer.valueOf(stringValue);
    }
 catch (    Throwable t) {
      throw new IllegalArgumentException("String_Node_Str",t);
    }
    if (desiredByteLength <= 0 || desiredByteLength == 2) {
      return fromInt(value);
    }
 else {
      return fromLong(value,desiredByteLength);
    }
  }
  if (HEX_PATTERN_NO_PREFIX.matcher(stringValue).matches()) {
    return parseHex(stringValue,desiredByteLength);
  }
  throw new IllegalArgumentException("String_Node_Str");
}
Program: 162683
Project: 162683
Buggy source:
/** 
 * Converts identifier to a byte array
 * @param bigEndian true if bytes are MSB first
 * @return a new byte array with a copy of the value
 */
public byte[] toByteArrayOfSpecifiedEndianness(boolean bigEndian){
  byte[] copy=Arrays.copyOf(mValue,mValue.length);
  if (!bigEndian) {
    reverseArray(copy);
  }
  return copy;
}

Fixed version (ground truth):
/** 
 * Converts identifier to a byte array
 * @param bigEndian true if bytes are MSB first
 * @return a new byte array with a copy of the value
 */
@TargetApi(Build.VERSION_CODES.GINGERBREAD) public byte[] toByteArrayOfSpecifiedEndianness(boolean bigEndian){
  byte[] copy=Arrays.copyOf(mValue,mValue.length);
  if (!bigEndian) {
    reverseArray(copy);
  }
  return copy;
}
Program: 162684
Project: 162684
Buggy source:
/** 
 * Creates an Identifier from the specified byte array.
 * @param bytes array to copy from
 * @param start the start index, inclusive
 * @param end the end index, exclusive
 * @param littleEndian whether the bytes are ordered in little endian
 * @return a new Identifier
 * @throws java.lang.NullPointerException <code>bytes</code> must not be <code>null</code>
 * @throws java.lang.ArrayIndexOutOfBoundsException start or end are outside the bounds of the array
 * @throws java.lang.IllegalArgumentException start is larger than end
 */
public static Identifier fromBytes(byte[] bytes,int start,int end,boolean littleEndian){
  if (bytes == null) {
    throw new NullPointerException("String_Node_Str");
  }
  if (start < 0 || start > bytes.length) {
    throw new ArrayIndexOutOfBoundsException("String_Node_Str");
  }
  if (end > bytes.length) {
    throw new ArrayIndexOutOfBoundsException("String_Node_Str");
  }
  if (start > end) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  byte[] byteRange=Arrays.copyOfRange(bytes,start,end);
  if (littleEndian) {
    reverseArray(byteRange);
  }
  return new Identifier(byteRange);
}

Fixed version (ground truth):
/** 
 * Creates an Identifier from the specified byte array.
 * @param bytes array to copy from
 * @param start the start index, inclusive
 * @param end the end index, exclusive
 * @param littleEndian whether the bytes are ordered in little endian
 * @return a new Identifier
 * @throws java.lang.NullPointerException <code>bytes</code> must not be <code>null</code>
 * @throws java.lang.ArrayIndexOutOfBoundsException start or end are outside the bounds of the array
 * @throws java.lang.IllegalArgumentException start is larger than end
 */
@TargetApi(Build.VERSION_CODES.GINGERBREAD) public static Identifier fromBytes(byte[] bytes,int start,int end,boolean littleEndian){
  if (bytes == null) {
    throw new NullPointerException("String_Node_Str");
  }
  if (start < 0 || start > bytes.length) {
    throw new ArrayIndexOutOfBoundsException("String_Node_Str");
  }
  if (end > bytes.length) {
    throw new ArrayIndexOutOfBoundsException("String_Node_Str");
  }
  if (start > end) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  byte[] byteRange=Arrays.copyOfRange(bytes,start,end);
  if (littleEndian) {
    reverseArray(byteRange);
  }
  return new Identifier(byteRange);
}
Program: 162685
Project: 162685
Buggy source:
/** 
 * methods for clients
 */
public void startRangingBeaconsInRegion(Region region,Callback callback){
synchronized (rangedRegionState) {
    if (rangedRegionState.containsKey(region)) {
      LogManager.i(TAG,"String_Node_Str");
      rangedRegionState.remove(region);
    }
    rangedRegionState.put(region,new RangeState(callback));
    LogManager.d(TAG,"String_Node_Str",rangedRegionState.size());
  }
  if (!scanningEnabled) {
    mCycledScanner.start();
  }
}

Fixed version (ground truth):
/** 
 * methods for clients
 */
public void startRangingBeaconsInRegion(Region region,Callback callback){
synchronized (rangedRegionState) {
    if (rangedRegionState.containsKey(region)) {
      LogManager.i(TAG,"String_Node_Str");
      rangedRegionState.remove(region);
    }
    rangedRegionState.put(region,new RangeState(callback));
    LogManager.d(TAG,"String_Node_Str",rangedRegionState.size());
  }
  mCycledScanner.start();
}
Program: 162686
Project: 162686
Buggy source:
public void stopRangingBeaconsInRegion(Region region){
  int rangedRegionCount;
synchronized (rangedRegionState) {
    rangedRegionState.remove(region);
    rangedRegionCount=rangedRegionState.size();
    LogManager.d(TAG,"String_Node_Str",rangedRegionState.size());
  }
  if (scanningEnabled && rangedRegionCount == 0 && monitoredRegionState.size() == 0) {
    mCycledScanner.stop();
  }
}

Fixed version (ground truth):
public void stopRangingBeaconsInRegion(Region region){
  int rangedRegionCount;
synchronized (rangedRegionState) {
    rangedRegionState.remove(region);
    rangedRegionCount=rangedRegionState.size();
    LogManager.d(TAG,"String_Node_Str",rangedRegionState.size());
  }
  if (rangedRegionCount == 0 && monitoredRegionState.size() == 0) {
    mCycledScanner.stop();
  }
}
Program: 162687
Project: 162687
Buggy source:
public void startMonitoringBeaconsInRegion(Region region,Callback callback){
  LogManager.d(TAG,"String_Node_Str");
synchronized (monitoredRegionState) {
    if (monitoredRegionState.containsKey(region)) {
      LogManager.i(TAG,"String_Node_Str");
      monitoredRegionState.remove(region);
    }
    monitoredRegionState.put(region,new MonitorState(callback));
  }
  LogManager.d(TAG,"String_Node_Str",monitoredRegionState.size());
  if (!scanningEnabled) {
    mCycledScanner.start();
  }
}

Fixed version (ground truth):
public void startMonitoringBeaconsInRegion(Region region,Callback callback){
  LogManager.d(TAG,"String_Node_Str");
synchronized (monitoredRegionState) {
    if (monitoredRegionState.containsKey(region)) {
      LogManager.i(TAG,"String_Node_Str");
      monitoredRegionState.remove(region);
    }
    monitoredRegionState.put(region,new MonitorState(callback));
  }
  LogManager.d(TAG,"String_Node_Str",monitoredRegionState.size());
  mCycledScanner.start();
}
Program: 162688
Project: 162688
Buggy source:
public void stopMonitoringBeaconsInRegion(Region region){
  int monitoredRegionCount;
  LogManager.d(TAG,"String_Node_Str");
synchronized (monitoredRegionState) {
    monitoredRegionState.remove(region);
    monitoredRegionCount=monitoredRegionState.size();
  }
  LogManager.d(TAG,"String_Node_Str",monitoredRegionState.size());
  if (scanningEnabled && monitoredRegionCount == 0 && monitoredRegionState.size() == 0) {
    mCycledScanner.stop();
  }
}

Fixed version (ground truth):
public void stopMonitoringBeaconsInRegion(Region region){
  int monitoredRegionCount;
  LogManager.d(TAG,"String_Node_Str");
synchronized (monitoredRegionState) {
    monitoredRegionState.remove(region);
    monitoredRegionCount=monitoredRegionState.size();
  }
  LogManager.d(TAG,"String_Node_Str",monitoredRegionState.size());
  if (monitoredRegionCount == 0 && rangedRegionState.size() == 0) {
    mCycledScanner.stop();
  }
}
Program: 162689
Project: 162689
Buggy source:
private void finishScanCycle(){
  LogManager.d(TAG,"String_Node_Str");
  mCycledLeScanCallback.onCycleEnd();
  if (mScanning) {
    if (getBluetoothAdapter() != null) {
      if (getBluetoothAdapter().isEnabled()) {
        try {
          LogManager.d(TAG,"String_Node_Str");
          finishScan();
        }
 catch (        Exception e) {
          LogManager.w(e,TAG,"String_Node_Str");
        }
        mLastScanCycleEndTime=new Date().getTime();
      }
 else {
        LogManager.d(TAG,"String_Node_Str");
      }
    }
    mNextScanCycleStartTime=getNextScanStartTime();
    if (mScanningEnabled) {
      scanLeDevice(true);
    }
 else {
      LogManager.d(TAG,"String_Node_Str");
      mScanCyclerStarted=false;
      cancelWakeUpAlarm();
    }
  }
}

Fixed version (ground truth):
private void finishScanCycle(){
  LogManager.d(TAG,"String_Node_Str");
  mCycledLeScanCallback.onCycleEnd();
  if (mScanning) {
    if (getBluetoothAdapter() != null) {
      if (getBluetoothAdapter().isEnabled()) {
        try {
          LogManager.d(TAG,"String_Node_Str");
          finishScan();
        }
 catch (        Exception e) {
          LogManager.w(e,TAG,"String_Node_Str");
        }
        mLastScanCycleEndTime=new Date().getTime();
      }
 else {
        LogManager.d(TAG,"String_Node_Str");
      }
    }
    mNextScanCycleStartTime=getNextScanStartTime();
    if (mScanningEnabled) {
      scanLeDevice(true);
    }
  }
  if (!mScanningEnabled) {
    LogManager.d(TAG,"String_Node_Str");
    mScanCyclerStarted=false;
    cancelWakeUpAlarm();
  }
}
Program: 162691
Project: 162691
Buggy source:
/** 
 * Checks to see if an Beacon object is included in the matching criteria of this Region
 * @param beacon the beacon to check to see if it is in the Region
 * @return true if is covered
 */
public boolean matchesBeacon(Beacon beacon){
  if (this.mIdentifiers.size() != beacon.mIdentifiers.size()) {
    return false;
  }
  for (int i=0; i < this.mIdentifiers.size(); i++) {
    if (mIdentifiers.get(i) != null && !mIdentifiers.get(i).equals(beacon.mIdentifiers.get(i))) {
      return false;
    }
  }
  return true;
}

Fixed version (ground truth):
/** 
 * Checks to see if an Beacon object is included in the matching criteria of this Region
 * @param beacon the beacon to check to see if it is in the Region
 * @return true if is covered
 */
public boolean matchesBeacon(Beacon beacon){
  for (int i=0; i < this.mIdentifiers.size(); i++) {
    if (beacon.getIdentifiers().size() <= i && mIdentifiers.get(i) == null) {
    }
 else {
      if (mIdentifiers.get(i) != null && !mIdentifiers.get(i).equals(beacon.mIdentifiers.get(i))) {
        return false;
      }
    }
  }
  return true;
}
Program: 162692
Project: 162692
Buggy source:
private List<Region> matchingRegions(Beacon beacon,Collection<Region> regions){
  List<Region> matched=new ArrayList<Region>();
  Iterator<Region> regionIterator=regions.iterator();
  while (regionIterator.hasNext()) {
    Region region=regionIterator.next();
    if (region.matchesBeacon(beacon)) {
      matched.add(region);
    }
 else {
      BeaconManager.logDebug(TAG,"String_Node_Str" + region);
    }
  }
  return matched;
}

Fixed version (ground truth):
private List<Region> matchingRegions(Beacon beacon,Collection<Region> regions){
  List<Region> matched=new ArrayList<Region>();
  Iterator<Region> regionIterator=regions.iterator();
  while (regionIterator.hasNext()) {
    Region region=regionIterator.next();
    if (region.matchesBeacon(beacon)) {
      matched.add(region);
    }
 else {
      BeaconManager.logDebug(TAG,"String_Node_Str" + region + "String_Node_Str"+ beacon);
    }
  }
  return matched;
}
Program: 162693
Project: 162693
Buggy source:
/** 
 * Tells the cycler the scan rate and whether it is in operating in background mode. Background mode flag  is used only with the Android 5.0 scanning implementations to switch between LOW_POWER_MODE vs. LOW_LATENCY_MODE
 * @param backgroundFlag
 */
public void setScanPeriods(long scanPeriod,long betweenScanPeriod,boolean backgroundFlag){
  Log.d(TAG,"String_Node_Str" + scanPeriod + "String_Node_Str"+ betweenScanPeriod+ "String_Node_Str");
  if (mBackgroundFlag != backgroundFlag) {
    mRestartNeeded=true;
  }
  mBackgroundFlag=backgroundFlag;
  mScanPeriod=scanPeriod;
  mBetweenScanPeriod=betweenScanPeriod;
  if (mBackgroundFlag == true) {
    BeaconManager.logDebug(TAG,"String_Node_Str");
    setWakeUpAlarm();
  }
 else {
    BeaconManager.logDebug(TAG,"String_Node_Str");
    cancelWakeUpAlarm();
  }
  long now=new Date().getTime();
  if (mNextScanCycleStartTime > now) {
    long proposedNextScanStartTime=(mLastScanCycleEndTime + betweenScanPeriod);
    if (proposedNextScanStartTime < mNextScanCycleStartTime) {
      mNextScanCycleStartTime=proposedNextScanStartTime;
      Log.i(TAG,"String_Node_Str" + new Date(mNextScanCycleStartTime));
    }
  }
  if (mScanCycleStopTime > now) {
    long proposedScanStopTime=(mLastScanCycleStartTime + scanPeriod);
    if (proposedScanStopTime < mScanCycleStopTime) {
      mScanCycleStopTime=proposedScanStopTime;
      Log.i(TAG,"String_Node_Str" + new Date(mScanCycleStopTime));
    }
  }
}

Fixed version (ground truth):
/** 
 * Tells the cycler the scan rate and whether it is in operating in background mode. Background mode flag  is used only with the Android 5.0 scanning implementations to switch between LOW_POWER_MODE vs. LOW_LATENCY_MODE
 * @param backgroundFlag
 */
public void setScanPeriods(long scanPeriod,long betweenScanPeriod,boolean backgroundFlag){
  BeaconManager.logDebug(TAG,"String_Node_Str" + scanPeriod + "String_Node_Str"+ betweenScanPeriod+ "String_Node_Str");
  if (mBackgroundFlag != backgroundFlag) {
    mRestartNeeded=true;
  }
  mBackgroundFlag=backgroundFlag;
  mScanPeriod=scanPeriod;
  mBetweenScanPeriod=betweenScanPeriod;
  if (mBackgroundFlag == true) {
    BeaconManager.logDebug(TAG,"String_Node_Str");
    setWakeUpAlarm();
  }
 else {
    BeaconManager.logDebug(TAG,"String_Node_Str");
    cancelWakeUpAlarm();
  }
  long now=new Date().getTime();
  if (mNextScanCycleStartTime > now) {
    long proposedNextScanStartTime=(mLastScanCycleEndTime + betweenScanPeriod);
    if (proposedNextScanStartTime < mNextScanCycleStartTime) {
      mNextScanCycleStartTime=proposedNextScanStartTime;
      Log.i(TAG,"String_Node_Str" + new Date(mNextScanCycleStartTime));
    }
  }
  if (mScanCycleStopTime > now) {
    long proposedScanStopTime=(mLastScanCycleStartTime + scanPeriod);
    if (proposedScanStopTime < mScanCycleStopTime) {
      mScanCycleStopTime=proposedScanStopTime;
      Log.i(TAG,"String_Node_Str" + new Date(mScanCycleStopTime));
    }
  }
}
Program: 162694
Project: 162694
Buggy source:
@TargetApi(3) private void cancelWakeUpAlarm(){
  Log.d(TAG,"String_Node_Str" + mWakeUpOperation);
  if (mWakeUpOperation != null) {
    AlarmManager alarmManager=(AlarmManager)mContext.getSystemService(Context.ALARM_SERVICE);
    alarmManager.cancel(mWakeUpOperation);
  }
}

Fixed version (ground truth):
@TargetApi(3) private void cancelWakeUpAlarm(){
  BeaconManager.logDebug(TAG,"String_Node_Str" + mWakeUpOperation);
  if (mWakeUpOperation != null) {
    AlarmManager alarmManager=(AlarmManager)mContext.getSystemService(Context.ALARM_SERVICE);
    alarmManager.cancel(mWakeUpOperation);
  }
}
Program: 162695
Project: 162695
Buggy source:
@TargetApi(21) private void finishScanCycle(){
  BeaconManager.logDebug(TAG,"String_Node_Str");
  mCycledLeScanCallback.onCycleEnd();
  if (mScanning == true) {
    if (getBluetoothAdapter() != null) {
      if (getBluetoothAdapter().isEnabled()) {
        try {
          Log.d(TAG,"String_Node_Str");
          if (mUseAndroidLScanner) {
            if (mBetweenScanPeriod == 0) {
              BeaconManager.logDebug(TAG,"String_Node_Str");
            }
 else {
              mScanner.stopScan((android.bluetooth.le.ScanCallback)getNewLeScanCallback());
              mScanningPaused=true;
            }
          }
 else {
            getBluetoothAdapter().stopLeScan((BluetoothAdapter.LeScanCallback)getLeScanCallback());
            mScanningPaused=true;
          }
        }
 catch (        Exception e) {
          Log.w("String_Node_Str",e);
        }
        mLastScanCycleEndTime=new Date().getTime();
      }
 else {
        Log.w(TAG,"String_Node_Str");
      }
    }
    mNextScanCycleStartTime=(new Date().getTime() + mBetweenScanPeriod);
    if (mScanningEnabled) {
      scanLeDevice(true);
    }
 else {
      BeaconManager.logDebug(TAG,"String_Node_Str");
      mScanCyclerStarted=false;
      cancelWakeUpAlarm();
    }
  }
}

Fixed version (ground truth):
@TargetApi(21) private void finishScanCycle(){
  BeaconManager.logDebug(TAG,"String_Node_Str");
  mCycledLeScanCallback.onCycleEnd();
  if (mScanning == true) {
    if (getBluetoothAdapter() != null) {
      if (getBluetoothAdapter().isEnabled()) {
        try {
          BeaconManager.logDebug(TAG,"String_Node_Str");
          if (mUseAndroidLScanner) {
            if (mBetweenScanPeriod == 0) {
              BeaconManager.logDebug(TAG,"String_Node_Str");
            }
 else {
              mScanner.stopScan((android.bluetooth.le.ScanCallback)getNewLeScanCallback());
              mScanningPaused=true;
            }
          }
 else {
            getBluetoothAdapter().stopLeScan((BluetoothAdapter.LeScanCallback)getLeScanCallback());
            mScanningPaused=true;
          }
        }
 catch (        Exception e) {
          Log.w("String_Node_Str",e);
        }
        mLastScanCycleEndTime=new Date().getTime();
      }
 else {
        Log.w(TAG,"String_Node_Str");
      }
    }
    mNextScanCycleStartTime=(new Date().getTime() + mBetweenScanPeriod);
    if (mScanningEnabled) {
      scanLeDevice(true);
    }
 else {
      BeaconManager.logDebug(TAG,"String_Node_Str");
      mScanCyclerStarted=false;
      cancelWakeUpAlarm();
    }
  }
}
Program: 162696
Project: 162696
Buggy source:
@SuppressLint("String_Node_Str") public void stop(){
  mScanningEnabled=false;
  if (mScanCyclerStarted) {
    scanLeDevice(false);
  }
  if (mBluetoothAdapter != null) {
    try {
      if (mUseAndroidLScanner) {
        mScanner.stopScan((android.bluetooth.le.ScanCallback)getNewLeScanCallback());
      }
 else {
        getBluetoothAdapter().stopLeScan((BluetoothAdapter.LeScanCallback)getLeScanCallback());
      }
    }
 catch (    Exception e) {
      Log.w("String_Node_Str",e);
    }
    mLastScanCycleEndTime=new Date().getTime();
  }
}

Fixed version (ground truth):
@SuppressLint("String_Node_Str") public void stop(){
  BeaconManager.logDebug(TAG,"String_Node_Str");
  mScanningEnabled=false;
  if (mScanCyclerStarted) {
    scanLeDevice(false);
  }
  if (mBluetoothAdapter != null) {
    try {
      if (mUseAndroidLScanner) {
        mScanner.stopScan((android.bluetooth.le.ScanCallback)getNewLeScanCallback());
      }
 else {
        getBluetoothAdapter().stopLeScan((BluetoothAdapter.LeScanCallback)getLeScanCallback());
      }
    }
 catch (    Exception e) {
      Log.w("String_Node_Str",e);
    }
    mLastScanCycleEndTime=new Date().getTime();
  }
}
Program: 162699
Project: 162699
Buggy source:
/** 
 * methods for clients
 */
public void startRangingBeaconsInRegion(Region region,Callback callback){
synchronized (rangedRegionState) {
    if (rangedRegionState.containsKey(region)) {
      Log.i(TAG,"String_Node_Str");
      rangedRegionState.remove(region);
    }
    rangedRegionState.put(region,new RangeState(callback));
  }
  BeaconManager.logDebug(TAG,"String_Node_Str" + rangedRegionState.size() + "String_Node_Str");
  if (!scanningEnabled) {
    enableScanning();
  }
}

Fixed version (ground truth):
/** 
 * methods for clients
 */
public void startRangingBeaconsInRegion(Region region,Callback callback){
synchronized (rangedRegionState) {
    if (rangedRegionState.containsKey(region)) {
      Log.i(TAG,"String_Node_Str");
      rangedRegionState.remove(region);
    }
    rangedRegionState.put(region,new RangeState(callback));
    BeaconManager.logDebug(TAG,"String_Node_Str" + rangedRegionState.size() + "String_Node_Str");
  }
  if (!scanningEnabled) {
    enableScanning();
  }
}
Program: 162700
Project: 162700
Buggy source:
private void processExpiredMonitors(){
  Iterator<Region> monitoredRegionIterator=monitoredRegionState.keySet().iterator();
  while (monitoredRegionIterator.hasNext()) {
    Region region=monitoredRegionIterator.next();
    MonitorState state=monitoredRegionState.get(region);
    if (state.isNewlyOutside()) {
      BeaconManager.logDebug(TAG,"String_Node_Str" + region);
      state.getCallback().call(BeaconService.this,"String_Node_Str",new MonitoringData(state.isInside(),region));
    }
  }
}

Fixed version (ground truth):
private void processExpiredMonitors(){
synchronized (monitoredRegionState) {
    Iterator<Region> monitoredRegionIterator=monitoredRegionState.keySet().iterator();
    while (monitoredRegionIterator.hasNext()) {
      Region region=monitoredRegionIterator.next();
      MonitorState state=monitoredRegionState.get(region);
      if (state.isNewlyOutside()) {
        BeaconManager.logDebug(TAG,"String_Node_Str" + region);
        state.getCallback().call(BeaconService.this,"String_Node_Str",new MonitoringData(state.isInside(),region));
      }
    }
  }
}
Program: 162701
Project: 162701
Buggy source:
private void processRangeData(){
  Iterator<Region> regionIterator=rangedRegionState.keySet().iterator();
  while (regionIterator.hasNext()) {
    Region region=regionIterator.next();
    RangeState rangeState=rangedRegionState.get(region);
    BeaconManager.logDebug(TAG,"String_Node_Str");
    rangeState.getCallback().call(BeaconService.this,"String_Node_Str",new RangingData(rangeState.finalizeBeacons(),region));
  }
}

Fixed version (ground truth):
private void processRangeData(){
synchronized (rangedRegionState) {
    Iterator<Region> regionIterator=rangedRegionState.keySet().iterator();
    while (regionIterator.hasNext()) {
      Region region=regionIterator.next();
      RangeState rangeState=rangedRegionState.get(region);
      BeaconManager.logDebug(TAG,"String_Node_Str");
      rangeState.getCallback().call(BeaconService.this,"String_Node_Str",new RangingData(rangeState.finalizeBeacons(),region));
    }
  }
}
Program: 162702
Project: 162702
Buggy source:
private void processBeaconFromScan(Beacon beacon){
  lastBeaconDetectionTime=new Date();
  trackedBeaconsPacketCount++;
  if (trackedBeacons.contains(beacon)) {
    BeaconManager.logDebug(TAG,"String_Node_Str" + beacon.toString());
  }
  trackedBeacons.add(beacon);
  BeaconManager.logDebug(TAG,"String_Node_Str" + beacon.toString());
  List<Region> matchedRegions=null;
synchronized (monitoredRegionState) {
    matchedRegions=matchingRegions(beacon,monitoredRegionState.keySet());
  }
  Iterator<Region> matchedRegionIterator=matchedRegions.iterator();
  while (matchedRegionIterator.hasNext()) {
    Region region=matchedRegionIterator.next();
    MonitorState state=monitoredRegionState.get(region);
    if (state.markInside()) {
      state.getCallback().call(BeaconService.this,"String_Node_Str",new MonitoringData(state.isInside(),region));
    }
  }
  BeaconManager.logDebug(TAG,"String_Node_Str");
synchronized (rangedRegionState) {
    matchedRegions=matchingRegions(beacon,rangedRegionState.keySet());
  }
  matchedRegionIterator=matchedRegions.iterator();
  while (matchedRegionIterator.hasNext()) {
    Region region=matchedRegionIterator.next();
    BeaconManager.logDebug(TAG,"String_Node_Str" + region);
    RangeState rangeState=rangedRegionState.get(region);
synchronized (rangeState) {
      rangeState.addBeacon(beacon);
    }
  }
}

Fixed version (ground truth):
private void processBeaconFromScan(Beacon beacon){
  lastBeaconDetectionTime=new Date();
  trackedBeaconsPacketCount++;
  if (trackedBeacons.contains(beacon)) {
    BeaconManager.logDebug(TAG,"String_Node_Str" + beacon.toString());
  }
  trackedBeacons.add(beacon);
  BeaconManager.logDebug(TAG,"String_Node_Str" + beacon.toString());
  List<Region> matchedRegions=null;
synchronized (monitoredRegionState) {
    matchedRegions=matchingRegions(beacon,monitoredRegionState.keySet());
  }
  Iterator<Region> matchedRegionIterator=matchedRegions.iterator();
  while (matchedRegionIterator.hasNext()) {
    Region region=matchedRegionIterator.next();
    MonitorState state=monitoredRegionState.get(region);
    if (state.markInside()) {
      state.getCallback().call(BeaconService.this,"String_Node_Str",new MonitoringData(state.isInside(),region));
    }
  }
  BeaconManager.logDebug(TAG,"String_Node_Str");
synchronized (rangedRegionState) {
    matchedRegions=matchingRegions(beacon,rangedRegionState.keySet());
    matchedRegionIterator=matchedRegions.iterator();
    while (matchedRegionIterator.hasNext()) {
      Region region=matchedRegionIterator.next();
      BeaconManager.logDebug(TAG,"String_Node_Str" + region);
      RangeState rangeState=rangedRegionState.get(region);
      rangeState.addBeacon(beacon);
    }
  }
}
Program: 162703
Project: 162703
Buggy source:
public void stopRangingBeaconsInRegion(Region region){
synchronized (rangedRegionState) {
    rangedRegionState.remove(region);
  }
  BeaconManager.logDebug(TAG,"String_Node_Str" + rangedRegionState.size() + "String_Node_Str");
  if (scanningEnabled && rangedRegionState.size() == 0 && monitoredRegionState.size() == 0) {
    disableScanning();
  }
}

Fixed version (ground truth):
public void stopRangingBeaconsInRegion(Region region){
  int rangedRegionCount;
synchronized (rangedRegionState) {
    rangedRegionState.remove(region);
    rangedRegionCount=rangedRegionState.size();
    BeaconManager.logDebug(TAG,"String_Node_Str" + rangedRegionState.size() + "String_Node_Str");
  }
  if (scanningEnabled && rangedRegionCount == 0 && monitoredRegionState.size() == 0) {
    disableScanning();
  }
}
Program: 162704
Project: 162704
Buggy source:
public void stopMonitoringBeaconsInRegion(Region region){
  BeaconManager.logDebug(TAG,"String_Node_Str");
synchronized (monitoredRegionState) {
    monitoredRegionState.remove(region);
  }
  BeaconManager.logDebug(TAG,"String_Node_Str" + monitoredRegionState.size() + "String_Node_Str");
  if (scanningEnabled && rangedRegionState.size() == 0 && monitoredRegionState.size() == 0) {
    disableScanning();
  }
}

Fixed version (ground truth):
public void stopMonitoringBeaconsInRegion(Region region){
  int monitoredRegionCount;
  BeaconManager.logDebug(TAG,"String_Node_Str");
synchronized (monitoredRegionState) {
    monitoredRegionState.remove(region);
    monitoredRegionCount=monitoredRegionState.size();
  }
  BeaconManager.logDebug(TAG,"String_Node_Str" + monitoredRegionState.size() + "String_Node_Str");
  if (scanningEnabled && monitoredRegionCount == 0 && monitoredRegionState.size() == 0) {
    disableScanning();
  }
}
Program: 162705
Project: 162705
Buggy source:
/** 
 * This method notifies the beacon service that the application is either moving to background mode or foreground mode.  When in background mode, BluetoothLE scans to look for beacons are executed less frequently in order to save battery life. The specific scan rates for background and foreground operation are set by the defaults below, but may be customized. When ranging in the background, the time between updates will be much less frequent than in the foreground.  Updates will come every time interval equal to the sum total of the BackgroundScanPeriod and the BackgroundBetweenScanPeriod.
 * @see #DEFAULT_FOREGROUND_SCAN_PERIOD
 * @see #DEFAULT_FOREGROUND_BETWEEN_SCAN_PERIOD;
 * @see #DEFAULT_BACKGROUND_SCAN_PERIOD;
 * @see #DEFAULT_BACKGROUND_BETWEEN_SCAN_PERIOD;
 * @see #setForegroundScanPeriod(long p)
 * @see #setForegroundBetweenScanPeriod(long p)
 * @see #setBackgroundScanPeriod(long p)
 * @see #setBackgroundBetweenScanPeriod(long p)
 * @param backgroundMode true indicates the app is in the background
 */
public void setBackgroundMode(boolean backgroundMode){
  if (android.os.Build.VERSION.SDK_INT < 18) {
    Log.w(TAG,"String_Node_Str");
  }
  if (backgroundMode != mBackgroundMode) {
    mBackgroundMode=backgroundMode;
    try {
      this.updateScanPeriods();
    }
 catch (    RemoteException e) {
      Log.e(TAG,"String_Node_Str");
    }
  }
}

Fixed version (ground truth):
/** 
 * This method notifies the beacon service that the application is either moving to background mode or foreground mode.  When in background mode, BluetoothLE scans to look for beacons are executed less frequently in order to save battery life. The specific scan rates for background and foreground operation are set by the defaults below, but may be customized. When ranging in the background, the time between updates will be much less frequent than in the foreground.  Updates will come every time interval equal to the sum total of the BackgroundScanPeriod and the BackgroundBetweenScanPeriod.
 * @see #DEFAULT_FOREGROUND_SCAN_PERIOD
 * @see #DEFAULT_FOREGROUND_BETWEEN_SCAN_PERIOD;
 * @see #DEFAULT_BACKGROUND_SCAN_PERIOD;
 * @see #DEFAULT_BACKGROUND_BETWEEN_SCAN_PERIOD;
 * @see #setForegroundScanPeriod(long p)
 * @see #setForegroundBetweenScanPeriod(long p)
 * @see #setBackgroundScanPeriod(long p)
 * @see #setBackgroundBetweenScanPeriod(long p)
 * @param backgroundMode true indicates the app is in the background
 */
public void setBackgroundMode(boolean backgroundMode){
  if (android.os.Build.VERSION.SDK_INT < 18) {
    Log.w(TAG,"String_Node_Str");
  }
  mBackgroundModeUninitialized=false;
  if (backgroundMode != mBackgroundMode) {
    mBackgroundMode=backgroundMode;
    try {
      this.updateScanPeriods();
    }
 catch (    RemoteException e) {
      Log.e(TAG,"String_Node_Str");
    }
  }
}
Program: 162706
Project: 162706
Buggy source:
/** 
 * Method reserved for system use
 */
@Override public void onBeaconServiceConnect(){
  BeaconManager.logDebug(TAG,"String_Node_Str");
  beaconManager.setMonitorNotifier(application);
  try {
    for (    Region region : regions) {
      BeaconManager.logDebug(TAG,"String_Node_Str" + region);
      beaconManager.startMonitoringBeaconsInRegion(region);
      beaconManager.setBackgroundMode(true);
    }
  }
 catch (  RemoteException e) {
    Log.e(TAG,"String_Node_Str" + e);
  }
}

Fixed version (ground truth):
/** 
 * Method reserved for system use
 */
@Override public void onBeaconServiceConnect(){
  BeaconManager.logDebug(TAG,"String_Node_Str");
  beaconManager.setMonitorNotifier(application);
  try {
    for (    Region region : regions) {
      BeaconManager.logDebug(TAG,"String_Node_Str" + region);
      beaconManager.startMonitoringBeaconsInRegion(region);
      if (beaconManager.isBackgroundModeUninitialized()) {
        beaconManager.setBackgroundMode(true);
      }
    }
  }
 catch (  RemoteException e) {
    Log.e(TAG,"String_Node_Str" + e);
  }
}
Program: 162707
Project: 162707
Buggy source:
/** 
 * Calculated the estimated distance in meters to the beacon based on a reference rssi at 1m and the known actual rssi at the current location
 * @param txPower
 * @param rssi
 * @return estimated distance
 */
protected static double calculateDistance(int txPower,double rssi){
  if (rssi == 0) {
    return -1.0;
  }
  BeaconManager.logDebug(TAG,"String_Node_Str" + rssi + "String_Node_Str"+ txPower);
  double ratio=rssi * 1.0 / txPower;
  double distance;
  if (ratio < 1.0) {
    distance=Math.pow(ratio,10);
  }
 else {
    distance=(0.42093) * Math.pow(ratio,6.9476) + 0.54992;
    BeaconManager.logDebug(TAG,"String_Node_Str" + rssi + "String_Node_Str"+ distance);
  }
  BeaconManager.logDebug(TAG,"String_Node_Str" + rssi + "String_Node_Str"+ distance);
  return distance;
}

Fixed version (ground truth):
/** 
 * Estimate the distance to the beacon using the DistanceCalculator set on this class.  If no DistanceCalculator has been set, return -1 as the distance.
 * @see org.altbeacon.beacon.distance.DistanceCalculator
 * @param txPower
 * @param bestRssiAvailable
 * @return
 */
protected static Double calculateDistance(int txPower,double bestRssiAvailable){
  if (Beacon.getDistanceCalculator() != null) {
    return Beacon.getDistanceCalculator().calculateDistance(txPower,bestRssiAvailable);
  }
 else {
    Log.e(TAG,"String_Node_Str");
    return -1.0;
  }
}
Program: 162708
Project: 162708
Buggy source:
/** 
 * Sets the running average rssi for use in distance calculations
 * @see #calculateDistance(int,double)
 * @param rssi the running average rssi
 */
public void setRunningAverageRssi(double rssi){
  mRunningAverageRssi=rssi;
  mDistance=null;
}

Fixed version (ground truth):
/** 
 * Sets the running average rssi for use in distance calculations
 * @param rssi the running average rssi
 */
public void setRunningAverageRssi(double rssi){
  mRunningAverageRssi=rssi;
  mDistance=null;
}
Program: 162709
Project: 162709
Buggy source:
/** 
 * This method notifies the beacon service that the application is either moving to background mode or foreground mode.  When in background mode, BluetoothLE scans to look for beacons are executed less frequently in order to save battery life. The specific scan rates for background and foreground operation are set by the defaults below, but may be customized. When ranging in the background, the time between updates will be much less frequent than in the foreground.  Updates will come every time interval equal to the sum total of the BackgroundScanPeriod and the BackgroundBetweenScanPeriod.
 * @see #DEFAULT_FOREGROUND_SCAN_PERIOD
 * @see #DEFAULT_FOREGROUND_BETWEEN_SCAN_PERIOD;
 * @see #DEFAULT_BACKGROUND_SCAN_PERIOD;
 * @see #DEFAULT_BACKGROUND_BETWEEN_SCAN_PERIOD;
 * @see #setForegroundScanPeriod(long p)
 * @see #setForegroundBetweenScanPeriod(long p)
 * @see #setBackgroundScanPeriod(long p)
 * @see #setBackgroundBetweenScanPeriod(long p)
 * @param backgroundMode true indicates the app is in the background
 */
public void setBackgroundMode(boolean backgroundMode){
  if (android.os.Build.VERSION.SDK_INT < 18) {
    Log.w(TAG,"String_Node_Str");
  }
  if (backgroundMode != mBackgroundMode) {
    mBackgroundMode=backgroundMode;
    try {
      this.updateScanPeriods();
    }
 catch (    RemoteException e) {
      Log.e(TAG,"String_Node_Str");
    }
  }
}

Fixed version (ground truth):
/** 
 * This method notifies the beacon service that the application is either moving to background mode or foreground mode.  When in background mode, BluetoothLE scans to look for beacons are executed less frequently in order to save battery life. The specific scan rates for background and foreground operation are set by the defaults below, but may be customized. When ranging in the background, the time between updates will be much less frequent than in the foreground.  Updates will come every time interval equal to the sum total of the BackgroundScanPeriod and the BackgroundBetweenScanPeriod.
 * @see #DEFAULT_FOREGROUND_SCAN_PERIOD
 * @see #DEFAULT_FOREGROUND_BETWEEN_SCAN_PERIOD;
 * @see #DEFAULT_BACKGROUND_SCAN_PERIOD;
 * @see #DEFAULT_BACKGROUND_BETWEEN_SCAN_PERIOD;
 * @see #setForegroundScanPeriod(long p)
 * @see #setForegroundBetweenScanPeriod(long p)
 * @see #setBackgroundScanPeriod(long p)
 * @see #setBackgroundBetweenScanPeriod(long p)
 * @param backgroundMode true indicates the app is in the background
 */
public void setBackgroundMode(boolean backgroundMode){
  if (android.os.Build.VERSION.SDK_INT < 18) {
    Log.w(TAG,"String_Node_Str");
  }
  mBackgroundModeUninitialized=false;
  if (backgroundMode != mBackgroundMode) {
    mBackgroundMode=backgroundMode;
    try {
      this.updateScanPeriods();
    }
 catch (    RemoteException e) {
      Log.e(TAG,"String_Node_Str");
    }
  }
}
Program: 162710
Project: 162710
Buggy source:
@TargetApi(17) private void startRecovery(){
  recoveryAttemptCount++;
  BluetoothAdapter adapter=BluetoothAdapter.getDefaultAdapter();
  if (isDebugEnabled())   Log.d(TAG,"String_Node_Str");
  if (!adapter.isDiscovering()) {
    Log.w(TAG,"String_Node_Str");
    recoveryInProgress=true;
    discoveryStartConfirmed=false;
    if (isDebugEnabled())     Log.d(TAG,"String_Node_Str");
    if (!adapter.startDiscovery()) {
      Log.w(TAG,"String_Node_Str");
    }
    if (isDebugEnabled())     Log.d(TAG,"String_Node_Str" + adapter.isDiscovering());
    if (TIME_TO_LET_DISCOVERY_RUN_MILLIS > 0) {
      if (isDebugEnabled())       Log.d(TAG,"String_Node_Str" + TIME_TO_LET_DISCOVERY_RUN_MILLIS + "String_Node_Str");
      discoveryCanceller.doInBackground();
    }
 else {
      Log.d(TAG,"String_Node_Str");
    }
  }
 else {
    Log.w(TAG,"String_Node_Str");
  }
}

Fixed version (ground truth):
@TargetApi(17) private void startRecovery(){
  recoveryAttemptCount++;
  BluetoothAdapter adapter=BluetoothAdapter.getDefaultAdapter();
  if (isDebugEnabled())   Log.d(TAG,"String_Node_Str");
  if (!adapter.isDiscovering()) {
    Log.w(TAG,"String_Node_Str");
    recoveryInProgress=true;
    discoveryStartConfirmed=false;
    if (isDebugEnabled())     Log.d(TAG,"String_Node_Str");
    if (!adapter.startDiscovery()) {
      Log.w(TAG,"String_Node_Str");
    }
    if (isDebugEnabled())     Log.d(TAG,"String_Node_Str" + adapter.isDiscovering());
    if (TIME_TO_LET_DISCOVERY_RUN_MILLIS > 0) {
      if (isDebugEnabled())       Log.d(TAG,"String_Node_Str" + TIME_TO_LET_DISCOVERY_RUN_MILLIS + "String_Node_Str");
      discoveryCanceller.doInBackground();
    }
 else {
      if (isDebugEnabled())       Log.d(TAG,"String_Node_Str");
    }
  }
 else {
    Log.w(TAG,"String_Node_Str");
  }
}
Program: 162712
Project: 162712
Buggy source:
@Override public String toString(){
  StringBuilder sb=new StringBuilder();
  int i=1;
  for (  Identifier identifier : mIdentifiers) {
    sb.append("String_Node_Str");
    sb.append(i);
    sb.append("String_Node_Str");
    sb.append(identifier.toString());
  }
  return sb.toString();
}

Fixed version (ground truth):
@Override public String toString(){
  StringBuilder sb=new StringBuilder();
  int i=1;
  for (  Identifier identifier : mIdentifiers) {
    sb.append("String_Node_Str");
    sb.append(i);
    sb.append("String_Node_Str");
    sb.append(identifier.toString());
    sb.append("String_Node_Str");
    i++;
  }
  return sb.toString();
}
Program: 162713
Project: 162713
Buggy source:
public boolean equals(Object other){
  if (other instanceof Region) {
    return ((Region)other).uniqueId == this.uniqueId;
  }
  return false;
}

Fixed version (ground truth):
public boolean equals(Object other){
  if (other instanceof Region) {
    return ((Region)other).uniqueId.equals(this.uniqueId);
  }
  return false;
}
Program: 162716
Project: 162716
Buggy source:
/** 
 * Binds an Android <code>Activity</code> or <code>Service</code> to the <code>IBeaconService</code>.  The  <code>Activity</code> or <code>Service</code> must implement the <code>IBeaconConsuemr</code> interface so that it can get a callback when the service is ready to use.
 * @param consumer the <code>Activity</code> or <code>Service</code> that will receive the callback when the service is ready.
 */
public void bind(IBeaconConsumer consumer){
  if (consumers.keySet().contains(consumer)) {
    if (IBeaconManager.LOG_DEBUG)     Log.d(TAG,"String_Node_Str");
  }
 else {
    Log.d(TAG,"String_Node_Str" + consumer);
    consumers.put(consumer,new ConsumerInfo());
    Intent intent=new Intent(consumer.getApplicationContext(),IBeaconService.class);
    consumer.bindService(intent,iBeaconServiceConnection,Context.BIND_AUTO_CREATE);
    if (IBeaconManager.LOG_DEBUG)     Log.d(TAG,"String_Node_Str" + consumers.size());
    if (serviceMessenger != null) {
      setBackgroundMode(consumer,false);
    }
  }
}

Fixed version (ground truth):
/** 
 * Binds an Android <code>Activity</code> or <code>Service</code> to the <code>IBeaconService</code>.  The  <code>Activity</code> or <code>Service</code> must implement the <code>IBeaconConsuemr</code> interface so that it can get a callback when the service is ready to use.
 * @param consumer the <code>Activity</code> or <code>Service</code> that will receive the callback when the service is ready.
 */
public void bind(IBeaconConsumer consumer){
  if (consumers.keySet().contains(consumer)) {
    if (IBeaconManager.LOG_DEBUG)     Log.d(TAG,"String_Node_Str");
  }
 else {
    if (IBeaconManager.LOG_DEBUG)     Log.d(TAG,"String_Node_Str" + consumer);
    consumers.put(consumer,new ConsumerInfo());
    Intent intent=new Intent(consumer.getApplicationContext(),IBeaconService.class);
    consumer.bindService(intent,iBeaconServiceConnection,Context.BIND_AUTO_CREATE);
    if (IBeaconManager.LOG_DEBUG)     Log.d(TAG,"String_Node_Str" + consumers.size());
    if (serviceMessenger != null) {
      setBackgroundMode(consumer,false);
    }
  }
}
Program: 162717
Project: 162717
Buggy source:
public void onServiceConnected(ComponentName className,IBinder service){
  Log.d(TAG,"String_Node_Str");
  serviceMessenger=new Messenger(service);
  Iterator<IBeaconConsumer> consumerIterator=consumers.keySet().iterator();
  while (consumerIterator.hasNext()) {
    IBeaconConsumer consumer=consumerIterator.next();
    Boolean alreadyConnected=consumers.get(consumer).isConnected;
    if (!alreadyConnected) {
      consumer.onIBeaconServiceConnect();
      ConsumerInfo consumerInfo=consumers.get(consumer);
      consumerInfo.isConnected=true;
      consumers.put(consumer,consumerInfo);
    }
  }
}

Fixed version (ground truth):
public void onServiceConnected(ComponentName className,IBinder service){
  if (IBeaconManager.LOG_DEBUG)   Log.d(TAG,"String_Node_Str");
  serviceMessenger=new Messenger(service);
  Iterator<IBeaconConsumer> consumerIterator=consumers.keySet().iterator();
  while (consumerIterator.hasNext()) {
    IBeaconConsumer consumer=consumerIterator.next();
    Boolean alreadyConnected=consumers.get(consumer).isConnected;
    if (!alreadyConnected) {
      consumer.onIBeaconServiceConnect();
      ConsumerInfo consumerInfo=consumers.get(consumer);
      consumerInfo.isConnected=true;
      consumers.put(consumer,consumerInfo);
    }
  }
}
Program: 162718
Project: 162718
Buggy source:
/** 
 * Two detected iBeacons are considered equal if they share the same three identifiers, regardless of their distance or RSSI.
 */
@Override public boolean equals(Object that){
  if (!(that instanceof IBeacon)) {
    return false;
  }
  IBeacon thatIBeacon=(IBeacon)that;
  return (thatIBeacon.getMinor() == this.getMinor() && thatIBeacon.getProximityUuid() == thatIBeacon.getProximityUuid());
}

Fixed version (ground truth):
/** 
 * Two detected iBeacons are considered equal if they share the same three identifiers, regardless of their distance or RSSI.
 */
@Override public boolean equals(Object that){
  if (!(that instanceof IBeacon)) {
    return false;
  }
  IBeacon thatIBeacon=(IBeacon)that;
  return (thatIBeacon.getMajor() == this.getMajor() && thatIBeacon.getMinor() == this.getMinor() && thatIBeacon.getProximityUuid() == thatIBeacon.getProximityUuid());
}
Program: 162719
Project: 162719
Buggy source:
@Override protected void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  setContentView(R.layout.activity_main);
  mContext=this;
  mListView=(MaterialListView)findViewById(R.id.material_listview);
  mListView.setItemAnimator(new SlideInLeftAnimator());
  mListView.getItemAnimator().setAddDuration(300);
  mListView.getItemAnimator().setRemoveDuration(300);
  final ImageView emptyView=new ImageView(this);
  emptyView.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
  mListView.setEmptyView(emptyView);
  Picasso.with(this).load("String_Node_Str").resize(100,100).centerInside().into(emptyView);
  fillArray();
  mListView.setOnDismissCallback(new OnDismissCallback(){
    @Override public void onDismiss(    @NonNull Card card,    int position){
      Toast.makeText(mContext,"String_Node_Str" + card.getTag(),Toast.LENGTH_SHORT).show();
    }
  }
);
  mListView.addOnItemTouchListener(new RecyclerItemClickListener.OnItemClickListener(){
    @Override public void onItemClick(    @NonNull Card card,    int position){
      Log.d("String_Node_Str","String_Node_Str" + card.getTag());
    }
    @Override public void onItemLongClick(    @NonNull Card card,    int position){
      Log.d("String_Node_Str","String_Node_Str" + card.getTag());
    }
  }
);
}

Fixed version (ground truth):
@Override protected void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  setContentView(R.layout.activity_main);
  mContext=this;
  mListView=(MaterialListView)findViewById(R.id.material_listview);
  mListView.setItemAnimator(new SlideInLeftAnimator());
  mListView.getItemAnimator().setAddDuration(300);
  mListView.getItemAnimator().setRemoveDuration(300);
  final ImageView emptyView=(ImageView)findViewById(R.id.imageView);
  emptyView.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
  mListView.setEmptyView(emptyView);
  Picasso.with(this).load("String_Node_Str").resize(100,100).centerInside().into(emptyView);
  fillArray();
  mListView.setOnDismissCallback(new OnDismissCallback(){
    @Override public void onDismiss(    @NonNull Card card,    int position){
      Toast.makeText(mContext,"String_Node_Str" + card.getTag(),Toast.LENGTH_SHORT).show();
    }
  }
);
  mListView.addOnItemTouchListener(new RecyclerItemClickListener.OnItemClickListener(){
    @Override public void onItemClick(    @NonNull Card card,    int position){
      Log.d("String_Node_Str","String_Node_Str" + card.getTag());
    }
    @Override public void onItemLongClick(    @NonNull Card card,    int position){
      Log.d("String_Node_Str","String_Node_Str" + card.getTag());
    }
  }
);
}