Program: 13649
Project: 13649
Buggy source:
@Override public int onStartCommand(Intent intent,int flags,int startId){
  Logger.log.logServiceState("String_Node_Str");
  if (!platform.isBluetoothLowEnergySupported() || !platform.hasMinimumAndroidRequirements()) {
    Logger.log.logError("String_Node_Str");
    stopSelf();
    return START_NOT_STICKY;
  }
  List<BroadcastReceiver> broadcastReceiver=platform.getBroadcastReceiver();
  if (broadcastReceiver.isEmpty()) {
    Logger.log.logError("String_Node_Str");
    stopSelf();
    return START_NOT_STICKY;
  }
 else {
    platform.registerBroadcastReceiver(broadcastReceiver);
  }
  if (intent != null) {
    Logger.log.serviceHandlesMessage(MSG.stringFrom(intent.getIntExtra(SensorbergService.EXTRA_GENERIC_TYPE,-1)));
    handleDebuggingIntent(intent,this);
    if (handleIntentEvenIfNoBootstrapperPresent(intent)) {
      stopSelf();
      return START_NOT_STICKY;
    }
    if (bootstrapper == null) {
      updateDiskConfiguration(intent);
    }
    if (intent.hasExtra(EXTRA_START_SERVICE)) {
      if (bootstrapper == null) {
        String apiKey=intent.getStringExtra(EXTRA_API_KEY);
        if (isEmpty(apiKey)) {
          apiKey=ManifestParser.get(META_DATA_API_KEY,this);
        }
        if (!isEmpty(apiKey)) {
          bootstrapper=new InternalApplicationBootstrapper(platform);
          bootstrapper.setApiToken(apiKey);
          persistConfiguration(bootstrapper);
          bootstrapper.startScanning();
          return START_STICKY;
        }
      }
 else {
        bootstrapper.startScanning();
        Logger.log.logError("String_Node_Str");
        return START_STICKY;
      }
      Logger.log.logError("String_Node_Str");
      stopSelf();
      return START_NOT_STICKY;
    }
    if (intent.hasExtra(SensorbergService.EXTRA_GENERIC_TYPE)) {
      if (bootstrapper == null) {
        createBootstrapperFromDiskConfiguration();
        if (bootstrapper == null) {
          Logger.log.logError("String_Node_Str");
          stopSelf();
          return START_NOT_STICKY;
        }
      }
      int what=intent.getIntExtra(SensorbergService.EXTRA_GENERIC_TYPE,-1);
      Logger.log.serviceHandlesMessage(MSG.stringFrom(what));
switch (what) {
case MSG_BEACON_LAYOUT_UPDATE:
        bootstrapper.updateBeaconLayout();
      break;
case MSG_SDK_SCANNER_MESSAGE:
    Bundle message=intent.getParcelableExtra(EXTRA_GENERIC_WHAT);
  bootstrapper.scanner.handlePlatformMessage(message);
break;
case MSG_SETTINGS_UPDATE:
bootstrapper.updateSettings();
break;
case MSG_UPLOAD_HISTORY:
bootstrapper.uploadHistory();
break;
case GENERIC_TYPE_BEACON_ACTION:
{
try {
BeaconEvent beaconEvent=intent.getParcelableExtra(EXTRA_GENERIC_WHAT);
int index=intent.getIntExtra(EXTRA_GENERIC_INDEX,0);
Logger.log.beaconResolveState(beaconEvent,"String_Node_Str");
bootstrapper.presentEventDirectly(beaconEvent,index);
}
 catch (Exception e) {
e.printStackTrace();
}
break;
}
case GENERIC_TYPE_RETRY_RESOLVE_SCANEVENT:
{
ResolutionConfiguration configuration=intent.getParcelableExtra(EXTRA_GENERIC_WHAT);
bootstrapper.retryScanEventResolve(configuration);
break;
}
case MSG_APPLICATION_IN_FOREGROUND:
{
bootstrapper.hostApplicationInForeground();
break;
}
case MSG_APPLICATION_IN_BACKGROUND:
{
bootstrapper.hostApplicationInBackground();
break;
}
case MSG_SET_API_TOKEN:
{
if (intent.hasExtra(MSG_SET_API_TOKEN_TOKEN)) {
String apiToken=intent.getStringExtra(MSG_SET_API_TOKEN_TOKEN);
bootstrapper.setApiToken(apiToken);
persistConfiguration(bootstrapper);
}
break;
}
case MSG_TYPE_SET_RESOLVER_ENDPOINT:
{
if (intent.hasExtra(MSG_SET_RESOLVER_ENDPOINT_ENDPOINT_URL)) {
try {
URL resolverURL=(URL)intent.getSerializableExtra(MSG_SET_RESOLVER_ENDPOINT_ENDPOINT_URL);
URLFactory.setLayoutURL(resolverURL.toString());
}
 catch (Exception e) {
Logger.log.logError("String_Node_Str" + MSG_SET_RESOLVER_ENDPOINT_ENDPOINT_URL,e);
}
}
break;
}
case MSG_UNREGISTER_PRESENTATION_DELEGATE:
{
if (intent.hasExtra(EXTRA_MESSENGER)) {
Messenger messenger=intent.getParcelableExtra(EXTRA_MESSENGER);
presentationDelegates.remove(messenger);
}
break;
}
case MSG_PING:
{
bootstrapper.startScanning();
break;
}
case MSG_BLUETOOTH:
{
if (intent.hasExtra(EXTRA_BLUETOOTH_STATE)) {
boolean bluetoothOn=intent.getBooleanExtra(EXTRA_BLUETOOTH_STATE,true);
if (bluetoothOn) {
bootstrapper.startScanning();
}
 else {
bootstrapper.stopScanning();
}
}
break;
}
}
}
}
 else {
Logger.log.logError("String_Node_Str");
createBootstrapperFromDiskConfiguration();
if (bootstrapper != null) {
bootstrapper.startScanning();
}
}
return START_STICKY;
}

Fixed version (ground truth):
@Override public int onStartCommand(Intent intent,int flags,int startId){
  Logger.log.logServiceState("String_Node_Str");
  if (!platform.isBluetoothLowEnergySupported() || !platform.hasMinimumAndroidRequirements()) {
    Logger.log.logError("String_Node_Str");
    stopSelf();
    return START_NOT_STICKY;
  }
  List<BroadcastReceiver> broadcastReceiver=platform.getBroadcastReceiver();
  if (broadcastReceiver.isEmpty()) {
    Logger.log.logError("String_Node_Str");
    stopSelf();
    return START_NOT_STICKY;
  }
 else {
    platform.registerBroadcastReceiver(broadcastReceiver);
  }
  if (intent != null) {
    Logger.log.serviceHandlesMessage(MSG.stringFrom(intent.getIntExtra(SensorbergService.EXTRA_GENERIC_TYPE,-1)));
    handleDebuggingIntent(intent,this);
    if (handleIntentEvenIfNoBootstrapperPresent(intent)) {
      stopSelf();
      return START_NOT_STICKY;
    }
    if (bootstrapper == null) {
      updateDiskConfiguration(intent);
    }
    if (intent.hasExtra(EXTRA_START_SERVICE)) {
      if (bootstrapper == null) {
        String apiKey=intent.getStringExtra(EXTRA_API_KEY);
        if (isEmpty(apiKey)) {
          apiKey=ManifestParser.get(META_DATA_API_KEY,this);
        }
        if (!isEmpty(apiKey)) {
          bootstrapper=new InternalApplicationBootstrapper(platform);
          bootstrapper.setApiToken(apiKey);
          persistConfiguration(bootstrapper);
          bootstrapper.startScanning();
          return START_STICKY;
        }
      }
 else {
        bootstrapper.startScanning();
        Logger.log.logError("String_Node_Str");
        return START_STICKY;
      }
      Logger.log.logError("String_Node_Str");
      stopSelf();
      return START_NOT_STICKY;
    }
    if (intent.hasExtra(SensorbergService.EXTRA_GENERIC_TYPE)) {
      if (bootstrapper == null) {
        createBootstrapperFromDiskConfiguration();
        if (bootstrapper == null) {
          Logger.log.logError("String_Node_Str");
          stopSelf();
          return START_NOT_STICKY;
        }
      }
      int what=intent.getIntExtra(SensorbergService.EXTRA_GENERIC_TYPE,-1);
      Logger.log.serviceHandlesMessage(MSG.stringFrom(what));
switch (what) {
case MSG_BEACON_LAYOUT_UPDATE:
        bootstrapper.updateBeaconLayout();
      break;
case MSG_SDK_SCANNER_MESSAGE:
    Bundle message=intent.getParcelableExtra(EXTRA_GENERIC_WHAT);
  bootstrapper.scanner.handlePlatformMessage(message);
break;
case MSG_SETTINGS_UPDATE:
bootstrapper.updateSettings();
break;
case MSG_UPLOAD_HISTORY:
bootstrapper.uploadHistory();
break;
case GENERIC_TYPE_BEACON_ACTION:
{
try {
BeaconEvent beaconEvent=intent.getParcelableExtra(EXTRA_GENERIC_WHAT);
int index=intent.getIntExtra(EXTRA_GENERIC_INDEX,0);
Logger.log.beaconResolveState(beaconEvent,"String_Node_Str");
bootstrapper.presentEventDirectly(beaconEvent,index);
}
 catch (Exception e) {
e.printStackTrace();
}
break;
}
case GENERIC_TYPE_RETRY_RESOLVE_SCANEVENT:
{
ResolutionConfiguration configuration=intent.getParcelableExtra(EXTRA_GENERIC_WHAT);
bootstrapper.retryScanEventResolve(configuration);
break;
}
case MSG_APPLICATION_IN_FOREGROUND:
{
bootstrapper.hostApplicationInForeground();
break;
}
case MSG_APPLICATION_IN_BACKGROUND:
{
bootstrapper.hostApplicationInBackground();
break;
}
case MSG_SET_API_TOKEN:
{
if (intent.hasExtra(MSG_SET_API_TOKEN_TOKEN)) {
String apiToken=intent.getStringExtra(MSG_SET_API_TOKEN_TOKEN);
bootstrapper.setApiToken(apiToken);
persistConfiguration(bootstrapper);
}
break;
}
case MSG_TYPE_SET_RESOLVER_ENDPOINT:
{
if (intent.hasExtra(MSG_SET_RESOLVER_ENDPOINT_ENDPOINT_URL)) {
try {
URL resolverURL=(URL)intent.getSerializableExtra(MSG_SET_RESOLVER_ENDPOINT_ENDPOINT_URL);
URLFactory.setLayoutURL(resolverURL.toString());
}
 catch (Exception e) {
Logger.log.logError("String_Node_Str" + MSG_SET_RESOLVER_ENDPOINT_ENDPOINT_URL,e);
}
}
break;
}
case MSG_REGISTER_PRESENTATION_DELEGATE:
{
if (intent.hasExtra(EXTRA_MESSENGER)) {
Messenger messenger=intent.getParcelableExtra(EXTRA_MESSENGER);
presentationDelegates.add(messenger);
}
break;
}
case MSG_UNREGISTER_PRESENTATION_DELEGATE:
{
if (intent.hasExtra(EXTRA_MESSENGER)) {
Messenger messenger=intent.getParcelableExtra(EXTRA_MESSENGER);
presentationDelegates.remove(messenger);
}
break;
}
case MSG_PING:
{
bootstrapper.startScanning();
break;
}
case MSG_BLUETOOTH:
{
if (intent.hasExtra(EXTRA_BLUETOOTH_STATE)) {
boolean bluetoothOn=intent.getBooleanExtra(EXTRA_BLUETOOTH_STATE,true);
if (bluetoothOn) {
bootstrapper.startScanning();
}
 else {
bootstrapper.stopScanning();
}
}
break;
}
}
}
}
 else {
Logger.log.logError("String_Node_Str");
createBootstrapperFromDiskConfiguration();
if (bootstrapper != null) {
bootstrapper.startScanning();
}
}
return START_STICKY;
}