Program: 50761
Project: 50761
Buggy source:
/** 
 * This method processes the supplied activity unit to create a set of trace nodes.
 * @param state The state
 * @param startau The activity unit being processed
 * @param topLevel The top level activity units
 */
protected static void processAU(CTState state,ActivityUnit startau,java.util.List<ActivityUnit> topLevel){
  ActivityType cur=null;
  Call call=(state.getCallStack().size() > 0 ? state.getCallStack().peek() : null);
  java.util.List<TraceNode> tasks=(state.getTasksStack().size() > 0 ? state.getTasksStack().peek() : null);
  ActivityType prev=null;
  if (LOG.isLoggable(Level.FINEST)) {
    LOG.finest("String_Node_Str" + startau);
  }
  java.util.List<ActivityUnit> aus=state.getActivityUnits();
  int aupos=aus.indexOf(startau);
  if (aupos == -1) {
    LOG.severe("String_Node_Str" + startau);
    return;
  }
  boolean f_end=false;
  boolean f_scopeFinalized=false;
  for (int i=aupos; !f_end && i < aus.size(); i++) {
    ActivityUnit au=aus.get(i);
    if (i != aupos && topLevel.contains(au)) {
      continue;
    }
    if (i != aupos && !processSubsequentAU(startau,au)) {
      if (LOG.isLoggable(Level.FINEST)) {
        LOG.finest("String_Node_Str" + au + "String_Node_Str"+ "String_Node_Str");
      }
      f_scopeFinalized=true;
      break;
    }
    if (LOG.isLoggable(Level.FINEST)) {
      LOG.finest("String_Node_Str" + aus.get(i));
    }
    ActivityUnitCursor cursor=state.getCursor(au);
    while ((cur=cursor.next()) != null) {
      if (LOG.isLoggable(Level.FINEST)) {
        LOG.finest("String_Node_Str" + cur);
      }
      if (shouldPostpone(state,au,topLevel,cur)) {
        break;
      }
      if (cur instanceof RPCActivityType) {
        if (cur instanceof RequestSent || (cur instanceof RequestReceived && call == null)) {
          call=createCall((RPCActivityType)cur);
          if (tasks != null) {
            tasks.add(call);
          }
 else           if (LOG.isLoggable(Level.FINE)) {
            LOG.fine("String_Node_Str");
          }
          tasks=call.getTasks();
          if (LOG.isLoggable(Level.FINEST)) {
            LOG.finest("String_Node_Str" + call);
            LOG.finest("String_Node_Str" + tasks);
          }
          state.getCallStack().push(call);
          state.getTasksStack().push(tasks);
          state.getTriggerActivities().put(call,(RPCActivityType)cur);
        }
        if (cur instanceof RequestSent) {
          instrumentCall(call,au,(RequestSent)cur);
          RPCActivityType rr=state.getSOAActivity(RequestReceived.class,((RequestSent)cur).getServiceType(),((RequestSent)cur).getOperation());
          if (rr != null) {
            call.setRequestLatency(rr.getTimestamp() - cur.getTimestamp());
            ActivityUnit subAU=state.getActivityUnit(rr.getUnitId());
            if (subAU != null) {
              processAU(state,subAU,topLevel);
              call=(state.getCallStack().size() > 0 ? state.getCallStack().peek() : null);
              tasks=(state.getTasksStack().size() > 0 ? state.getTasksStack().peek() : null);
            }
          }
        }
 else         if (cur instanceof RequestReceived) {
          instrumentCall(call,au,(RequestReceived)cur);
          call.setRequest(((RequestReceived)cur).getContent());
        }
 else         if (cur instanceof ResponseSent) {
          initializeResponseSent(state,(ResponseSent)cur,call);
          state.finalizeScope();
          f_scopeFinalized=true;
          call=(state.getCallStack().size() > 0 ? state.getCallStack().peek() : null);
          tasks=(state.getTasksStack().size() > 0 ? state.getTasksStack().peek() : null);
          if (state.getCallStack().size() > 0) {
            if (LOG.isLoggable(Level.FINEST)) {
              LOG.finest("String_Node_Str");
            }
            f_end=true;
            break;
          }
        }
 else         if (cur instanceof ResponseReceived) {
          initializeResponseReceived(state,(ResponseReceived)cur);
          f_end=true;
        }
      }
 else {
        Task task=createTask(cur);
        tasks.add(task);
        if (prev != null) {
          task.setDuration(cur.getTimestamp() - prev.getTimestamp());
        }
      }
      for (      Context con : cur.getContext()) {
        if (con.getType() == Context.Type.Link && !state.isLinkProcessed(con)) {
          state.linkProcessed(con);
          for (          ActivityUnit other : state.getActivityUnits(con)) {
            if (other != au) {
              if (LOG.isLoggable(Level.FINEST)) {
                LOG.finest("String_Node_Str" + other);
              }
              processAU(state,other,topLevel);
            }
          }
        }
      }
      prev=cur;
    }
  }
  if (!f_scopeFinalized) {
    state.finalizeScope();
  }
  if (LOG.isLoggable(Level.FINEST)) {
    LOG.finest("String_Node_Str" + startau);
  }
}

Fixed version (ground truth):
/** 
 * This method processes the supplied activity unit to create a set of trace nodes.
 * @param state The state
 * @param startau The activity unit being processed
 * @param topLevel The top level activity units
 */
protected static void processAU(CTState state,ActivityUnit startau,java.util.List<ActivityUnit> topLevel){
  ActivityType cur=null;
  Call call=(state.getCallStack().size() > 0 ? state.getCallStack().peek() : null);
  java.util.List<TraceNode> tasks=(state.getTasksStack().size() > 0 ? state.getTasksStack().peek() : null);
  ActivityType prev=null;
  if (LOG.isLoggable(Level.FINEST)) {
    LOG.finest("String_Node_Str" + startau);
  }
  java.util.List<ActivityUnit> aus=state.getActivityUnits();
  int aupos=aus.indexOf(startau);
  if (aupos == -1) {
    LOG.severe("String_Node_Str" + startau);
    return;
  }
  boolean f_end=false;
  boolean f_scopeFinalized=false;
  for (int i=aupos; !f_end && i < aus.size(); i++) {
    ActivityUnit au=aus.get(i);
    if (i != aupos) {
      if (topLevel.contains(au)) {
        continue;
      }
 else       if (!processSubsequentAU(startau,au)) {
        if (LOG.isLoggable(Level.FINEST)) {
          LOG.finest("String_Node_Str" + au + "String_Node_Str"+ "String_Node_Str");
        }
        f_scopeFinalized=true;
        break;
      }
    }
    if (LOG.isLoggable(Level.FINEST)) {
      LOG.finest("String_Node_Str" + aus.get(i));
    }
    ActivityUnitCursor cursor=state.getCursor(au);
    while ((cur=cursor.next()) != null) {
      if (LOG.isLoggable(Level.FINEST)) {
        LOG.finest("String_Node_Str" + cur);
      }
      if (shouldPostpone(state,au,topLevel,cur)) {
        break;
      }
      if (cur instanceof RPCActivityType) {
        if (cur instanceof RequestSent || (cur instanceof RequestReceived && call == null)) {
          call=createCall((RPCActivityType)cur);
          if (tasks != null) {
            tasks.add(call);
          }
 else           if (LOG.isLoggable(Level.FINE)) {
            LOG.fine("String_Node_Str");
          }
          tasks=call.getTasks();
          if (LOG.isLoggable(Level.FINEST)) {
            LOG.finest("String_Node_Str" + call);
            LOG.finest("String_Node_Str" + tasks);
          }
          state.getCallStack().push(call);
          state.getTasksStack().push(tasks);
          state.getTriggerActivities().put(call,(RPCActivityType)cur);
        }
        if (cur instanceof RequestSent) {
          instrumentCall(call,au,(RequestSent)cur);
          RPCActivityType rr=state.getSOAActivity(RequestReceived.class,((RequestSent)cur).getServiceType(),((RequestSent)cur).getOperation());
          if (rr != null) {
            call.setRequestLatency(rr.getTimestamp() - cur.getTimestamp());
            ActivityUnit subAU=state.getActivityUnit(rr.getUnitId());
            if (subAU != null) {
              processAU(state,subAU,topLevel);
              call=(state.getCallStack().size() > 0 ? state.getCallStack().peek() : null);
              tasks=(state.getTasksStack().size() > 0 ? state.getTasksStack().peek() : null);
            }
          }
        }
 else         if (cur instanceof RequestReceived) {
          instrumentCall(call,au,(RequestReceived)cur);
          call.setRequest(((RequestReceived)cur).getContent());
        }
 else         if (cur instanceof ResponseSent) {
          initializeResponseSent(state,(ResponseSent)cur,call);
          state.finalizeScope();
          f_scopeFinalized=true;
          call=(state.getCallStack().size() > 0 ? state.getCallStack().peek() : null);
          tasks=(state.getTasksStack().size() > 0 ? state.getTasksStack().peek() : null);
          if (state.getCallStack().size() > 0) {
            if (LOG.isLoggable(Level.FINEST)) {
              LOG.finest("String_Node_Str");
            }
            f_end=true;
            break;
          }
        }
 else         if (cur instanceof ResponseReceived) {
          initializeResponseReceived(state,(ResponseReceived)cur);
          f_end=true;
        }
      }
 else {
        Task task=createTask(cur);
        tasks.add(task);
        if (prev != null) {
          task.setDuration(cur.getTimestamp() - prev.getTimestamp());
        }
      }
      checkForLinkedAU(cur,state,au,topLevel);
      prev=cur;
    }
  }
  if (!f_scopeFinalized) {
    state.finalizeScope();
  }
  if (LOG.isLoggable(Level.FINEST)) {
    LOG.finest("String_Node_Str" + startau);
  }
}