Program: 29557
Project: 29557
Buggy source:
public List<EngineInfo> setupContainerInfos(final ArchiveHandler handler,Collection<? extends Sniffer> sniffers,DeploymentContext context) throws Exception {
}

Fixed version (ground truth):
public List<EngineInfo> setupContainerInfos(final ArchiveHandler handler,Collection<? extends Sniffer> sniffers,DeploymentContext context) throws Exception {
  final ActionReport report=context.getActionReport();
  DeploymentTracing tracing=context.getModuleMetaData(DeploymentTracing.class);
  Map<Deployer,EngineInfo> containerInfosByDeployers=new LinkedHashMap<Deployer,EngineInfo>();
  for (  Sniffer sniffer : sniffers) {
    if (sniffer.getContainersNames() == null || sniffer.getContainersNames().length == 0) {
      report.failure(logger,"String_Node_Str" + sniffer.getModuleType(),null);
      return null;
    }
    final String containerName=sniffer.getContainersNames()[0];
    if (tracing != null) {
      tracing.addContainerMark(DeploymentTracing.ContainerMark.SNIFFER_DONE,containerName);
    }
    EngineInfo engineInfo=containerRegistry.getContainer(containerName);
    if (engineInfo == null) {
      Collection<EngineInfo> containersInfo=null;
synchronized (containerRegistry) {
        if (containerRegistry.getContainer(containerName) == null) {
          if (tracing != null) {
            tracing.addContainerMark(DeploymentTracing.ContainerMark.BEFORE_CONTAINER_SETUP,containerName);
          }
          containersInfo=setupContainer(sniffer,logger,context);
          if (tracing != null) {
            tracing.addContainerMark(DeploymentTracing.ContainerMark.AFTER_CONTAINER_SETUP,containerName);
          }
          if (containersInfo == null || containersInfo.size() == 0) {
            String msg="String_Node_Str" + sniffer.getModuleType();
            report.failure(logger,msg,null);
            throw new Exception(msg);
          }
        }
      }
      if (containersInfo != null && !startContainers(containersInfo,logger,context)) {
        final String msg="String_Node_Str" + containerName;
        report.failure(logger,msg,null);
        throw new Exception(msg);
      }
    }
    engineInfo=containerRegistry.getContainer(sniffer.getContainersNames()[0]);
    if (tracing != null) {
      tracing.addContainerMark(DeploymentTracing.ContainerMark.GOT_CONTAINER,containerName);
    }
    if (engineInfo == null) {
      final String msg="String_Node_Str" + containerName;
      report.failure(logger,msg,null);
      throw new Exception(msg);
    }
    Deployer deployer=getDeployer(engineInfo);
    if (deployer == null) {
      if (!startContainers(Collections.singleton(engineInfo),logger,context)) {
        final String msg="String_Node_Str" + containerName;
        report.failure(logger,msg,null);
        throw new Exception(msg);
      }
      deployer=getDeployer(engineInfo);
      if (deployer == null) {
        report.failure(logger,"String_Node_Str" + engineInfo.getContainer().getClass() + "String_Node_Str");
        return null;
      }
    }
    if (tracing != null) {
      tracing.addContainerMark(DeploymentTracing.ContainerMark.GOT_DEPLOYER,containerName);
    }
    containerInfosByDeployers.put(deployer,engineInfo);
  }
  List<ApplicationMetaDataProvider> providers=new LinkedList<ApplicationMetaDataProvider>();
  providers.addAll(habitat.getAllByContract(ApplicationMetaDataProvider.class));
  List<EngineInfo> sortedEngineInfos=new ArrayList<EngineInfo>();
  Map<Class,ApplicationMetaDataProvider> typeByProvider=new HashMap<Class,ApplicationMetaDataProvider>();
  for (  ApplicationMetaDataProvider provider : habitat.getAllByContract(ApplicationMetaDataProvider.class)) {
    if (provider.getMetaData() != null) {
      for (      Class provided : provider.getMetaData().provides()) {
        typeByProvider.put(provided,provider);
      }
    }
  }
  for (  ApplicationMetaDataProvider provider : habitat.getAllByContract(ApplicationMetaDataProvider.class)) {
    if (provider.getMetaData() != null) {
      for (      Class dependency : provider.getMetaData().requires()) {
        if (!typeByProvider.containsKey(dependency)) {
          logger.warning("String_Node_Str" + provider + "String_Node_Str"+ dependency+ "String_Node_Str");
        }
      }
    }
  }
  Map<Class,Deployer> typeByDeployer=new HashMap<Class,Deployer>();
  for (  Deployer deployer : containerInfosByDeployers.keySet()) {
    if (deployer.getMetaData() != null) {
      for (      Class provided : deployer.getMetaData().provides()) {
        typeByDeployer.put(provided,deployer);
      }
    }
  }
  for (  Deployer deployer : containerInfosByDeployers.keySet()) {
    if (deployer.getMetaData() != null) {
      for (      Class dependency : deployer.getMetaData().requires()) {
        if (!typeByDeployer.containsKey(dependency) && !typeByProvider.containsKey(dependency)) {
          Service s=deployer.getClass().getAnnotation(Service.class);
          String serviceName;
          if (s != null && s.name() != null && s.name().length() > 0) {
            serviceName=s.name();
          }
 else {
            serviceName=deployer.getClass().getSimpleName();
          }
          report.failure(logger,serviceName + "String_Node_Str" + dependency+ "String_Node_Str",null);
          return null;
        }
      }
    }
  }
  List<Deployer> orderedDeployers=new ArrayList<Deployer>();
  for (  Deployer deployer : containerInfosByDeployers.keySet()) {
    if (logger.isLoggable(Level.FINE)) {
      logger.fine("String_Node_Str" + deployer.getClass());
    }
    loadDeployer(orderedDeployers,deployer,typeByDeployer,typeByProvider,context);
  }
  for (  Deployer deployer : orderedDeployers) {
    if (logger.isLoggable(Level.FINE)) {
      logger.fine("String_Node_Str" + deployer.getClass());
    }
    final MetaData metadata=deployer.getMetaData();
    try {
      if (metadata != null) {
        if (metadata.provides() == null || metadata.provides().length == 0) {
          deployer.loadMetaData(null,context);
        }
 else {
          for (          Class<?> provide : metadata.provides()) {
            if (context.getModuleMetaData(provide) == null) {
              context.addModuleMetaData(deployer.loadMetaData(provide,context));
            }
 else {
              deployer.loadMetaData(null,context);
            }
          }
        }
      }
 else {
        deployer.loadMetaData(null,context);
      }
    }
 catch (    Exception e) {
      report.failure(logger,"String_Node_Str" + deployer.getClass() + "String_Node_Str",e);
      throw e;
    }
    sortedEngineInfos.add(containerInfosByDeployers.get(deployer));
  }
  return sortedEngineInfos;
}