Program: 13593
Project: 13593
Buggy source:
@Override public void handleMessage(Message message){
  ScannerEvent queueEvent=new ScannerEvent(message.what,message.obj);
switch (queueEvent.getType()) {
case ScannerEvent.LOGICAL_SCAN_START_REQUESTED:
{
      if (!scanning) {
        lastExitCheckTimestamp=clock.now();
        if (lastStopTimestamp != NEVER_STOPPED && lastExitCheckTimestamp - lastStopTimestamp > settingsManager.getCleanBeaconMapRestartTimeout()) {
          clearCache();
          Logger.log.scannerStateChange("String_Node_Str");
        }
        started=clock.now();
        scanning=true;
        runLoop.sendMessage(ScannerEvent.UN_PAUSE_SCAN);
      }
      break;
    }
case ScannerEvent.PAUSE_SCAN:
{
    bluetoothPlatform.stopLeScan();
    Logger.log.scannerStateChange("String_Node_Str" + waitTime + "String_Node_Str");
    scheduleExecution(ScannerEvent.UN_PAUSE_SCAN,waitTime);
    runLoop.cancelFixedRateExecution();
    break;
  }
case ScannerEvent.UN_PAUSE_SCAN:
{
  lastScanStart=clock.now();
  lastBreakLength=clock.now() - lastExitCheckTimestamp;
  Logger.log.scannerStateChange("String_Node_Str" + lastBreakLength + "String_Node_Str");
  if (scanning) {
    Logger.log.debug("String_Node_Str" + Boolean.toString(scanning));
    Logger.log.scannerStateChange("String_Node_Str" + scanTime + "String_Node_Str");
    bluetoothPlatform.startLeScan(scanCallback);
    scheduleExecution(ScannerEvent.PAUSE_SCAN,scanTime);
    runLoop.scheduleAtFixedRate(new TimerTask(){
      @Override public void run(){
        loop();
      }
    }
,0,TimeConstants.ONE_SECOND);
  }
  break;
}
case ScannerEvent.SCAN_STOP_REQUESTED:
{
started=0;
scanning=false;
clearScheduledExecutions();
bluetoothPlatform.stopLeScan();
lastStopTimestamp=clock.now();
runLoop.cancelFixedRateExecution();
Logger.log.scannerStateChange("String_Node_Str");
break;
}
case ScannerEvent.EVENT_DETECTED:
{
ScanEvent scanEvent=(ScanEvent)queueEvent.getData();
synchronized (listenersMonitor) {
for (ScannerListener listener : listeners) {
  listener.onScanEventDetected(scanEvent);
}
}
break;
}
case ScannerEvent.RSSI_UPDATED:
{
Pair<BeaconId,Integer> value=(Pair<BeaconId,Integer>)queueEvent.getData();
this.rssiListener.onRssiUpdated(value.first,value.second);
break;
}
default :
{
throw new IllegalArgumentException("String_Node_Str" + queueEvent.getData());
}
}
}

Fixed version (ground truth):
@Override public void handleMessage(Message message){
  ScannerEvent queueEvent=new ScannerEvent(message.what,message.obj);
switch (queueEvent.getType()) {
case ScannerEvent.LOGICAL_SCAN_START_REQUESTED:
{
      if (!scanning) {
        lastExitCheckTimestamp=clock.now();
        if (lastStopTimestamp != NEVER_STOPPED && lastExitCheckTimestamp - lastStopTimestamp > settingsManager.getCleanBeaconMapRestartTimeout()) {
          clearCache();
          Logger.log.scannerStateChange("String_Node_Str");
        }
        started=clock.now();
        scanning=true;
        runLoop.sendMessage(ScannerEvent.UN_PAUSE_SCAN);
      }
      break;
    }
case ScannerEvent.PAUSE_SCAN:
{
    bluetoothPlatform.stopLeScan();
    Logger.log.scannerStateChange("String_Node_Str" + waitTime + "String_Node_Str");
    scheduleExecution(ScannerEvent.UN_PAUSE_SCAN,waitTime);
    runLoop.cancelFixedRateExecution();
    break;
  }
case ScannerEvent.UN_PAUSE_SCAN:
{
  lastScanStart=clock.now();
  lastBreakLength=clock.now() - lastExitCheckTimestamp;
  Logger.log.scannerStateChange("String_Node_Str" + lastBreakLength + "String_Node_Str");
  if (scanning) {
    Logger.log.debug("String_Node_Str" + Boolean.toString(scanning));
    Logger.log.scannerStateChange("String_Node_Str" + scanTime + "String_Node_Str"+ exitGraceTime+ "String_Node_Str");
    bluetoothPlatform.startLeScan(scanCallback);
    scheduleExecution(ScannerEvent.PAUSE_SCAN,scanTime);
    runLoop.scheduleAtFixedRate(new TimerTask(){
      @Override public void run(){
        loop();
      }
    }
,exitGraceTime,TimeConstants.ONE_SECOND);
  }
  break;
}
case ScannerEvent.SCAN_STOP_REQUESTED:
{
started=0;
scanning=false;
clearScheduledExecutions();
bluetoothPlatform.stopLeScan();
lastStopTimestamp=clock.now();
runLoop.cancelFixedRateExecution();
Logger.log.scannerStateChange("String_Node_Str");
break;
}
case ScannerEvent.EVENT_DETECTED:
{
ScanEvent scanEvent=(ScanEvent)queueEvent.getData();
synchronized (listenersMonitor) {
for (ScannerListener listener : listeners) {
  listener.onScanEventDetected(scanEvent);
}
}
break;
}
case ScannerEvent.RSSI_UPDATED:
{
Pair<BeaconId,Integer> value=(Pair<BeaconId,Integer>)queueEvent.getData();
this.rssiListener.onRssiUpdated(value.first,value.second);
break;
}
default :
{
throw new IllegalArgumentException("String_Node_Str" + queueEvent.getData());
}
}
}