Program: 15669
Project: 15669
Buggy source:
/** 
 * Returns the subscription informations and paginated articles.
 * @param id Subscription ID
 * @param unread Returns only unread articles
 * @param limit Page limit
 * @param offset Page offset
 * @return Response
 * @throws JSONException
 */
@GET @Path("String_Node_Str") @Produces(MediaType.APPLICATION_JSON) public Response get(@PathParam("String_Node_Str") String id,@QueryParam("String_Node_Str") boolean unread,@QueryParam("String_Node_Str") Integer limit,@QueryParam("String_Node_Str") Integer offset) throws JSONException {
  if (!authenticate()) {
    throw new ForbiddenClientException();
  }
  FeedSubscriptionCriteria feedSubscriptionCriteria=new FeedSubscriptionCriteria();
  feedSubscriptionCriteria.setId(id);
  feedSubscriptionCriteria.setUserId(principal.getId());
  FeedSubscriptionDao feedSubscriptionDao=new FeedSubscriptionDao();
  List<FeedSubscriptionDto> feedSubscriptionList=feedSubscriptionDao.findByCriteria(feedSubscriptionCriteria);
  if (feedSubscriptionList.isEmpty()) {
    throw new ClientException("String_Node_Str",MessageFormat.format("String_Node_Str",id));
  }
  FeedSubscriptionDto feedSubscription=feedSubscriptionList.iterator().next();
  UserArticleCriteria userArticleCriteria=new UserArticleCriteria();
  userArticleCriteria.setUnread(unread);
  userArticleCriteria.setUserId(principal.getId());
  userArticleCriteria.setSubscribed(true);
  userArticleCriteria.setFeedId(feedSubscription.getFeedId());
  UserArticleDao userArticleDao=new UserArticleDao();
  PaginatedList<UserArticleDto> paginatedList=PaginatedLists.create(limit,offset);
  userArticleDao.findByCriteria(userArticleCriteria,paginatedList);
  JSONObject response=new JSONObject();
  JSONObject subscription=new JSONObject();
  subscription.put("String_Node_Str",feedSubscription.getFeedSubscriptionTitle());
  subscription.put("String_Node_Str",feedSubscription.getFeedUrl());
  subscription.put("String_Node_Str",feedSubscription.getFeedDescription());
  response.put("String_Node_Str",subscription);
  List<JSONObject> articles=new ArrayList<JSONObject>();
  for (  UserArticleDto userArticle : paginatedList.getResultList()) {
    articles.add(ArticleAssembler.asJson(userArticle));
  }
  response.put("String_Node_Str",paginatedList.getResultCount());
  response.put("String_Node_Str",articles);
  return Response.ok().entity(response).build();
}

Fixed version (ground truth):
/** 
 * Returns the subscription informations and paginated articles.
 * @param id Subscription ID
 * @param unread Returns only unread articles
 * @param limit Page limit
 * @param offset Page offset
 * @return Response
 * @throws JSONException
 */
@GET @Path("String_Node_Str") @Produces(MediaType.APPLICATION_JSON) public Response get(@PathParam("String_Node_Str") String id,@QueryParam("String_Node_Str") boolean unread,@QueryParam("String_Node_Str") Integer limit,@QueryParam("String_Node_Str") Integer offset) throws JSONException {
  if (!authenticate()) {
    throw new ForbiddenClientException();
  }
  FeedSubscriptionCriteria feedSubscriptionCriteria=new FeedSubscriptionCriteria();
  feedSubscriptionCriteria.setId(id);
  feedSubscriptionCriteria.setUserId(principal.getId());
  FeedSubscriptionDao feedSubscriptionDao=new FeedSubscriptionDao();
  List<FeedSubscriptionDto> feedSubscriptionList=feedSubscriptionDao.findByCriteria(feedSubscriptionCriteria);
  if (feedSubscriptionList.isEmpty()) {
    throw new ClientException("String_Node_Str",MessageFormat.format("String_Node_Str",id));
  }
  FeedSubscriptionDto feedSubscription=feedSubscriptionList.iterator().next();
  UserArticleCriteria userArticleCriteria=new UserArticleCriteria();
  userArticleCriteria.setUnread(unread);
  userArticleCriteria.setUserId(principal.getId());
  userArticleCriteria.setVisible(true);
  userArticleCriteria.setFeedId(feedSubscription.getFeedId());
  UserArticleDao userArticleDao=new UserArticleDao();
  PaginatedList<UserArticleDto> paginatedList=PaginatedLists.create(limit,offset);
  userArticleDao.findByCriteria(userArticleCriteria,paginatedList);
  JSONObject response=new JSONObject();
  JSONObject subscription=new JSONObject();
  subscription.put("String_Node_Str",feedSubscription.getFeedSubscriptionTitle());
  subscription.put("String_Node_Str",feedSubscription.getFeedUrl());
  subscription.put("String_Node_Str",feedSubscription.getFeedDescription());
  response.put("String_Node_Str",subscription);
  List<JSONObject> articles=new ArrayList<JSONObject>();
  for (  UserArticleDto userArticle : paginatedList.getResultList()) {
    articles.add(ArticleAssembler.asJson(userArticle));
  }
  response.put("String_Node_Str",paginatedList.getResultCount());
  response.put("String_Node_Str",articles);
  return Response.ok().entity(response).build();
}