Program: 6527
Project: 6527
Buggy source:
@Override public void process(ApplicationDeployable appSpec) throws Exception {
  List<ProgramSpecification> deletedSpecs=store.getDeletedProgramSpecifications(appSpec.getId(),appSpec.getSpecification());
  List<String> deletedFlows=Lists.newArrayList();
  for (  ProgramSpecification spec : deletedSpecs) {
    ProgramType type=ProgramTypes.fromSpecification(spec);
    Id.Program programId=Id.Program.from(appSpec.getId(),type,spec.getName());
    programTerminator.stop(programId);
    if (ProgramType.FLOW.equals(type)) {
      FlowSpecification flowSpecification=(FlowSpecification)spec;
      Multimap<String,Long> streamGroups=HashMultimap.create();
      for (      FlowletConnection connection : flowSpecification.getConnections()) {
        if (connection.getSourceType() == FlowletConnection.Type.STREAM) {
          long groupId=FlowUtils.generateConsumerGroupId(programId,connection.getTargetName());
          streamGroups.put(connection.getSourceName(),groupId);
        }
      }
      String namespace=String.format("String_Node_Str",programId.getApplicationId(),programId.getId());
      for (      Map.Entry<String,Collection<Long>> entry : streamGroups.asMap().entrySet()) {
        streamConsumerFactory.dropAll(Id.Stream.from(appSpec.getId().getNamespaceId(),entry.getKey()),namespace,entry.getValue());
      }
      queueAdmin.dropAllForFlow(Id.Flow.from(programId.getApplication(),programId.getId()));
      deletedFlows.add(programId.getId());
    }
  }
  if (!deletedFlows.isEmpty()) {
    deleteMetrics(appSpec.getId().getNamespaceId(),appSpec.getId().getId(),deletedFlows);
  }
  emit(appSpec);
}

Fixed version (ground truth):
@Override public void process(ApplicationDeployable appSpec) throws Exception {
  List<ProgramSpecification> deletedSpecs=store.getDeletedProgramSpecifications(appSpec.getId(),appSpec.getSpecification());
  List<String> deletedFlows=Lists.newArrayList();
  for (  ProgramSpecification spec : deletedSpecs) {
    ProgramType type=ProgramTypes.fromSpecification(spec);
    Id.Program programId=Id.Program.from(appSpec.getId(),type,spec.getName());
    programTerminator.stop(programId);
    if (ProgramType.FLOW.equals(type)) {
      FlowSpecification flowSpecification=(FlowSpecification)spec;
      Multimap<String,Long> streamGroups=HashMultimap.create();
      for (      FlowletConnection connection : flowSpecification.getConnections()) {
        if (connection.getSourceType() == FlowletConnection.Type.STREAM) {
          long groupId=FlowUtils.generateConsumerGroupId(programId,connection.getTargetName());
          streamGroups.put(connection.getSourceName(),groupId);
        }
      }
      String namespace=String.format("String_Node_Str",programId.getApplicationId(),programId.getId());
      for (      Map.Entry<String,Collection<Long>> entry : streamGroups.asMap().entrySet()) {
        streamConsumerFactory.dropAll(Id.Stream.from(appSpec.getId().getNamespaceId(),entry.getKey()),namespace,entry.getValue());
      }
      queueAdmin.dropAllForFlow(Id.Flow.from(programId.getApplication(),programId.getId()));
      deletedFlows.add(programId.getId());
    }
    businessMetadataStore.removeMetadata(programId);
  }
  if (!deletedFlows.isEmpty()) {
    deleteMetrics(appSpec.getId().getNamespaceId(),appSpec.getId().getId(),deletedFlows);
  }
  emit(appSpec);
}