Program: 13313
Project: 13313
Buggy source:
/** 
 * Check and update the application state
 */
private void checkState(){
  Bundle[] bundles=context.getBundleContext().getBundles();
  List<String> bundleFailures=new ArrayList<String>();
  List<String> fragmentFailures=new ArrayList<String>();
  for (  Bundle bundle : bundles) {
    if (requiredBundles.contains(bundle.getSymbolicName())) {
      if (isFragment(bundle)) {
        if (bundle.getState() != Bundle.RESOLVED) {
          fragmentFailures.add(bundle.getSymbolicName());
        }
      }
 else {
        if (bundle.getState() != Bundle.ACTIVE) {
          bundleFailures.add(bundle.getSymbolicName());
        }
      }
    }
  }
  ServiceReference[] refs=null;
  try {
    refs=context.getBundleContext().getAllServiceReferences(null,null);
  }
 catch (  InvalidSyntaxException e) {
    logger.debug("String_Node_Str",e);
  }
  Map<String,ServiceReference> pidToRef=new HashMap<String,ServiceReference>();
  for (  ServiceReference ref : refs) {
    String pid=(String)ref.getProperty(Constants.SERVICE_PID);
    if (pid != null) {
      pidToRef.put(pid,ref);
    }
  }
  List<String> missingServices=new ArrayList<String>();
  for (  String req : requiredServices) {
    if (!pidToRef.containsKey(req)) {
      missingServices.add(req);
    }
  }
  AppState updatedAppState=null;
  String updatedShortDesc=null;
  if (bundleFailures.size() > 0 || fragmentFailures.size() > 0) {
    updatedAppState=AppState.ACTIVE_NOT_READY;
    updatedShortDesc="String_Node_Str" + bundleFailures + "String_Node_Str"+ fragmentFailures;
  }
 else   if (missingServices.size() > 0) {
    updatedAppState=AppState.ACTIVE_NOT_READY;
    updatedShortDesc="String_Node_Str" + missingServices;
  }
 else   if (!clusterUp) {
    if (cluster != null && !cluster.isStarted()) {
      cluster.startClusterManagement();
    }
    updatedAppState=AppState.ACTIVE_NOT_READY;
    updatedShortDesc="String_Node_Str";
  }
 else {
    updatedAppState=AppState.ACTIVE_READY;
    updatedShortDesc="String_Node_Str";
  }
  setState(updatedAppState,updatedShortDesc);
}

Fixed version (ground truth):
/** 
 * Check and update the application state
 */
private void checkState(){
  Bundle[] bundles=context.getBundleContext().getBundles();
  List<String> bundleFailures=new ArrayList<String>();
  List<String> fragmentFailures=new ArrayList<String>();
  for (  Bundle bundle : bundles) {
    if (requiredBundles.contains(bundle.getSymbolicName())) {
      if (isFragment(bundle)) {
        if (bundle.getState() != Bundle.RESOLVED) {
          fragmentFailures.add(bundle.getSymbolicName());
        }
      }
 else {
        if (bundle.getState() != Bundle.ACTIVE) {
          bundleFailures.add(bundle.getSymbolicName());
        }
      }
    }
  }
  ServiceReference[] refs=null;
  try {
    refs=context.getBundleContext().getAllServiceReferences(null,null);
  }
 catch (  InvalidSyntaxException e) {
    logger.debug("String_Node_Str",e);
  }
  Map<String,ServiceReference> pidToRef=new HashMap<String,ServiceReference>();
  for (  ServiceReference ref : refs) {
    String pid=(String)ref.getProperty(Constants.SERVICE_PID);
    if (pid != null) {
      pidToRef.put(pid,ref);
    }
  }
  List<String> missingServices=new ArrayList<String>();
  for (  String req : requiredServices) {
    if (!pidToRef.containsKey(req)) {
      missingServices.add(req);
    }
  }
  AppState updatedAppState=null;
  String updatedShortDesc=null;
  if (bundleFailures.size() > 0 || fragmentFailures.size() > 0) {
    updatedAppState=AppState.ACTIVE_NOT_READY;
    updatedShortDesc="String_Node_Str" + bundleFailures + "String_Node_Str"+ fragmentFailures;
  }
 else   if (missingServices.size() > 0) {
    updatedAppState=AppState.ACTIVE_NOT_READY;
    updatedShortDesc="String_Node_Str" + missingServices;
  }
 else   if (clusterEnabled && !clusterUp) {
    if (cluster != null && !cluster.isStarted()) {
      cluster.startClusterManagement();
    }
    updatedAppState=AppState.ACTIVE_NOT_READY;
    updatedShortDesc="String_Node_Str";
  }
 else {
    updatedAppState=AppState.ACTIVE_READY;
    updatedShortDesc="String_Node_Str";
  }
  setState(updatedAppState,updatedShortDesc);
}