Program: 5167
Project: 5167
Buggy source:
/** 
 * Get all applications in the specified namespace that satisfy the specified predicate.
 * @param namespace the namespace to get apps from
 * @param predicate the predicate that must be satisfied in order to be returned
 * @return list of all applications in the namespace that satisfy the specified predicate
 */
public List<ApplicationRecord> getApps(final NamespaceId namespace,com.google.common.base.Predicate<ApplicationRecord> predicate) throws Exception {
  List<ApplicationRecord> appRecords=new ArrayList<>();
  Set<ApplicationId> appIds=new HashSet<>();
  for (  ApplicationSpecification appSpec : store.getAllApplications(namespace)) {
    appIds.add(namespace.app(appSpec.getName(),appSpec.getAppVersion()));
  }
  for (  ApplicationId appId : appIds) {
    ApplicationSpecification appSpec=store.getApplication(appId);
    if (appSpec == null) {
      continue;
    }
    ArtifactId artifactId=appSpec.getArtifactId();
    ArtifactSummary artifactSummary=artifactId == null ? new ArtifactSummary(appSpec.getName(),null) : ArtifactSummary.from(artifactId);
    ApplicationRecord record=new ApplicationRecord(artifactSummary,appId,appSpec.getDescription(),ownerAdmin.getImpersonationPrincipal(appId));
    if (predicate.apply(record)) {
      appRecords.add(record);
    }
  }
  Principal principal=authenticationContext.getPrincipal();
  final Predicate<EntityId> filter=authorizationEnforcer.createFilter(principal);
  return Lists.newArrayList(Iterables.filter(appRecords,new com.google.common.base.Predicate<ApplicationRecord>(){
    @Override public boolean apply(    ApplicationRecord appRecord){
      return filter.apply(namespace.app(appRecord.getName()));
    }
  }
));
}

Fixed version (ground truth):
/** 
 * Get all applications in the specified namespace that satisfy the specified predicate.
 * @param namespace the namespace to get apps from
 * @param predicate the predicate that must be satisfied in order to be returned
 * @return list of all applications in the namespace that satisfy the specified predicate
 */
public List<ApplicationRecord> getApps(final NamespaceId namespace,com.google.common.base.Predicate<ApplicationRecord> predicate) throws Exception {
  List<ApplicationRecord> appRecords=new ArrayList<>();
  Set<ApplicationId> appIds=new HashSet<>();
  for (  ApplicationSpecification appSpec : store.getAllApplications(namespace)) {
    appIds.add(namespace.app(appSpec.getName(),appSpec.getAppVersion()));
  }
  for (  ApplicationId appId : appIds) {
    ApplicationSpecification appSpec=store.getApplication(appId);
    if (appSpec == null) {
      continue;
    }
    ArtifactId artifactId=appSpec.getArtifactId();
    ArtifactSummary artifactSummary=artifactId == null ? new ArtifactSummary(appSpec.getName(),null) : ArtifactSummary.from(artifactId);
    ApplicationRecord record=new ApplicationRecord(artifactSummary,appId,appSpec.getDescription(),ownerAdmin.getOwnerPrincipal(appId));
    if (predicate.apply(record)) {
      appRecords.add(record);
    }
  }
  Principal principal=authenticationContext.getPrincipal();
  final Predicate<EntityId> filter=authorizationEnforcer.createFilter(principal);
  return Lists.newArrayList(Iterables.filter(appRecords,new com.google.common.base.Predicate<ApplicationRecord>(){
    @Override public boolean apply(    ApplicationRecord appRecord){
      return filter.apply(namespace.app(appRecord.getName()));
    }
  }
));
}