Program: 13170
Project: 13170
Buggy source:
/** 
 * Check and update the application state
 */
private void checkState(){
  Bundle[] bundles=context.getBundleContext().getBundles();
  List<String> missingBundles=new ArrayList<String>(requiredBundles);
  List<String> bundleFailures=new ArrayList<String>();
  List<String> fragmentFailures=new ArrayList<String>();
  for (  String req : requiredBundles) {
    for (    Bundle bundle : bundles) {
      String symbolicName=bundle.getSymbolicName();
      if (symbolicName != null && symbolicName.matches(req)) {
        if (isFragment(bundle)) {
          if (bundle.getState() != Bundle.RESOLVED) {
            fragmentFailures.add(bundle.getSymbolicName());
          }
        }
 else {
          if (bundle.getState() != Bundle.ACTIVE) {
            bundleFailures.add(bundle.getSymbolicName());
          }
        }
        missingBundles.remove(req);
      }
    }
  }
  ServiceReference[] refs=null;
  try {
    refs=context.getBundleContext().getAllServiceReferences(null,null);
  }
 catch (  Exception e) {
    logger.debug("String_Node_Str",e);
  }
  List<String> missingServices=new ArrayList<String>(requiredServices);
  if (refs != null && refs.length > 0) {
    for (    String req : requiredServices) {
      for (      ServiceReference ref : refs) {
        String pid=(String)ref.getProperty(Constants.SERVICE_PID);
        if (pid != null && pid.matches(req)) {
          missingServices.remove(req);
          break;
        }
      }
    }
  }
  AppState updatedAppState=null;
  String updatedShortDesc=null;
  if (missingBundles.size() > 0 || bundleFailures.size() > 0 || fragmentFailures.size() > 0) {
    updatedAppState=AppState.ACTIVE_NOT_READY;
    updatedShortDesc="String_Node_Str" + missingBundles + "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);
}

Fixed version (ground truth):
/** 
 * Check and update the application state
 */
private void checkState(){
  Bundle[] bundles=context.getBundleContext().getBundles();
  List<String> missingBundles=new ArrayList<String>(requiredBundles);
  List<String> bundleFailures=new ArrayList<String>();
  List<String> fragmentFailures=new ArrayList<String>();
  for (  String req : requiredBundles) {
    for (    Bundle bundle : bundles) {
      String symbolicName=bundle.getSymbolicName();
      if (symbolicName != null && symbolicName.matches(req)) {
        if (isFragment(bundle)) {
          if (bundle.getState() != Bundle.RESOLVED) {
            fragmentFailures.add(bundle.getSymbolicName());
          }
        }
 else {
          if (bundle.getState() != Bundle.ACTIVE) {
            bundleFailures.add(bundle.getSymbolicName());
          }
        }
        missingBundles.remove(req);
      }
    }
  }
  ServiceReference[] refs=null;
  try {
    refs=context.getBundleContext().getAllServiceReferences(null,null);
  }
 catch (  Exception e) {
    logger.debug("String_Node_Str",e);
  }
  List<String> missingServices=new ArrayList<String>(requiredServices);
  if (refs != null && refs.length > 0) {
    for (    String req : requiredServices) {
      for (      ServiceReference ref : refs) {
        String pid=(String)ref.getProperty(Constants.SERVICE_PID);
        if (pid != null && pid.matches(req)) {
          missingServices.remove(req);
          break;
        }
      }
    }
  }
  AppState updatedAppState=null;
  String updatedShortDesc=null;
  if (missingBundles.size() > 0 || bundleFailures.size() > 0 || fragmentFailures.size() > 0) {
    updatedAppState=AppState.ACTIVE_NOT_READY;
    updatedShortDesc="String_Node_Str" + missingBundles + "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) {
    updatedAppState=AppState.ACTIVE_NOT_READY;
    updatedShortDesc="String_Node_Str";
  }
 else {
    updatedAppState=AppState.ACTIVE_READY;
    updatedShortDesc="String_Node_Str";
  }
  setState(updatedAppState,updatedShortDesc);
}