nus-yam/ex-repair huggingface dataset:
Program: 62335
Project: 62335
Buggy source:
/** 
 * This method load the defaults suggestions to ES.
 * @throws IOException
 */
@PostConstruct public void loadDefaultSuggestions() throws IOException {
  try (InputStream input=Thread.currentThread().getContextClassLoader().getResourceAsStream("String_Node_Str")){
    SuggestionEntry[] suggestions=YamlParserUtil.parse(input,SuggestionEntry[].class);
    for (    SuggestionEntry suggestionEntry : suggestions) {
      suggestionEntry.generateId();
      if (!isSuggestionExist(suggestionEntry)) {
        alienDAO.save(suggestionEntry);
      }
    }
  }
 }

Fixed version (ground truth):
/** 
 * This method load the defaults suggestions to ES.
 * @throws IOException
 */
@PostConstruct public void loadDefaultSuggestions() throws IOException {
  try (InputStream input=Thread.currentThread().getContextClassLoader().getResourceAsStream("String_Node_Str")){
    SuggestionEntry[] suggestions=YamlParserUtil.parse(input,SuggestionEntry[].class);
    for (    SuggestionEntry suggestionEntry : suggestions) {
      if (!isSuggestionExist(suggestionEntry)) {
        alienDAO.save(suggestionEntry);
      }
    }
  }
 }
Program: 62336
Project: 62336
Buggy source:
/** 
 * Get all suggestionEntry
 * @return all suggestion entries
 */
public List<SuggestionEntry> getAllSuggestionEntries(){
  return alienDAO.customFindAll(SuggestionEntry.class,null);
}

Fixed version (ground truth):
/** 
 * Get all suggestionEntries, attention this method do not return suggested values
 * @return all suggestion entries without their values
 */
private List<SuggestionEntry> getAllSuggestionEntries(){
  GetMultipleDataResult<SuggestionEntry> result=alienDAO.search(SuggestionEntry.class,null,null,FetchContext.SUMMARY,0,Integer.MAX_VALUE);
  if (result.getData() != null && result.getData().length > 0) {
    return Arrays.asList(result.getData());
  }
 else {
    return new ArrayList<>();
  }
}
Program: 62337
Project: 62337
Buggy source:
private void checkPropertyConstraints(String prefix,Class<? extends IndexedInheritableToscaElement> type,String elementId,String propertyName,List<PropertyConstraint> constraints,ParsingContext context){
  if (constraints != null && !constraints.isEmpty()) {
    for (    PropertyConstraint propertyConstraint : constraints) {
      if (propertyConstraint instanceof EqualConstraint) {
        EqualConstraint equalConstraint=(EqualConstraint)propertyConstraint;
        String valueToCheck=equalConstraint.getEqual();
        checkProperty(prefix,propertyName,valueToCheck,type,elementId,context);
      }
 else       if (propertyConstraint instanceof ValidValuesConstraint) {
        ValidValuesConstraint validValuesConstraint=(ValidValuesConstraint)propertyConstraint;
        if (validValuesConstraint.getValidValues() != null && !validValuesConstraint.getValidValues().isEmpty()) {
          for (          String valueToCheck : validValuesConstraint.getValidValues()) {
            checkProperty(prefix,propertyName,valueToCheck,type,elementId,context);
          }
        }
      }
    }
  }
}

Fixed version (ground truth):
private void checkPropertyConstraints(String prefix,Class<? extends IndexedInheritableToscaElement> type,String elementId,String propertyName,List<PropertyConstraint> constraints,ParsingContext context){
  if (constraints != null && !constraints.isEmpty()) {
    for (    PropertyConstraint propertyConstraint : constraints) {
      if (propertyConstraint instanceof EqualConstraint) {
        EqualConstraint equalConstraint=(EqualConstraint)propertyConstraint;
        String valueToCheck=equalConstraint.getEqual();
        if (checkProperty(prefix,propertyName,valueToCheck,type,elementId,context) == null) {
          createSuggestionEntry(ElasticSearchDAO.TOSCA_ELEMENT_INDEX,IndexedCapabilityType.class,Sets.newHashSet(valueToCheck),elementId,propertyName);
        }
      }
 else       if (propertyConstraint instanceof ValidValuesConstraint) {
        ValidValuesConstraint validValuesConstraint=(ValidValuesConstraint)propertyConstraint;
        if (validValuesConstraint.getValidValues() != null && !validValuesConstraint.getValidValues().isEmpty()) {
          SuggestionEntry foundSuggestion=null;
          for (          String valueToCheck : validValuesConstraint.getValidValues()) {
            foundSuggestion=checkProperty(prefix,propertyName,valueToCheck,type,elementId,context);
            if (foundSuggestion == null) {
              break;
            }
          }
          if (foundSuggestion == null) {
            createSuggestionEntry(ElasticSearchDAO.TOSCA_ELEMENT_INDEX,IndexedCapabilityType.class,Sets.newHashSet(validValuesConstraint.getValidValues()),elementId,propertyName);
          }
        }
      }
    }
  }
}
Program: 62338
Project: 62338
Buggy source:
/** 
 * Upload a TOSCA archive and index its components.
 * @param path The archive path.
 * @return The Csar object from the parsing.
 * @throws ParsingException
 * @throws CSARVersionAlreadyExistsException
 */
public ParsingResult<Csar> upload(Path path) throws ParsingException, CSARVersionAlreadyExistsException {
  ParsingResult<ArchiveRoot> parsingResult=parser.parse(path);
  final ArchiveRoot archiveRoot=parsingResult.getResult();
  if (archiveRoot.hasToscaTopologyTemplate()) {
    AuthorizationUtil.checkHasOneRoleIn(Role.ARCHITECT,Role.ADMIN);
  }
  if (archiveRoot.hasToscaTypes()) {
    AuthorizationUtil.checkHasOneRoleIn(Role.COMPONENTS_MANAGER,Role.ADMIN);
  }
  if (ArchiveUploadService.hasError(parsingResult,null)) {
    if (ArchiveUploadService.hasError(parsingResult,ParsingErrorLevel.ERROR)) {
      return toSimpleResult(parsingResult);
    }
  }
  archiveIndexer.importArchive(archiveRoot,path,parsingResult.getContext().getParsingErrors());
  suggestionService.postProcessSuggestionFromArchive(parsingResult);
  suggestionService.setAllSuggestionIdOnPropertyDefinition();
  return toSimpleResult(parsingResult);
}

Fixed version (ground truth):
/** 
 * Upload a TOSCA archive and index its components.
 * @param path The archive path.
 * @return The Csar object from the parsing.
 * @throws ParsingException
 * @throws CSARVersionAlreadyExistsException
 */
public ParsingResult<Csar> upload(Path path) throws ParsingException, CSARVersionAlreadyExistsException {
  ParsingResult<ArchiveRoot> parsingResult=parser.parse(path);
  final ArchiveRoot archiveRoot=parsingResult.getResult();
  if (archiveRoot.hasToscaTopologyTemplate()) {
    AuthorizationUtil.checkHasOneRoleIn(Role.ARCHITECT,Role.ADMIN);
  }
  if (archiveRoot.hasToscaTypes()) {
    AuthorizationUtil.checkHasOneRoleIn(Role.COMPONENTS_MANAGER,Role.ADMIN);
  }
  if (ArchiveUploadService.hasError(parsingResult,null)) {
    if (ArchiveUploadService.hasError(parsingResult,ParsingErrorLevel.ERROR)) {
      return toSimpleResult(parsingResult);
    }
  }
  archiveIndexer.importArchive(archiveRoot,path,parsingResult.getContext().getParsingErrors());
  try {
    suggestionService.postProcessSuggestionFromArchive(parsingResult);
    suggestionService.setAllSuggestionIdOnPropertyDefinition();
  }
 catch (  Exception e) {
    log.error("String_Node_Str");
  }
  return toSimpleResult(parsingResult);
}
Program: 62339
Project: 62339
Buggy source:
private RequirementDefinition getRequirementDefinitionByNameInHierarchy(IndexedNodeType indexedNodeType,String name,ArchiveRoot archiveRoot){
  RequirementDefinition rd=getRequirementDefinitionByName(indexedNodeType,name);
  if (rd != null) {
    return rd;
  }
  List<String> derivedFrom=indexedNodeType.getDerivedFrom();
  if (derivedFrom == null) {
    return null;
  }
  Map<String,IndexedNodeType> hierarchy=Maps.newHashMap();
  for (  String parentId : derivedFrom) {
    IndexedNodeType parentType=ToscaParsingUtil.getNodeTypeFromArchiveOrDependencies(parentId,archiveRoot,searchService);
    hierarchy.put(parentType.getId(),parentType);
  }
  List<IndexedNodeType> hierarchyList=IndexedModelUtils.orderByDerivedFromHierarchy(hierarchy);
  Collections.reverse(hierarchyList);
  for (  IndexedNodeType parentType : hierarchyList) {
    rd=getRequirementDefinitionByName(parentType,name);
    if (rd != null) {
      return rd;
    }
  }
  return null;
}

Fixed version (ground truth):
private RequirementDefinition getRequirementDefinitionByNameInHierarchy(IndexedNodeType indexedNodeType,String name,ArchiveRoot archiveRoot){
  RequirementDefinition rd=getRequirementDefinitionByName(indexedNodeType,name);
  if (rd != null) {
    return rd;
  }
  List<String> derivedFrom=indexedNodeType.getDerivedFrom();
  if (derivedFrom == null) {
    return null;
  }
  Map<String,IndexedNodeType> hierarchy=Maps.newHashMap();
  for (  String parentId : derivedFrom) {
    IndexedNodeType parentType=ToscaParsingUtil.getNodeTypeFromArchiveOrDependencies(parentId,archiveRoot,searchService);
    hierarchy.put(parentType.getElementId(),parentType);
  }
  List<IndexedNodeType> hierarchyList=IndexedModelUtils.orderByDerivedFromHierarchy(hierarchy);
  Collections.reverse(hierarchyList);
  for (  IndexedNodeType parentType : hierarchyList) {
    rd=getRequirementDefinitionByName(parentType,name);
    if (rd != null) {
      return rd;
    }
  }
  return null;
}
Program: 62340
Project: 62340
Buggy source:
private <T extends IndexedInheritableToscaElement>void mergeHierarchy(T indexedElement,ArchiveRoot archiveRoot){
  List<String> derivedFrom=indexedElement.getDerivedFrom();
  if (derivedFrom == null) {
    return;
  }
  Map<String,T> hierarchy=Maps.newHashMap();
  for (  String parentId : derivedFrom) {
    T parentElement=(T)ToscaParsingUtil.getElementFromArchiveOrDependencies(indexedElement.getClass(),parentId,archiveRoot,searchService);
    hierarchy.put(parentElement.getId(),parentElement);
  }
  List<T> hierarchyList=IndexedModelUtils.orderByDerivedFromHierarchy(hierarchy);
  hierarchyList.add(indexedElement);
  for (int i=0; i < hierarchyList.size() - 1; i++) {
    T from=hierarchyList.get(i);
    T to=hierarchyList.get(i + 1);
    if (Objects.equal(to.getArchiveName(),archiveRoot.getArchive().getName()) && Objects.equal(to.getArchiveVersion(),archiveRoot.getArchive().getVersion())) {
      IndexedModelUtils.mergeInheritableIndex(from,to);
    }
  }
}

Fixed version (ground truth):
private <T extends IndexedInheritableToscaElement>void mergeHierarchy(T indexedElement,ArchiveRoot archiveRoot){
  List<String> derivedFrom=indexedElement.getDerivedFrom();
  if (derivedFrom == null) {
    return;
  }
  Map<String,T> hierarchy=Maps.newHashMap();
  for (  String parentId : derivedFrom) {
    T parentElement=(T)ToscaParsingUtil.getElementFromArchiveOrDependencies(indexedElement.getClass(),parentId,archiveRoot,searchService);
    hierarchy.put(parentElement.getElementId(),parentElement);
  }
  List<T> hierarchyList=IndexedModelUtils.orderByDerivedFromHierarchy(hierarchy);
  hierarchyList.add(indexedElement);
  for (int i=0; i < hierarchyList.size() - 1; i++) {
    T from=hierarchyList.get(i);
    T to=hierarchyList.get(i + 1);
    if (Objects.equal(to.getArchiveName(),archiveRoot.getArchive().getName()) && Objects.equal(to.getArchiveVersion(),archiveRoot.getArchive().getVersion())) {
      IndexedModelUtils.mergeInheritableIndex(from,to);
    }
  }
}
Program: 62341
Project: 62341
Buggy source:
@Override public void registerStompEndpoints(StompEndpointRegistry registry){
  registry.addEndpoint("String_Node_Str").withSockJS().setSessionCookieNeeded(true);
  registry.addEndpoint("String_Node_Str").withSockJS().setSessionCookieNeeded(true);
}

Fixed version (ground truth):
@Override public void registerStompEndpoints(StompEndpointRegistry registry){
  registry.addEndpoint("String_Node_Str").withSockJS().setSessionCookieNeeded(true);
  registry.addEndpoint("String_Node_Str").withSockJS().setSessionCookieNeeded(true);
  registry.addEndpoint("String_Node_Str").withSockJS().setSessionCookieNeeded(true);
}
Program: 62342
Project: 62342
Buggy source:
/** 
 * Get the audit configuration, this method will cache the configuration in memory
 * @return the audit configuration
 */
public synchronized AuditConfiguration getAuditConfiguration(){
  if (this.auditConfiguration == null) {
    this.auditConfiguration=alienDAO.customFind(AuditConfiguration.class,null);
  }
  return this.auditConfiguration;
}

Fixed version (ground truth):
/** 
 * Get the audit configuration, this method will cache the configuration in memory
 * @return the audit configuration
 */
public synchronized AuditConfiguration getAuditConfiguration(){
  if (this.auditConfiguration == null) {
    this.auditConfiguration=alienDAO.findById(AuditConfiguration.class,AuditConfiguration.ID);
  }
  return this.auditConfiguration;
}
Program: 62343
Project: 62343
Buggy source:
public Method getAuditedMethod(HandlerMethod controllerMethod){
  RequestMapping methodMapping=AnnotationUtils.findAnnotation(controllerMethod.getMethod(),RequestMapping.class);
  RequestMapping controllerMapping=AnnotationUtils.findAnnotation(controllerMethod.getMethod().getDeclaringClass(),RequestMapping.class);
  String contextPath=null;
  String httpMethod=null;
  if (controllerMapping != null) {
    contextPath=getRequestMappingPath(controllerMapping);
    httpMethod=getRequestMappingMethod(controllerMapping);
    if (methodMapping != null) {
      String methodContextPath=getRequestMappingPath(methodMapping);
      String methodHttpMethod=getRequestMappingMethod(methodMapping);
      if (contextPath == null) {
        contextPath=methodContextPath;
      }
 else       if (methodContextPath != null) {
        contextPath+=methodContextPath;
      }
      if (httpMethod == null) {
        httpMethod=methodHttpMethod;
      }
    }
  }
 else   if (methodMapping != null) {
    contextPath=getRequestMappingPath(methodMapping);
    httpMethod=getRequestMappingMethod(methodMapping);
  }
  if (contextPath == null || httpMethod == null) {
    return null;
  }
  Audit audit=getAuditAnnotation(controllerMethod);
  return new Method(contextPath,httpMethod,getAuditCategoryName(controllerMethod,audit),getAuditActionName(controllerMethod,audit));
}

Fixed version (ground truth):
public Method getAuditedMethod(HandlerMethod controllerMethod){
  RequestMapping methodMapping=AnnotationUtils.findAnnotation(controllerMethod.getMethod(),RequestMapping.class);
  RequestMapping controllerMapping=AnnotationUtils.findAnnotation(controllerMethod.getMethod().getDeclaringClass(),RequestMapping.class);
  String httpMethod=null;
  if (controllerMapping != null) {
    httpMethod=getRequestMappingMethod(controllerMapping);
    if (methodMapping != null) {
      String methodHttpMethod=getRequestMappingMethod(methodMapping);
      if (httpMethod == null) {
        httpMethod=methodHttpMethod;
      }
    }
  }
 else   if (methodMapping != null) {
    httpMethod=getRequestMappingMethod(methodMapping);
  }
  if (httpMethod == null) {
    return null;
  }
  Audit audit=getAuditAnnotation(controllerMethod);
  return new Method(httpMethod,getAuditCategoryName(controllerMethod,audit),getAuditActionName(controllerMethod,audit));
}
Program: 62344
Project: 62344
Buggy source:
@JsonIgnore public void setAuditedMethodsMap(Map<Method,Boolean> auditedMethodsMap){
  auditedMethods=Sets.newHashSet();
  if (auditedMethodsMap == null) {
    return;
  }
  for (  Map.Entry<Method,Boolean> auditedMethodsMapEntry : auditedMethodsMap.entrySet()) {
    auditedMethods.add(new AuditedMethod(auditedMethodsMapEntry.getKey().getPath(),auditedMethodsMapEntry.getKey().getMethod(),auditedMethodsMapEntry.getKey().getCategory(),auditedMethodsMapEntry.getKey().getAction(),auditedMethodsMapEntry.getValue()));
  }
}

Fixed version (ground truth):
@JsonIgnore public void setAuditedMethodsMap(Map<Method,Boolean> auditedMethodsMap){
  auditedMethods=Sets.newHashSet();
  if (auditedMethodsMap == null) {
    return;
  }
  for (  Map.Entry<Method,Boolean> auditedMethodsMapEntry : auditedMethodsMap.entrySet()) {
    auditedMethods.add(new AuditedMethod(auditedMethodsMapEntry.getKey().getMethod(),auditedMethodsMapEntry.getKey().getCategory(),auditedMethodsMapEntry.getKey().getAction(),auditedMethodsMapEntry.getValue()));
  }
}
Program: 62345
Project: 62345
Buggy source:
@JsonIgnore public Map<Method,Boolean> getAuditedMethodsMap(){
  Map<Method,Boolean> methodsMap=Maps.newHashMap();
  if (auditedMethods == null) {
    return methodsMap;
  }
  for (  AuditedMethod auditedMethod : auditedMethods) {
    methodsMap.put(new Method(auditedMethod.getPath(),auditedMethod.getMethod(),auditedMethod.getCategory(),auditedMethod.getAction()),auditedMethod.isEnabled());
  }
  return methodsMap;
}

Fixed version (ground truth):
@JsonIgnore public Map<Method,Boolean> getAuditedMethodsMap(){
  Map<Method,Boolean> methodsMap=Maps.newHashMap();
  if (auditedMethods == null) {
    return methodsMap;
  }
  for (  AuditedMethod auditedMethod : auditedMethods) {
    methodsMap.put(new Method(auditedMethod.getMethod(),auditedMethod.getCategory(),auditedMethod.getAction()),auditedMethod.isEnabled());
  }
  return methodsMap;
}
Program: 62346
Project: 62346
Buggy source:
public AuditedMethod(String path,String method,String category,String action,boolean enabled){
  super(path,method,category,action);
  this.enabled=enabled;
}

Fixed version (ground truth):
public AuditedMethod(String method,String category,String action,boolean enabled){
  super(method,category,action);
  this.enabled=enabled;
}
Program: 62347
Project: 62347
Buggy source:
@PostConstruct private void postConstruct(){
  AuditConfiguration auditConfiguration=auditService.getAuditConfiguration();
  Map<Method,Boolean> allAvailableMethodsForAudit=getAllAvailableMethodsForAudit();
  if (auditConfiguration == null) {
    log.info("String_Node_Str");
    auditConfiguration=new AuditConfiguration();
  }
 else {
    log.info("String_Node_Str");
    Map<Method,Boolean> existingMethodsMap=auditConfiguration.getAuditedMethodsMap();
    for (    Map.Entry<Method,Boolean> methodEntry : allAvailableMethodsForAudit.entrySet()) {
      Boolean existingMethodEnabled=existingMethodsMap.get(methodEntry.getKey());
      if (existingMethodEnabled != null) {
        methodEntry.setValue(existingMethodEnabled);
      }
    }
  }
  auditConfiguration.setAuditedMethodsMap(allAvailableMethodsForAudit);
  auditService.saveAuditConfiguration(auditConfiguration);
}

Fixed version (ground truth):
@PostConstruct private void postConstruct(){
  AuditConfiguration auditConfiguration=auditService.getAuditConfiguration();
  Map<Method,Boolean> allAvailableMethodsForAudit=getAllAvailableMethodsForAudit();
  if (auditConfiguration == null) {
    log.info("String_Node_Str");
    auditConfiguration=new AuditConfiguration();
    auditConfiguration.setId(AuditConfiguration.ID);
  }
 else {
    log.info("String_Node_Str");
    Map<Method,Boolean> existingMethodsMap=auditConfiguration.getAuditedMethodsMap();
    for (    Map.Entry<Method,Boolean> methodEntry : allAvailableMethodsForAudit.entrySet()) {
      Boolean existingMethodEnabled=existingMethodsMap.get(methodEntry.getKey());
      if (existingMethodEnabled != null) {
        methodEntry.setValue(existingMethodEnabled);
      }
    }
  }
  auditConfiguration.setAuditedMethodsMap(allAvailableMethodsForAudit);
  auditService.saveAuditConfiguration(auditConfiguration);
}
Program: 62348
Project: 62348
Buggy source:
private AuditTrace getAuditTrace(HttpServletRequest request,HttpServletResponse response,HandlerMethod method,User user,boolean requestContainsJson) throws IOException {
  Audit audit=auditService.getAuditAnnotation(method);
  AuditTrace auditTrace=new AuditTrace();
  auditTrace.setTimestamp(System.currentTimeMillis());
  auditTrace.setAction(auditService.getAuditActionName(method,audit));
  ApiOperation apiDoc=getApiDoc(method);
  if (apiDoc != null) {
    auditTrace.setActionDescription(apiDoc.value());
  }
  auditTrace.setCategory(auditService.getAuditCategoryName(method,audit));
  auditTrace.setUserName(user.getUsername());
  auditTrace.setUserFirstName(user.getFirstName());
  auditTrace.setUserLastName(user.getLastName());
  auditTrace.setUserEmail(user.getEmail());
  auditTrace.setPath(request.getRequestURI());
  auditTrace.setMethod(request.getMethod());
  auditTrace.setRequestParameters(request.getParameterMap());
  auditTrace.setSourceIp(request.getRemoteAddr());
  if (requestContainsJson) {
    auditTrace.setRequestBody(StreamUtils.copyToString(request.getInputStream(),Charsets.UTF_8));
  }
  auditTrace.setResponseStatus(response.getStatus());
  return auditTrace;
}

Fixed version (ground truth):
private AuditTrace getAuditTrace(HttpServletRequest request,HttpServletResponse response,HandlerMethod method,User user,boolean requestContainsJson) throws IOException {
  Audit audit=auditService.getAuditAnnotation(method);
  AuditTrace auditTrace=new AuditTrace();
  auditTrace.setTimestamp(System.currentTimeMillis());
  auditTrace.setAction(auditService.getAuditActionName(method,audit));
  ApiOperation apiDoc=getApiDoc(method);
  if (apiDoc != null) {
    auditTrace.setActionDescription(apiDoc.value());
  }
  auditTrace.setCategory(auditService.getAuditCategoryName(method,audit));
  auditTrace.setUserName(user.getUsername());
  auditTrace.setUserFirstName(user.getFirstName());
  auditTrace.setUserLastName(user.getLastName());
  auditTrace.setUserEmail(user.getEmail());
  auditTrace.setPath(request.getRequestURI());
  auditTrace.setVersion(getApiVersion(request.getRequestURI()));
  auditTrace.setUserAgent(request.getHeader(HttpHeaders.USER_AGENT));
  auditTrace.setAlien4CloudUI(!Strings.isNullOrEmpty(request.getHeader(A4C_UI_HEADER)));
  auditTrace.setMethod(request.getMethod());
  auditTrace.setRequestParameters(request.getParameterMap());
  auditTrace.setSourceIp(request.getRemoteAddr());
  if (requestContainsJson) {
    auditTrace.setRequestBody(StreamUtils.copyToString(request.getInputStream(),Charsets.UTF_8));
  }
  auditTrace.setResponseStatus(response.getStatus());
  return auditTrace;
}
Program: 62349
Project: 62349
Buggy source:
@Override public void filter(List<ILocationMatch> toFilter,Topology topology){
  artifactsElector.setDependencies(topology.getDependencies());
  for (  Entry<String,NodeTemplate> entry : topology.getNodeTemplates().entrySet()) {
    artifactsElector.setTemplate(entry.getValue());
    filterWith(toFilter,artifactsElector);
  }
}

Fixed version (ground truth):
@Override public void filter(List<ILocationMatch> toFilter,Topology topology){
  NodeMatchContext nodeMatchContext=new NodeMatchContext();
  nodeMatchContext.topology=topology;
  for (  Entry<String,NodeTemplate> entry : topology.getNodeTemplates().entrySet()) {
    nodeMatchContext.template=entry.getValue();
    for (Iterator<ILocationMatch> it=toFilter.iterator(); it.hasNext(); ) {
      nodeMatchContext.locationMatch=it.next();
      if (!artifactsElector.isEligible(nodeMatchContext)) {
        it.remove();
      }
    }
  }
}
Program: 62350
Project: 62350
Buggy source:
private boolean areRelationshipsArtifactSupported(ILocationMatch locationMatch,NodeTemplate nodeTemplate){
  if (MapUtils.isNotEmpty(nodeTemplate.getRelationships())) {
    for (    RelationshipTemplate relTemplate : nodeTemplate.getRelationships().values()) {
      if (!isEligible(relTemplate,locationMatch)) {
        return false;
      }
    }
  }
  return true;
}

Fixed version (ground truth):
private boolean areRelationshipsArtifactSupported(LocationMatchNodeFilter.NodeMatchContext matchContext){
  if (MapUtils.isNotEmpty(matchContext.getTemplate().getRelationships())) {
    for (    RelationshipTemplate relTemplate : matchContext.getTemplate().getRelationships().values()) {
      if (!isEligible(relTemplate,matchContext)) {
        return false;
      }
    }
  }
  return true;
}
Program: 62351
Project: 62351
Buggy source:
private boolean isEligible(AbstractTemplate template,ILocationMatch locationMatch){
  if (template == null) {
    return true;
  }
  IOrchestratorPluginFactory orchestratorFactory=orchestratorService.getPluginFactory(locationMatch.getOrchestrator());
  if (orchestratorFactory.getArtifactSupport() == null || ArrayUtils.isEmpty(orchestratorFactory.getArtifactSupport().getTypes())) {
    return true;
  }
  String[] supportedArtifacts=orchestratorFactory.getArtifactSupport().getTypes();
  IndexedArtifactToscaElement indexedArtifactToscaElement=csarSearchService.getRequiredElementInDependencies(IndexedArtifactToscaElement.class,template.getType(),dependencies);
  if (MapUtils.isNotEmpty(indexedArtifactToscaElement.getInterfaces())) {
    for (    Interface interfaz : indexedArtifactToscaElement.getInterfaces().values()) {
      for (      Operation operation : interfaz.getOperations().values()) {
        if (operation.getImplementationArtifact() != null) {
          String artifactTypeString=operation.getImplementationArtifact().getArtifactType();
          IndexedArtifactType artifactType=csarSearchService.getRequiredElementInDependencies(IndexedArtifactType.class,artifactTypeString,dependencies);
          if (!isFromOneOfTypes(supportedArtifacts,artifactType)) {
            return false;
          }
        }
      }
    }
  }
  return true;
}

Fixed version (ground truth):
private boolean isEligible(AbstractTemplate template,LocationMatchNodeFilter.NodeMatchContext matchContext){
  if (template == null) {
    return true;
  }
  ArtifactSupport artifactSupport=matchContext.getArtifactSupport();
  if (artifactSupport == null || ArrayUtils.isEmpty(artifactSupport.getTypes())) {
    return true;
  }
  String[] supportedArtifacts=artifactSupport.getTypes();
  IndexedArtifactToscaElement indexedArtifactToscaElement=matchContext.getElement(IndexedArtifactToscaElement.class,template.getType());
  if (MapUtils.isNotEmpty(indexedArtifactToscaElement.getInterfaces())) {
    for (    Interface interfaz : indexedArtifactToscaElement.getInterfaces().values()) {
      for (      Operation operation : interfaz.getOperations().values()) {
        if (operation.getImplementationArtifact() != null) {
          String artifactTypeString=operation.getImplementationArtifact().getArtifactType();
          IndexedArtifactType artifactType=matchContext.getElement(IndexedArtifactType.class,artifactTypeString);
          if (!isFromOneOfTypes(supportedArtifacts,artifactType)) {
            return false;
          }
        }
      }
    }
  }
  return true;
}
Program: 62352
Project: 62352
Buggy source:
private void createLocation(Orchestrator orchestrator,Location location,String infrastructureType){
  ensureNameUnicityAndSave(location);
  location.setInfrastructureType(infrastructureType);
  Set<CSARDependency> dependencies=locationArchiveIndexer.indexArchives(orchestrator,location);
  location.setDependencies(dependencies);
  alienDAO.save(location);
  autoConfigure(orchestrator,location);
  try {
    locationResourceService.getLocationResourcesFromOrchestrator(location);
  }
 catch (  NotFoundException e) {
    delete(location.getId());
    throw new MissingCSARDependencies(e.getMessage());
  }
}

Fixed version (ground truth):
private void createLocation(Orchestrator orchestrator,Location location,String infrastructureType){
  ensureNameUnicityAndSave(location);
  location.setInfrastructureType(infrastructureType);
  Set<CSARDependency> dependencies=locationArchiveIndexer.indexArchives(orchestrator,location);
  location.setDependencies(dependencies);
  alienDAO.save(location);
  autoConfigure(orchestrator,location);
  try {
    locationResourceService.getLocationResourcesFromOrchestrator(location);
  }
 catch (  NotFoundException e) {
    delete(location.getId());
    throw new MissingCSARDependenciesException(e.getMessage());
  }
}
Program: 62353
Project: 62353
Buggy source:
private List<PluginArchive> parseArchives(){
  List<PluginArchive> archives=Lists.newArrayList();
  addToAchive(archives,"String_Node_Str");
  addToAchive(archives,"String_Node_Str");
  return archives;
}

Fixed version (ground truth):
private List<PluginArchive> parseArchives() throws ParsingException {
  List<PluginArchive> archives=Lists.newArrayList();
  addToAchive(archives,"String_Node_Str");
  addToAchive(archives,"String_Node_Str");
  return archives;
}
Program: 62354
Project: 62354
Buggy source:
private void addToAchive(List<PluginArchive> archives,String path){
  Path archivePath=selfContext.getPluginPath().resolve(path);
  try {
    ParsingResult<ArchiveRoot> result=archiveParser.parseDir(archivePath);
    PluginArchive pluginArchive=new PluginArchive(result.getResult(),archivePath);
    archives.add(pluginArchive);
  }
 catch (  ParsingException e) {
    log.error("String_Node_Str",e);
  }
}

Fixed version (ground truth):
private void addToAchive(List<PluginArchive> archives,String path) throws ParsingException {
  Path archivePath=selfContext.getPluginPath().resolve(path);
  ParsingResult<ArchiveRoot> result=archiveParser.parseDir(archivePath);
  PluginArchive pluginArchive=new PluginArchive(result.getResult(),archivePath);
  archives.add(pluginArchive);
}
Program: 62355
Project: 62355
Buggy source:
@Override public List<PluginArchive> pluginArchives(){
  return archives;
}

Fixed version (ground truth):
@Override public List<PluginArchive> pluginArchives() throws PluginParseException {
  if (archives == null) {
    try {
      archives=parseArchives();
    }
 catch (    ParsingException e) {
      log.error(e.getMessage());
      throw new PluginParseException(e.getMessage());
    }
  }
  return archives;
}
Program: 62356
Project: 62356
Buggy source:
@ExceptionHandler(value=MissingCSARDependencies.class) @ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR) @ResponseBody public RestResponse<Void> MissingCSARDependenciesExceptionHandler(MissingCSARDependencies e){
  log.error("String_Node_Str" + e.getMessage());
  return RestResponseBuilder.<Void>builder().error(RestErrorBuilder.builder(RestErrorCode.CSAR_PARSING_ERROR).message(e.getMessage()).build()).build();
}

Fixed version (ground truth):
@ExceptionHandler(value=MissingCSARDependenciesException.class) @ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR) @ResponseBody public RestResponse<Void> MissingCSARDependenciesExceptionHandler(MissingCSARDependenciesException e){
  log.error("String_Node_Str" + e.getMessage());
  return RestResponseBuilder.<Void>builder().error(RestErrorBuilder.builder(RestErrorCode.CSAR_PARSING_ERROR).message(e.getMessage()).build()).build();
}
Program: 62357
Project: 62357
Buggy source:
/** 
 * Inject input artifacts in the corresponding nodes.
 */
public void processInputArtifacts(DeploymentTopology topology){
  if (topology.getInputArtifacts() != null && !topology.getInputArtifacts().isEmpty()) {
    Map<String,List<DeploymentArtifact>> artifactMap=Maps.newHashMap();
    for (    NodeTemplate nodeTemplate : topology.getNodeTemplates().values()) {
      if (nodeTemplate.getArtifacts() != null && !nodeTemplate.getArtifacts().isEmpty()) {
        for (        DeploymentArtifact da : nodeTemplate.getArtifacts().values()) {
          String inputArtifactId=InputArtifactUtil.getInputArtifactId(da);
          if (inputArtifactId != null) {
            List<DeploymentArtifact> das=artifactMap.get(inputArtifactId);
            if (das == null) {
              das=Lists.newArrayList();
              artifactMap.put(inputArtifactId,das);
            }
            das.add(da);
          }
        }
      }
    }
    for (    Map.Entry<String,DeploymentArtifact> e : topology.getInputArtifacts().entrySet()) {
      List<DeploymentArtifact> nodeArtifacts=artifactMap.get(e.getKey());
      if (nodeArtifacts != null) {
        for (        DeploymentArtifact nodeArtifact : nodeArtifacts) {
          nodeArtifact.setArtifactRef(e.getValue().getArtifactRef());
          nodeArtifact.setArtifactName(e.getValue().getArtifactName());
        }
      }
    }
  }
}

Fixed version (ground truth):
/** 
 * Inject input artifacts in the corresponding nodes.
 */
public void processInputArtifacts(DeploymentTopology topology){
  if (topology.getInputArtifacts() != null && !topology.getInputArtifacts().isEmpty()) {
    Map<String,List<DeploymentArtifact>> artifactMap=Maps.newHashMap();
    for (    NodeTemplate nodeTemplate : topology.getNodeTemplates().values()) {
      if (nodeTemplate.getArtifacts() != null && !nodeTemplate.getArtifacts().isEmpty()) {
        for (        DeploymentArtifact da : nodeTemplate.getArtifacts().values()) {
          String inputArtifactId=InputArtifactUtil.getInputArtifactId(da);
          if (inputArtifactId != null) {
            List<DeploymentArtifact> das=artifactMap.get(inputArtifactId);
            if (das == null) {
              das=Lists.newArrayList();
              artifactMap.put(inputArtifactId,das);
            }
            das.add(da);
          }
        }
      }
    }
    for (    Map.Entry<String,DeploymentArtifact> e : topology.getInputArtifacts().entrySet()) {
      List<DeploymentArtifact> nodeArtifacts=artifactMap.get(e.getKey());
      if (nodeArtifacts != null) {
        for (        DeploymentArtifact nodeArtifact : nodeArtifacts) {
          nodeArtifact.setArtifactRef(e.getValue().getArtifactRef());
          nodeArtifact.setArtifactName(e.getValue().getArtifactName());
          nodeArtifact.setArtifactRepository(ArtifactRepositoryConstants.ALIEN_ARTIFACT_REPOSITORY);
        }
      }
    }
  }
}
Program: 62359
Project: 62359
Buggy source:
private boolean isTemplatePropertiesMatchCandidateFilters(NodeTemplate nodeTemplate,MatchingConfiguration matchingConfiguration,LocationResourceTemplate candidate,IndexedNodeType candidateType,Map<String,IndexedCapabilityType> capabilityTypes){
  if (!isTemplatePropertiesMatchCandidateFilter(nodeTemplate.getProperties(),matchingConfiguration.getProperties(),candidate.getTemplate().getProperties(),candidateType.getProperties())) {
    return false;
  }
  for (  Map.Entry<String,MatchingFilterDefinition> capabilityMatchingFilterEntry : matchingConfiguration.getCapabilities().entrySet()) {
    FilterDefinition filterDefinition=new FilterDefinition();
    Capability candidateCapability=candidate.getTemplate().getCapabilities().get(capabilityMatchingFilterEntry.getKey());
    IndexedCapabilityType capabilityType=capabilityTypes.get(candidateCapability.getType());
    Capability templateCapability=nodeTemplate.getCapabilities().get(capabilityMatchingFilterEntry.getKey());
    if (templateCapability != null && !isTemplatePropertiesMatchCandidateFilter(templateCapability.getProperties(),capabilityMatchingFilterEntry.getValue().getProperties(),candidateCapability.getProperties(),capabilityType.getProperties())) {
      return false;
    }
  }
  return true;
}

Fixed version (ground truth):
private boolean isTemplatePropertiesMatchCandidateFilters(NodeTemplate nodeTemplate,MatchingConfiguration matchingConfiguration,LocationResourceTemplate candidate,IndexedNodeType candidateType,Map<String,IndexedCapabilityType> capabilityTypes){
  if (!isTemplatePropertiesMatchCandidateFilter(nodeTemplate.getProperties(),matchingConfiguration.getProperties(),candidate.getTemplate().getProperties(),candidateType.getProperties())) {
    return false;
  }
  if (matchingConfiguration.getCapabilities() == null) {
    return true;
  }
  for (  Map.Entry<String,MatchingFilterDefinition> capabilityMatchingFilterEntry : matchingConfiguration.getCapabilities().entrySet()) {
    FilterDefinition filterDefinition=new FilterDefinition();
    Capability candidateCapability=candidate.getTemplate().getCapabilities().get(capabilityMatchingFilterEntry.getKey());
    IndexedCapabilityType capabilityType=capabilityTypes.get(candidateCapability.getType());
    Capability templateCapability=nodeTemplate.getCapabilities().get(capabilityMatchingFilterEntry.getKey());
    if (templateCapability != null && !isTemplatePropertiesMatchCandidateFilter(templateCapability.getProperties(),capabilityMatchingFilterEntry.getValue().getProperties(),candidateCapability.getProperties(),capabilityType.getProperties())) {
      return false;
    }
  }
  return true;
}
Program: 62360
Project: 62360
Buggy source:
/** 
 * Disable an orchestrator.
 * @param orchestrator The orchestrator to disable.
 * @param force If true the orchestrator is disabled even if some deployments are currently running.
 */
public synchronized List<Usage> disable(Orchestrator orchestrator,boolean force){
  if (!force) {
    QueryHelper.SearchQueryHelperBuilder searchQueryHelperBuilder=queryHelper.buildSearchQuery(alienDAO.getIndexForType(Deployment.class)).types(Deployment.class).filters(MapUtil.newHashMap(new String[]{"String_Node_Str","String_Node_Str"},new String[][]{new String[]{orchestrator.getId()},new String[]{null}})).fieldSort("String_Node_Str",true);
    GetMultipleDataResult<Object> result=alienDAO.search(searchQueryHelperBuilder,0,1);
    if (result.getData().length > 0) {
      List<Usage> usages=generateDeploymentUsages(result.getData());
      return usages;
    }
  }
  try {
    IOrchestratorPlugin orchestratorInstance=orchestratorPluginService.unregister(orchestrator.getId());
    if (orchestratorInstance != null) {
      IOrchestratorPluginFactory orchestratorFactory=orchestratorService.getPluginFactory(orchestrator);
      orchestratorFactory.destroy(orchestratorInstance);
    }
  }
 catch (  Exception e) {
    log.info("String_Node_Str",e);
  }
 finally {
    orchestrator.setState(OrchestratorState.DISABLED);
    alienDAO.save(orchestrator);
  }
  return null;
}

Fixed version (ground truth):
/** 
 * Disable an orchestrator.
 * @param orchestrator The orchestrator to disable.
 * @param force        If true the orchestrator is disabled even if some deployments are currently running.
 */
public synchronized List<Usage> disable(Orchestrator orchestrator,boolean force){
  if (!force) {
    QueryHelper.SearchQueryHelperBuilder searchQueryHelperBuilder=queryHelper.buildSearchQuery(alienDAO.getIndexForType(Deployment.class)).types(Deployment.class).filters(MapUtil.newHashMap(new String[]{"String_Node_Str","String_Node_Str"},new String[][]{new String[]{orchestrator.getId()},new String[]{null}})).fieldSort("String_Node_Str",true);
    GetMultipleDataResult<Object> result=alienDAO.search(searchQueryHelperBuilder,0,1);
    if (result.getData().length > 0) {
      List<Usage> usages=generateDeploymentUsages(result.getData());
      return usages;
    }
  }
  try {
    IOrchestratorPlugin orchestratorInstance=orchestratorPluginService.unregister(orchestrator.getId());
    if (orchestratorInstance != null) {
      IOrchestratorPluginFactory orchestratorFactory=orchestratorService.getPluginFactory(orchestrator);
      orchestratorFactory.destroy(orchestratorInstance);
    }
  }
 catch (  Exception e) {
    log.info("String_Node_Str",e);
  }
 finally {
    orchestrator.setState(OrchestratorState.DISABLED);
    alienDAO.save(orchestrator);
  }
  return null;
}
Program: 62361
Project: 62361
Buggy source:
@Override public void run(){
  try {
    load(orchestrator);
  }
 catch (  AlreadyExistException e) {
    log.info("String_Node_Str",orchestrator.getId());
  }
catch (  Throwable t) {
    log.error("String_Node_Str",t);
    orchestrator.setState(OrchestratorState.DISABLED);
    alienDAO.save(orchestrator);
  }
}

Fixed version (ground truth):
@Override public void run(){
  try {
    load(orchestrator);
  }
 catch (  AlreadyExistException e) {
    log.info("String_Node_Str",orchestrator.getId());
  }
catch (  Exception e) {
    log.error("String_Node_Str",e);
    orchestrator.setState(OrchestratorState.DISABLED);
    alienDAO.save(orchestrator);
  }
}
Program: 62365
Project: 62365
Buggy source:
/** 
 * Link the plugin against alien components that may need to use it.
 * @param plugin The plugin to link.
 * @param managedPlugin The managed plugin related to the plugin.
 * @param componentDescriptors The map of component descriptors.
 */
private void link(Plugin plugin,ManagedPlugin managedPlugin,Map<String,PluginComponentDescriptor> componentDescriptors){
  Map<String,IPluginLoadingCallback> beans=alienContext.getBeansOfType(IPluginLoadingCallback.class);
  for (  IPluginLoadingCallback callback : beans.values()) {
    callback.onPluginLoaded(managedPlugin);
  }
  for (  PluginLinker linker : linkers) {
    Map<String,?> instancesToLink=managedPlugin.getPluginContext().getBeansOfType(linker.linkedType);
    for (    Entry<String,?> instanceToLink : instancesToLink.entrySet()) {
      linker.linker.link(plugin.getId(),instanceToLink.getKey(),instanceToLink.getValue());
      PluginComponentDescriptor componentDescriptor=componentDescriptors.get(instanceToLink.getKey());
      if (componentDescriptor == null) {
        componentDescriptor=new PluginComponentDescriptor();
        componentDescriptor.setBeanName(instanceToLink.getKey());
        componentDescriptor.setName(instanceToLink.getKey());
      }
      componentDescriptor.setType(linker.linkedType.getSimpleName());
    }
  }
  for (  PluginComponentDescriptor componentDescriptor : componentDescriptors.values()) {
    if (componentDescriptor.getType() == null) {
      componentDescriptor.setType(UNKNOWN_PLUGIN_COMPONENT_TYPE);
    }
  }
}

Fixed version (ground truth):
/** 
 * Link the plugin against alien components that may need to use it.
 * @param plugin               The plugin to link.
 * @param managedPlugin        The managed plugin related to the plugin.
 * @param componentDescriptors The map of component descriptors.
 */
private void link(Plugin plugin,ManagedPlugin managedPlugin,Map<String,PluginComponentDescriptor> componentDescriptors){
  Map<String,IPluginLoadingCallback> beans=alienContext.getBeansOfType(IPluginLoadingCallback.class);
  for (  IPluginLoadingCallback callback : beans.values()) {
    callback.onPluginLoaded(managedPlugin);
  }
  for (  PluginLinker linker : linkers) {
    Map<String,?> instancesToLink=managedPlugin.getPluginContext().getBeansOfType(linker.linkedType);
    for (    Entry<String,?> instanceToLink : instancesToLink.entrySet()) {
      linker.linker.link(plugin.getId(),instanceToLink.getKey(),instanceToLink.getValue());
      PluginComponentDescriptor componentDescriptor=componentDescriptors.get(instanceToLink.getKey());
      if (componentDescriptor == null) {
        componentDescriptor=new PluginComponentDescriptor();
        componentDescriptor.setBeanName(instanceToLink.getKey());
        componentDescriptor.setName(instanceToLink.getKey());
      }
      componentDescriptor.setType(linker.linkedType.getSimpleName());
    }
  }
  for (  PluginComponentDescriptor componentDescriptor : componentDescriptors.values()) {
    if (componentDescriptor.getType() == null) {
      componentDescriptor.setType(UNKNOWN_PLUGIN_COMPONENT_TYPE);
    }
  }
}
Program: 62367
Project: 62367
Buggy source:
/** 
 * Initialize the list of exposed beans for the given plugin.
 * @param managedPlugin The plugin for which to configure exposed beans.
 * @param componentDescriptors The components descriptor of the plugin.
 */
private void expose(ManagedPlugin managedPlugin,Map<String,PluginComponentDescriptor> componentDescriptors){
  Map<String,Object> exposedBeans=Maps.newHashMap();
  for (  Entry<String,PluginComponentDescriptor> componentDescriptorEntry : componentDescriptors.entrySet()) {
    String beanName=componentDescriptorEntry.getValue().getBeanName();
    Object bean=managedPlugin.getPluginContext().getBean(beanName);
    if (bean == null) {
      log.warn("String_Node_Str" + beanName + "String_Node_Str");
    }
 else {
      exposedBeans.put(beanName,bean);
    }
  }
  managedPlugin.setExposedBeans(exposedBeans);
}

Fixed version (ground truth):
/** 
 * Initialize the list of exposed beans for the given plugin.
 * @param managedPlugin        The plugin for which to configure exposed beans.
 * @param componentDescriptors The components descriptor of the plugin.
 */
private void expose(ManagedPlugin managedPlugin,Map<String,PluginComponentDescriptor> componentDescriptors){
  Map<String,Object> exposedBeans=Maps.newHashMap();
  for (  Entry<String,PluginComponentDescriptor> componentDescriptorEntry : componentDescriptors.entrySet()) {
    String beanName=componentDescriptorEntry.getValue().getBeanName();
    Object bean=managedPlugin.getPluginContext().getBean(beanName);
    if (bean == null) {
      log.warn("String_Node_Str" + beanName + "String_Node_Str");
    }
 else {
      exposedBeans.put(beanName,bean);
    }
  }
  managedPlugin.setExposedBeans(exposedBeans);
}
Program: 62368
Project: 62368
Buggy source:
/** 
 * Delete all archives related to a location, if not exposed or used by another location
 * @param location
 * @return Map of usages per archives if found (that means the deletion wasn't performed successfully), null if everything went well.
 */
public Map<Csar,List<Usage>> deleteArchives(Location location){
  ILocationConfiguratorPlugin configuratorPlugin;
  try {
    IOrchestratorPlugin orchestratorInstance=(IOrchestratorPlugin)orchestratorPluginService.getOrFail(location.getOrchestratorId());
    configuratorPlugin=orchestratorInstance.getConfigurator(location.getInfrastructureType());
  }
 catch (  OrchestratorDisabledException e) {
    IOrchestratorPluginFactory orchestratorFactory=orchestratorService.getPluginFactory(orchestratorService.getOrFail(location.getOrchestratorId()));
    IOrchestratorPlugin orchestratorInstance=orchestratorFactory.newInstance();
    configuratorPlugin=orchestratorInstance.getConfigurator(location.getInfrastructureType());
  }
  List<PluginArchive> pluginArchives=configuratorPlugin.pluginArchives();
  if (CollectionUtils.isEmpty(pluginArchives)) {
    return null;
  }
  Set<String> allExposedArchivesIds=getAllExposedArchivesIdsExluding(location);
  Map<Csar,List<Usage>> usages=Maps.newHashMap();
  for (  PluginArchive pluginArchive : pluginArchives) {
    Csar csar=pluginArchive.getArchive().getArchive();
    if (!allExposedArchivesIds.contains(csar.getId())) {
      List<Usage> csarUsage=csarService.deleteCsarWithElements(csar);
      if (CollectionUtils.isNotEmpty(csarUsage)) {
        usages.put(csar,csarUsage);
      }
    }
  }
  return usages.isEmpty() ? null : usages;
}

Fixed version (ground truth):
/** 
 * Delete all archives related to a location, if not exposed or used by another location
 * @param location
 * @return Map of usages per archives if found (that means the deletion wasn't performed successfully), null if everything went well.
 */
public Map<Csar,List<Usage>> deleteArchives(Location location){
  ILocationConfiguratorPlugin configuratorPlugin=getConfiguratorPlugin(location);
  List<PluginArchive> pluginArchives=configuratorPlugin.pluginArchives();
  if (CollectionUtils.isEmpty(pluginArchives)) {
    return null;
  }
  Set<String> allExposedArchivesIds=getAllExposedArchivesIdsExluding(location);
  Map<Csar,List<Usage>> usages=Maps.newHashMap();
  for (  PluginArchive pluginArchive : pluginArchives) {
    Csar csar=pluginArchive.getArchive().getArchive();
    if (!allExposedArchivesIds.contains(csar.getId())) {
      List<Usage> csarUsage=csarService.deleteCsarWithElements(csar);
      if (CollectionUtils.isNotEmpty(csarUsage)) {
        usages.put(csar,csarUsage);
      }
    }
  }
  return usages.isEmpty() ? null : usages;
}
Program: 62369
Project: 62369
Buggy source:
private Set<String> getAllExposedArchivesIdsExluding(Location excludedLocation){
  QueryBuilder query=QueryBuilders.boolQuery().mustNot(QueryBuilders.idsQuery(Location.class.getSimpleName().toLowerCase()).ids(excludedLocation.getId()));
  List<Location> locations=alienDAO.customFindAll(Location.class,query);
  Set<String> archiveIds=Sets.newHashSet();
  if (locations != null) {
    for (    Location location : locations) {
      IOrchestratorPlugin orchestratorInstance=(IOrchestratorPlugin)orchestratorPluginService.getOrFail(location.getOrchestratorId());
      ILocationConfiguratorPlugin configuratorPlugin=orchestratorInstance.getConfigurator(location.getInfrastructureType());
      List<PluginArchive> pluginArchives=configuratorPlugin.pluginArchives();
      for (      PluginArchive pluginArchive : pluginArchives) {
        archiveIds.add(pluginArchive.getArchive().getArchive().getId());
      }
    }
  }
  return archiveIds;
}

Fixed version (ground truth):
private Set<String> getAllExposedArchivesIdsExluding(Location excludedLocation){
  QueryBuilder query=QueryBuilders.boolQuery().mustNot(QueryBuilders.idsQuery(Location.class.getSimpleName().toLowerCase()).ids(excludedLocation.getId()));
  List<Location> locations=alienDAO.customFindAll(Location.class,query);
  Set<String> archiveIds=Sets.newHashSet();
  if (locations != null) {
    for (    Location location : locations) {
      ILocationConfiguratorPlugin configuratorPlugin=getConfiguratorPlugin(location);
      List<PluginArchive> pluginArchives=configuratorPlugin.pluginArchives();
      for (      PluginArchive pluginArchive : pluginArchives) {
        archiveIds.add(pluginArchive.getArchive().getArchive().getId());
      }
    }
  }
  return archiveIds;
}