Program: 52249
Project: 52249
Buggy source:
/** 
 * Create a list of all activity.
 */
private void addActivity(Division div) throws WingException, SQLException {
  Request request=ObjectModelHelper.getRequest(objectModel);
  String showSelf=request.getParameter("String_Node_Str");
  if (showSelf == null || !showSelf.equals("String_Node_Str"))   showSelf="String_Node_Str";
  EventSort sortBy=EventSort.TIME;
  String sortByString=request.getParameter("String_Node_Str");
  if (EventSort.TIME.toString().equals(sortByString))   sortBy=EventSort.TIME;
  if (EventSort.URL.toString().equals(sortByString))   sortBy=EventSort.URL;
  if (EventSort.SESSION.toString().equals(sortByString))   sortBy=EventSort.SESSION;
  if (EventSort.AGENT.toString().equals(sortByString))   sortBy=EventSort.AGENT;
  if (EventSort.IP.toString().equals(sortByString))   sortBy=EventSort.IP;
  java.util.List<CurrentActivityAction.Event> events=CurrentActivityAction.getEvents();
  Collections.sort(events,new ActivitySort<CurrentActivityAction.Event>(sortBy));
  Collections.reverse(events);
  if (showSelf.equals("String_Node_Str"))   div.addPara().addXref("String_Node_Str" + sortBy + "String_Node_Str").addContent(T_activity_hideself);
 else   div.addPara().addXref("String_Node_Str" + sortBy + "String_Node_Str").addContent(T_activity_showself);
  Table activeUsers=div.addTable("String_Node_Str",1,1);
  activeUsers.setHead(T_activity_head);
  Row row=activeUsers.addRow(Row.ROLE_HEADER);
  if (sortBy == EventSort.TIME)   row.addCell().addHighlight("String_Node_Str").addXref("String_Node_Str" + EventSort.TIME + "String_Node_Str"+ showSelf).addContent(T_activity_sort_time);
 else   row.addCell().addXref("String_Node_Str" + EventSort.TIME + "String_Node_Str"+ showSelf).addContent(T_activity_sort_time);
  if (sortBy == EventSort.SESSION)   row.addCell().addHighlight("String_Node_Str").addXref("String_Node_Str" + EventSort.SESSION + "String_Node_Str"+ showSelf).addContent(T_activity_sort_user);
 else   row.addCell().addXref("String_Node_Str" + EventSort.SESSION + "String_Node_Str"+ showSelf).addContent(T_activity_sort_user);
  if (sortBy == EventSort.IP)   row.addCell().addHighlight("String_Node_Str").addXref("String_Node_Str" + EventSort.IP + "String_Node_Str"+ showSelf).addContent(T_activity_sort_ip);
 else   row.addCell().addXref("String_Node_Str" + EventSort.IP + "String_Node_Str"+ showSelf).addContent(T_activity_sort_ip);
  if (sortBy == EventSort.URL)   row.addCell().addHighlight("String_Node_Str").addXref("String_Node_Str" + EventSort.URL + "String_Node_Str"+ showSelf).addContent(T_activity_sort_url);
 else   row.addCell().addXref("String_Node_Str" + EventSort.URL + "String_Node_Str"+ showSelf).addContent(T_activity_sort_url);
  if (sortBy == EventSort.AGENT)   row.addCell().addHighlight("String_Node_Str").addXref("String_Node_Str" + EventSort.AGENT + "String_Node_Str"+ showSelf).addContent(T_activity_sort_agent);
 else   row.addCell().addXref("String_Node_Str" + EventSort.AGENT + "String_Node_Str"+ showSelf).addContent(T_activity_sort_agent);
  HashMap<String,Integer> anonymousHash=new HashMap<String,Integer>();
  int anonymousCount=1;
  int shown=0;
  for (  CurrentActivityAction.Event event : events) {
    if (showSelf.equals("String_Node_Str") && event.getEPersonID() == context.getCurrentUser().getID())     continue;
    shown++;
    Message timeStampMessage=null;
    long ago=System.currentTimeMillis() - event.getTimeStamp();
    if (ago > 2 * 60 * 60* 1000)     timeStampMessage=T_hours.parameterize((ago / (60 * 60 * 1000)));
 else     if (ago > 60 * 1000)     timeStampMessage=T_minutes.parameterize((ago / (60 * 1000)));
 else     timeStampMessage=T_seconds.parameterize((ago / (1000)));
    Row eventRow=activeUsers.addRow();
    eventRow.addCellContent(timeStampMessage);
    int eid=event.getEPersonID();
    EPerson eperson=EPerson.find(context,eid);
    if (eperson != null) {
      String name=eperson.getFullName();
      eventRow.addCellContent(name);
    }
 else {
      if (!anonymousHash.containsKey(event.getSessionID()))       anonymousHash.put(event.getSessionID(),anonymousCount++);
      eventRow.addCellContent(T_activity_anonymous.parameterize(anonymousHash.get(event.getSessionID())));
    }
    eventRow.addCellContent(event.getIP());
    eventRow.addCell().addXref(contextPath + "String_Node_Str" + event.getURL()).addContent("String_Node_Str" + event.getURL());
    eventRow.addCellContent(event.getDectectedBrowser());
  }
  if (shown == 0) {
    activeUsers.addRow().addCell(1,5).addContent(T_activity_none.parameterize(CurrentActivityAction.MAX_EVENTS));
  }
}

Fixed version (ground truth):
/** 
 * Create a list of all activity.
 */
private void addActivity(Division div) throws WingException, SQLException {
  Request request=ObjectModelHelper.getRequest(objectModel);
  String showSelf=request.getParameter("String_Node_Str");
  if (showSelf == null || !showSelf.equals("String_Node_Str"))   showSelf="String_Node_Str";
  EventSort sortBy=EventSort.TIME;
  String sortByString=request.getParameter("String_Node_Str");
  if (EventSort.TIME.toString().equals(sortByString))   sortBy=EventSort.TIME;
  if (EventSort.URL.toString().equals(sortByString))   sortBy=EventSort.URL;
  if (EventSort.SESSION.toString().equals(sortByString))   sortBy=EventSort.SESSION;
  if (EventSort.AGENT.toString().equals(sortByString))   sortBy=EventSort.AGENT;
  if (EventSort.IP.toString().equals(sortByString))   sortBy=EventSort.IP;
  java.util.List<CurrentActivityAction.Event> events=CurrentActivityAction.getEvents();
  Collections.sort(events,new ActivitySort<CurrentActivityAction.Event>(sortBy));
  Collections.reverse(events);
  if (showSelf.equals("String_Node_Str"))   div.addPara().addXref("String_Node_Str" + sortBy + "String_Node_Str").addContent(T_activity_hideself);
 else   div.addPara().addXref("String_Node_Str" + sortBy + "String_Node_Str").addContent(T_activity_showself);
  Table activeUsers=div.addTable("String_Node_Str",1,1);
  activeUsers.setHead(T_activity_head.parameterize(CurrentActivityAction.MAX_EVENTS));
  Row row=activeUsers.addRow(Row.ROLE_HEADER);
  if (sortBy == EventSort.TIME)   row.addCell().addHighlight("String_Node_Str").addXref("String_Node_Str" + EventSort.TIME + "String_Node_Str"+ showSelf).addContent(T_activity_sort_time);
 else   row.addCell().addXref("String_Node_Str" + EventSort.TIME + "String_Node_Str"+ showSelf).addContent(T_activity_sort_time);
  if (sortBy == EventSort.SESSION)   row.addCell().addHighlight("String_Node_Str").addXref("String_Node_Str" + EventSort.SESSION + "String_Node_Str"+ showSelf).addContent(T_activity_sort_user);
 else   row.addCell().addXref("String_Node_Str" + EventSort.SESSION + "String_Node_Str"+ showSelf).addContent(T_activity_sort_user);
  if (sortBy == EventSort.IP)   row.addCell().addHighlight("String_Node_Str").addXref("String_Node_Str" + EventSort.IP + "String_Node_Str"+ showSelf).addContent(T_activity_sort_ip);
 else   row.addCell().addXref("String_Node_Str" + EventSort.IP + "String_Node_Str"+ showSelf).addContent(T_activity_sort_ip);
  if (sortBy == EventSort.URL)   row.addCell().addHighlight("String_Node_Str").addXref("String_Node_Str" + EventSort.URL + "String_Node_Str"+ showSelf).addContent(T_activity_sort_url);
 else   row.addCell().addXref("String_Node_Str" + EventSort.URL + "String_Node_Str"+ showSelf).addContent(T_activity_sort_url);
  if (sortBy == EventSort.AGENT)   row.addCell().addHighlight("String_Node_Str").addXref("String_Node_Str" + EventSort.AGENT + "String_Node_Str"+ showSelf).addContent(T_activity_sort_agent);
 else   row.addCell().addXref("String_Node_Str" + EventSort.AGENT + "String_Node_Str"+ showSelf).addContent(T_activity_sort_agent);
  HashMap<String,Integer> anonymousHash=new HashMap<String,Integer>();
  int anonymousCount=1;
  int shown=0;
  for (  CurrentActivityAction.Event event : events) {
    if (event == null)     continue;
    if (showSelf.equals("String_Node_Str") && event.getEPersonID() == context.getCurrentUser().getID())     continue;
    shown++;
    Message timeStampMessage=null;
    long ago=System.currentTimeMillis() - event.getTimeStamp();
    if (ago > 2 * 60 * 60* 1000)     timeStampMessage=T_hours.parameterize((ago / (60 * 60 * 1000)));
 else     if (ago > 60 * 1000)     timeStampMessage=T_minutes.parameterize((ago / (60 * 1000)));
 else     timeStampMessage=T_seconds.parameterize((ago / (1000)));
    Row eventRow=activeUsers.addRow();
    eventRow.addCellContent(timeStampMessage);
    int eid=event.getEPersonID();
    EPerson eperson=EPerson.find(context,eid);
    if (eperson != null) {
      String name=eperson.getFullName();
      eventRow.addCellContent(name);
    }
 else {
      if (!anonymousHash.containsKey(event.getSessionID()))       anonymousHash.put(event.getSessionID(),anonymousCount++);
      eventRow.addCellContent(T_activity_anonymous.parameterize(anonymousHash.get(event.getSessionID())));
    }
    eventRow.addCellContent(event.getIP());
    eventRow.addCell().addXref(contextPath + "String_Node_Str" + event.getURL()).addContent("String_Node_Str" + event.getURL());
    eventRow.addCellContent(event.getDectectedBrowser());
  }
  if (shown == 0) {
    activeUsers.addRow().addCell(1,5).addContent(T_activity_none.parameterize(CurrentActivityAction.MAX_EVENTS));
  }
}