Program: 13403
Project: 13403
Buggy source:
private static void handleUpdatePostsResponse(final ReaderTag tag,final JSONObject jsonObject,final UpdateAction updateAction,final ReaderActions.UpdateResultListener resultListener){
  if (jsonObject == null) {
    resultListener.onUpdateResult(ReaderActions.UpdateResult.FAILED);
    return;
  }
  new Thread(){
    @Override public void run(){
      ReaderPostList serverPosts=ReaderPostList.fromJson(jsonObject);
      ReaderActions.UpdateResult updateResult=ReaderPostTable.comparePosts(serverPosts);
      if (updateResult.isNewOrChanged()) {
        ReaderPost postWithGap=null;
        if (tag != null) {
switch (updateAction) {
case REQUEST_NEWER:
            int numServerPosts=serverPosts.size();
          if (numServerPosts >= 2 && ReaderPostTable.getNumPostsWithTag(tag) > 0 && !ReaderPostTable.hasOverlap(serverPosts)) {
            postWithGap=serverPosts.get(numServerPosts - 2);
            serverPosts.remove(numServerPosts - 1);
            AppLog.d(AppLog.T.READER,"String_Node_Str" + tag.getTagNameForLog());
          }
        ReaderPostTable.removeGapMarkerForTag(tag);
      break;
case REQUEST_OLDER_THAN_GAP:
    ReaderPostTable.deletePostsBeforeGapMarkerForTag(tag);
  ReaderPostTable.removeGapMarkerForTag(tag);
break;
}
}
ReaderPostTable.addOrUpdatePosts(tag,serverPosts);
if (postWithGap != null) {
ReaderPostTable.setGapMarkerForTag(postWithGap.blogId,postWithGap.postId,tag);
}
}
 else if (updateResult == ReaderActions.UpdateResult.UNCHANGED && updateAction == UpdateAction.REQUEST_OLDER_THAN_GAP) {
ReaderPostTable.removeGapMarkerForTag(tag);
AppLog.w(AppLog.T.READER,"String_Node_Str");
}
AppLog.d(AppLog.T.READER,"String_Node_Str" + updateResult.toString());
resultListener.onUpdateResult(updateResult);
}
}
.start();
}

Fixed version (ground truth):
private static void handleUpdatePostsResponse(final ReaderTag tag,final JSONObject jsonObject,final UpdateAction updateAction,final ReaderActions.UpdateResultListener resultListener){
  if (jsonObject == null) {
    resultListener.onUpdateResult(ReaderActions.UpdateResult.FAILED);
    return;
  }
  new Thread(){
    @Override public void run(){
      ReaderPostList serverPosts=ReaderPostList.fromJson(jsonObject);
      ReaderActions.UpdateResult updateResult=ReaderPostTable.comparePosts(serverPosts);
      if (updateResult.isNewOrChanged()) {
        ReaderPost postWithGap=null;
        if (tag != null) {
switch (updateAction) {
case REQUEST_NEWER:
            int numServerPosts=serverPosts.size();
          if (numServerPosts >= 2 && ReaderPostTable.getNumPostsWithTag(tag) > 0 && !ReaderPostTable.hasOverlap(serverPosts)) {
            postWithGap=serverPosts.get(numServerPosts - 2);
            serverPosts.remove(numServerPosts - 1);
            ReaderBlogIdPostId gapMarker=ReaderPostTable.getGapMarkerIdsForTag(tag);
            if (gapMarker != null) {
              ReaderPostTable.deletePostsBeforeGapMarkerForTag(tag);
              ReaderPostTable.removeGapMarkerForTag(tag);
            }
          }
        break;
case REQUEST_OLDER_THAN_GAP:
      ReaderPostTable.deletePostsBeforeGapMarkerForTag(tag);
    ReaderPostTable.removeGapMarkerForTag(tag);
  break;
case REQUEST_OLDER:
break;
}
}
ReaderPostTable.addOrUpdatePosts(tag,serverPosts);
if (postWithGap != null) {
ReaderPostTable.setGapMarkerForTag(postWithGap.blogId,postWithGap.postId,tag);
AppLog.d(AppLog.T.READER,"String_Node_Str" + tag.getTagNameForLog());
}
}
 else if (updateResult == ReaderActions.UpdateResult.UNCHANGED && updateAction == UpdateAction.REQUEST_OLDER_THAN_GAP) {
ReaderPostTable.removeGapMarkerForTag(tag);
AppLog.w(AppLog.T.READER,"String_Node_Str");
}
AppLog.d(AppLog.T.READER,"String_Node_Str" + updateResult.toString());
resultListener.onUpdateResult(updateResult);
}
}
.start();
}