Program: 15160
Project: 15160
Buggy source:
public boolean loadComments(boolean refresh,boolean loadMore){
  refreshOnly=refresh;
  String author, postID, comment, dateCreatedFormatted, status, authorEmail, authorURL, postTitle;
  int commentID;
  List<Map<String,Object>> loadedPosts=WordPress.wpDB.loadComments(WordPress.currentBlog.getId());
  if (loadedPosts != null) {
    numRecords=loadedPosts.size();
    if (refreshOnly) {
      if (model != null) {
        model.clear();
      }
    }
 else {
      model=new ArrayList<Comment>();
    }
    checkedComments=new Vector<String>();
    for (int i=0; i < loadedPosts.size(); i++) {
      checkedComments.add(i,"String_Node_Str");
      Map<String,Object> contentHash=loadedPosts.get(i);
      allComments.put((Integer)contentHash.get("String_Node_Str"),contentHash);
      author=EscapeUtils.unescapeHtml(contentHash.get("String_Node_Str").toString());
      commentID=(Integer)contentHash.get("String_Node_Str");
      postID=contentHash.get("String_Node_Str").toString();
      comment=EscapeUtils.unescapeHtml(contentHash.get("String_Node_Str").toString());
      dateCreatedFormatted=contentHash.get("String_Node_Str").toString();
      status=contentHash.get("String_Node_Str").toString();
      authorEmail=EscapeUtils.unescapeHtml(contentHash.get("String_Node_Str").toString());
      authorURL=EscapeUtils.unescapeHtml(contentHash.get("String_Node_Str").toString());
      postTitle=EscapeUtils.unescapeHtml(contentHash.get("String_Node_Str").toString());
      if (model == null) {
        model=new ArrayList<Comment>();
      }
      model.add(new Comment(postID,commentID,i,author,dateCreatedFormatted,comment,status,postTitle,authorURL,authorEmail,URI.create("String_Node_Str" + StringUtils.getMd5Hash(authorEmail.trim()) + "String_Node_Str")));
    }
    if (!refreshOnly) {
      ListView listView=this.getListView();
      listView.removeFooterView(switcher);
      if (loadedPosts.size() % 30 == 0) {
        listView.addFooterView(switcher);
      }
      setListAdapter(new CommentAdapter());
      listView.setOnItemClickListener(new OnItemClickListener(){
        public void onItemClick(        AdapterView<?> arg0,        View view,        int position,        long id){
          selectedPosition=position;
          Comment comment=model.get((int)id);
          onCommentSelectedListener.onCommentSelected(comment);
          getListView().invalidateViews();
        }
      }
);
      listView.setOnCreateContextMenuListener(new OnCreateContextMenuListener(){
        public void onCreateContextMenu(        ContextMenu menu,        View v,        ContextMenuInfo menuInfo){
          AdapterView.AdapterContextMenuInfo info;
          try {
            info=(AdapterView.AdapterContextMenuInfo)menuInfo;
          }
 catch (          ClassCastException e) {
            return;
          }
          WordPress.currentComment=model.get(info.position);
          menu.setHeaderTitle(getResources().getText(R.string.comment_actions));
          menu.add(0,0,0,getResources().getText(R.string.mark_approved));
          menu.add(0,1,0,getResources().getText(R.string.mark_unapproved));
          menu.add(0,2,0,getResources().getText(R.string.mark_spam));
          menu.add(0,3,0,getResources().getText(R.string.reply));
          menu.add(0,4,0,getResources().getText(R.string.delete));
          menu.add(0,5,0,getResources().getText(R.string.edit));
        }
      }
);
    }
 else {
      getListView().invalidateViews();
    }
    if (this.shouldSelectAfterLoad) {
      if (model != null) {
        if (model.size() > 0) {
          selectedPosition=0;
          Comment aComment=model.get((int)0);
          onCommentSelectedListener.onCommentSelected(aComment);
          getListView().setItemChecked(0,true);
        }
      }
      shouldSelectAfterLoad=false;
    }
    if (loadMore && scrollPosition > 0) {
      ListView listView=this.getListView();
      try {
        listView.setSelectionFromTop(scrollPosition,scrollPositionTop);
      }
 catch (      Exception e) {
        e.printStackTrace();
      }
    }
    return true;
  }
 else {
    return false;
  }
}

Fixed version (ground truth):
public boolean loadComments(boolean refresh,boolean loadMore){
  refreshOnly=refresh;
  String author, postID, comment, dateCreatedFormatted, status, authorEmail, authorURL, postTitle;
  int commentID;
  List<Map<String,Object>> loadedComments=WordPress.wpDB.loadComments(WordPress.currentBlog.getId());
  if (loadedComments != null) {
    numRecords=loadedComments.size();
    if (refreshOnly) {
      if (model != null) {
        model.clear();
      }
    }
 else {
      model=new ArrayList<Comment>();
    }
    checkedComments=new Vector<String>();
    for (int i=0; i < loadedComments.size(); i++) {
      checkedComments.add(i,"String_Node_Str");
      Map<String,Object> contentHash=loadedComments.get(i);
      allComments.put((Integer)contentHash.get("String_Node_Str"),contentHash);
      author=EscapeUtils.unescapeHtml(contentHash.get("String_Node_Str").toString());
      commentID=(Integer)contentHash.get("String_Node_Str");
      postID=contentHash.get("String_Node_Str").toString();
      comment=EscapeUtils.unescapeHtml(contentHash.get("String_Node_Str").toString());
      dateCreatedFormatted=contentHash.get("String_Node_Str").toString();
      status=contentHash.get("String_Node_Str").toString();
      authorEmail=EscapeUtils.unescapeHtml(contentHash.get("String_Node_Str").toString());
      authorURL=EscapeUtils.unescapeHtml(contentHash.get("String_Node_Str").toString());
      postTitle=EscapeUtils.unescapeHtml(contentHash.get("String_Node_Str").toString());
      if (model == null) {
        model=new ArrayList<Comment>();
      }
      model.add(new Comment(postID,commentID,i,author,dateCreatedFormatted,comment,status,postTitle,authorURL,authorEmail,URI.create("String_Node_Str" + StringUtils.getMd5Hash(authorEmail.trim()) + "String_Node_Str")));
    }
    if (!refreshOnly) {
      ListView listView=this.getListView();
      listView.removeFooterView(switcher);
      if (loadedComments.size() % 30 == 0) {
        listView.addFooterView(switcher);
      }
      setListAdapter(new CommentAdapter());
      listView.setOnItemClickListener(new OnItemClickListener(){
        public void onItemClick(        AdapterView<?> arg0,        View view,        int position,        long id){
          selectedPosition=position;
          Comment comment=model.get((int)id);
          onCommentSelectedListener.onCommentSelected(comment);
          getListView().invalidateViews();
        }
      }
);
      listView.setOnCreateContextMenuListener(new OnCreateContextMenuListener(){
        public void onCreateContextMenu(        ContextMenu menu,        View v,        ContextMenuInfo menuInfo){
          AdapterView.AdapterContextMenuInfo info;
          try {
            info=(AdapterView.AdapterContextMenuInfo)menuInfo;
          }
 catch (          ClassCastException e) {
            return;
          }
          WordPress.currentComment=model.get(info.position);
          menu.setHeaderTitle(getResources().getText(R.string.comment_actions));
          menu.add(0,0,0,getResources().getText(R.string.mark_approved));
          menu.add(0,1,0,getResources().getText(R.string.mark_unapproved));
          menu.add(0,2,0,getResources().getText(R.string.mark_spam));
          menu.add(0,3,0,getResources().getText(R.string.reply));
          menu.add(0,4,0,getResources().getText(R.string.delete));
          menu.add(0,5,0,getResources().getText(R.string.edit));
        }
      }
);
    }
 else {
      getListView().invalidateViews();
    }
    if (this.shouldSelectAfterLoad) {
      if (model != null) {
        if (model.size() > 0) {
          selectedPosition=0;
          Comment aComment=model.get((int)0);
          onCommentSelectedListener.onCommentSelected(aComment);
          getListView().setItemChecked(0,true);
        }
      }
      shouldSelectAfterLoad=false;
    }
    if (loadMore && scrollPosition > 0) {
      ListView listView=this.getListView();
      try {
        listView.setSelectionFromTop(scrollPosition,scrollPositionTop);
      }
 catch (      Exception e) {
        e.printStackTrace();
      }
    }
    return true;
  }
 else {
    return false;
  }
}