Program: 174775
Project: 174775
Buggy source:
@Override protected Map<String,Object> buildModel(WorkflowModelBuilder modelBuilder,WebScriptRequest req,Status status,Cache cache){
  Map<String,String> params=req.getServiceMatch().getTemplateVars();
  WorkflowState state=getState(req);
  Map<String,Object> filters=new HashMap<String,Object>(9);
  filters.put(PARAM_INITIATOR,req.getParameter(PARAM_INITIATOR));
  filters.put(PARAM_PRIORITY,req.getParameter(PARAM_PRIORITY));
  filters.put(PARAM_DEFINITION_NAME,req.getParameter(PARAM_DEFINITION_NAME));
  String excludeParam=req.getParameter(PARAM_EXCLUDE);
  if (excludeParam != null && excludeParam.length() > 0) {
    filters.put(PARAM_EXCLUDE,new ExcludeFilter(excludeParam));
  }
  processDateFilter(req,PARAM_DUE_BEFORE,filters);
  processDateFilter(req,PARAM_DUE_AFTER,filters);
  processDateFilter(req,PARAM_STARTED_BEFORE,filters);
  processDateFilter(req,PARAM_STARTED_AFTER,filters);
  processDateFilter(req,PARAM_COMPLETED_BEFORE,filters);
  processDateFilter(req,PARAM_COMPLETED_AFTER,filters);
  String workflowDefinitionId=params.get(VAR_DEFINITION_ID);
  if (workflowDefinitionId == null) {
    workflowDefinitionId=req.getParameter(PARAM_DEFINITION_ID);
  }
  if (state == null) {
    state=WorkflowState.ACTIVE;
  }
  List<WorkflowInstance> workflows=new ArrayList<WorkflowInstance>();
  if (workflowDefinitionId != null) {
    if (state == WorkflowState.ACTIVE) {
      workflows.addAll(workflowService.getActiveWorkflows(workflowDefinitionId));
    }
 else {
      workflows.addAll(workflowService.getCompletedWorkflows(workflowDefinitionId));
    }
  }
 else {
    List<WorkflowDefinition> workflowDefinitions=workflowService.getAllDefinitions();
    for (    WorkflowDefinition workflowDefinition : workflowDefinitions) {
      if (state == WorkflowState.ACTIVE) {
        workflows.addAll(workflowService.getActiveWorkflows(workflowDefinition.getId()));
      }
 else {
        workflows.addAll(workflowService.getCompletedWorkflows(workflowDefinition.getId()));
      }
    }
  }
  Collections.sort(workflows,workflowComparator);
  List<Map<String,Object>> results=new ArrayList<Map<String,Object>>(workflows.size());
  for (  WorkflowInstance workflow : workflows) {
    if (matches(workflow,filters,modelBuilder)) {
      results.add(modelBuilder.buildSimple(workflow));
    }
  }
  return createResultModel(req,"String_Node_Str",results);
}

Fixed version (ground truth):
@Override protected Map<String,Object> buildModel(WorkflowModelBuilder modelBuilder,WebScriptRequest req,Status status,Cache cache){
  Map<String,String> params=req.getServiceMatch().getTemplateVars();
  WorkflowState state=getState(req);
  Map<String,Object> filters=new HashMap<String,Object>(9);
  filters.put(PARAM_INITIATOR,req.getParameter(PARAM_INITIATOR));
  filters.put(PARAM_PRIORITY,req.getParameter(PARAM_PRIORITY));
  filters.put(PARAM_DEFINITION_NAME,req.getParameter(PARAM_DEFINITION_NAME));
  String excludeParam=req.getParameter(PARAM_EXCLUDE);
  if (excludeParam != null && excludeParam.length() > 0) {
    filters.put(PARAM_EXCLUDE,new ExcludeFilter(excludeParam));
  }
  processDateFilter(req,PARAM_DUE_BEFORE,filters);
  processDateFilter(req,PARAM_DUE_AFTER,filters);
  processDateFilter(req,PARAM_STARTED_BEFORE,filters);
  processDateFilter(req,PARAM_STARTED_AFTER,filters);
  processDateFilter(req,PARAM_COMPLETED_BEFORE,filters);
  processDateFilter(req,PARAM_COMPLETED_AFTER,filters);
  String workflowDefinitionId=params.get(VAR_DEFINITION_ID);
  if (workflowDefinitionId == null) {
    workflowDefinitionId=req.getParameter(PARAM_DEFINITION_ID);
  }
  List<WorkflowInstance> workflows;
  if (state == null) {
    workflows=workflowService.getWorkflows(workflowDefinitionId);
  }
 else   if (state == WorkflowState.ACTIVE) {
    workflows=workflowService.getActiveWorkflows(workflowDefinitionId);
  }
 else {
    workflows=workflowService.getCompletedWorkflows(workflowDefinitionId);
  }
  Collections.sort(workflows,workflowComparator);
  List<Map<String,Object>> results=new ArrayList<Map<String,Object>>(workflows.size());
  for (  WorkflowInstance workflow : workflows) {
    if (matches(workflow,filters,modelBuilder)) {
      results.add(modelBuilder.buildSimple(workflow));
    }
  }
  return createResultModel(req,"String_Node_Str",results);
}