Program: 15663
Project: 15663
Buggy source:
/** 
 * Search articles.
 * @param query Search query
 * @return List of articles
 * @throws Exception 
 */
public PaginatedList<UserArticleDto> searchArticles(String userId,List<String> feedList,String searchQuery,Integer offset,Integer limit) throws Exception {
  ArticleDao articleDao=new ArticleDao();
  PaginatedList<UserArticleDto> paginatedList=PaginatedLists.create(limit,offset);
  Map<String,Article> articleMap=null;
  if (feedList.size() > 0) {
    articleMap=articleDao.search(paginatedList,feedList,searchQuery);
  }
  if (articleMap != null && articleMap.size() > 0) {
    UserArticleCriteria userArticleCriteria=new UserArticleCriteria();
    userArticleCriteria.setUserId(userId);
    userArticleCriteria.setSubscribed(true);
    userArticleCriteria.setArticleIdIn(Lists.newArrayList(articleMap.keySet()));
    UserArticleDao userArticleDao=new UserArticleDao();
    PaginatedList<UserArticleDto> userArticledList=PaginatedLists.create(paginatedList.getLimit(),0);
    userArticleDao.findByCriteria(userArticleCriteria,userArticledList);
    paginatedList.setResultList(userArticledList.getResultList());
    for (    UserArticleDto userArticleDto : paginatedList.getResultList()) {
      Article article=articleMap.get(userArticleDto.getArticleId());
      if (article.getTitle() != null) {
        userArticleDto.setArticleTitle(article.getTitle());
      }
      if (article.getDescription() != null) {
        userArticleDto.setArticleDescription(article.getDescription());
      }
    }
  }
 else {
    paginatedList.setResultList(new ArrayList<UserArticleDto>());
  }
  return paginatedList;
}

Fixed version (ground truth):
/** 
 * Search articles.
 * @param query Search query
 * @return List of articles
 * @throws Exception 
 */
public PaginatedList<UserArticleDto> searchArticles(String userId,List<String> feedList,String searchQuery,Integer offset,Integer limit) throws Exception {
  ArticleDao articleDao=new ArticleDao();
  PaginatedList<UserArticleDto> paginatedList=PaginatedLists.create(limit,offset);
  Map<String,Article> articleMap=null;
  if (feedList.size() > 0) {
    articleMap=articleDao.search(paginatedList,feedList,searchQuery);
  }
  if (articleMap != null && articleMap.size() > 0) {
    UserArticleCriteria userArticleCriteria=new UserArticleCriteria();
    userArticleCriteria.setUserId(userId);
    userArticleCriteria.setVisible(true);
    userArticleCriteria.setArticleIdIn(Lists.newArrayList(articleMap.keySet()));
    UserArticleDao userArticleDao=new UserArticleDao();
    PaginatedList<UserArticleDto> userArticledList=PaginatedLists.create(paginatedList.getLimit(),0);
    userArticleDao.findByCriteria(userArticleCriteria,userArticledList);
    paginatedList.setResultList(userArticledList.getResultList());
    for (    UserArticleDto userArticleDto : paginatedList.getResultList()) {
      Article article=articleMap.get(userArticleDto.getArticleId());
      if (article.getTitle() != null) {
        userArticleDto.setArticleTitle(article.getTitle());
      }
      if (article.getDescription() != null) {
        userArticleDto.setArticleDescription(article.getDescription());
      }
    }
  }
 else {
    paginatedList.setResultList(new ArrayList<UserArticleDto>());
  }
  return paginatedList;
}