Program: 52039
Project: 52039
Buggy source:
/** 
 * Read list of bitstreams. It throws WebApplicationException with response code INTERNAL_SERVER_ERROR(500), if there was problem while reading bitstreams from database.
 * @param limit How much bitstreams in list will be. Default value is 100.
 * @param offset On which index will list starts. Default values is 0.
 * @param headers If you want to access to item under logged user into context. In headers must be set header "rest-dspace-token" with passed token from login method.
 * @return It returns array of bistreams. In array are not bitstreams onwhich user has not permission to read.
 * @throws WebApplicationException It is thrown when was problem with database reading or with creating context.
 */
@GET @Produces({MediaType.APPLICATION_JSON,MediaType.APPLICATION_XML}) public Bitstream[] getBitstreams(@QueryParam("String_Node_Str") String expand,@QueryParam("String_Node_Str") @DefaultValue("String_Node_Str") Integer limit,@QueryParam("String_Node_Str") @DefaultValue("String_Node_Str") Integer offset,@QueryParam("String_Node_Str") String user_ip,@QueryParam("String_Node_Str") String user_agent,@QueryParam("String_Node_Str") String xforwarderfor,@Context HttpHeaders headers,@Context HttpServletRequest request) throws WebApplicationException {
  log.info("String_Node_Str" + offset + "String_Node_Str"+ limit+ "String_Node_Str");
  org.dspace.core.Context context=null;
  List<Bitstream> bitstreams=new ArrayList<Bitstream>();
  try {
    context=createContext(getUser(headers));
    org.dspace.content.Bitstream[] dspaceBitstreams=org.dspace.content.Bitstream.findAll(context);
    if (!((limit != null) && (limit >= 0) && (offset != null)&& (offset >= 0))) {
      log.warn("String_Node_Str");
      limit=100;
      offset=0;
    }
    for (int i=offset; (i < (offset + limit)) && (i < dspaceBitstreams.length); i++) {
      if (AuthorizeManager.authorizeActionBoolean(context,dspaceBitstreams[i],org.dspace.core.Constants.READ)) {
        if (dspaceBitstreams[i].getParentObject() != null) {
          bitstreams.add(new Bitstream(dspaceBitstreams[i],expand));
          writeStats(dspaceBitstreams[i],UsageEvent.Action.VIEW,user_ip,user_agent,xforwarderfor,headers,request);
        }
      }
    }
    context.complete();
    log.trace("String_Node_Str");
  }
 catch (  SQLException e) {
    processException("String_Node_Str" + e,context);
  }
catch (  ContextException e) {
    processException("String_Node_Str" + e.getMessage(),context);
  }
 finally {
    processFinally(context);
  }
  return bitstreams.toArray(new Bitstream[0]);
}

Fixed version (ground truth):
/** 
 * Read list of bitstreams. It throws WebApplicationException with response code INTERNAL_SERVER_ERROR(500), if there was problem while reading bitstreams from database.
 * @param limit How much bitstreams in list will be. Default value is 100.
 * @param offset On which index will list starts. Default values is 0.
 * @param headers If you want to access to item under logged user into context. In headers must be set header "rest-dspace-token" with passed token from login method.
 * @return It returns array of bistreams. In array are not bitstreams onwhich user has not permission to read.
 * @throws WebApplicationException It is thrown when was problem with database reading or with creating context.
 */
@GET @Produces({MediaType.APPLICATION_JSON,MediaType.APPLICATION_XML}) public Bitstream[] getBitstreams(@QueryParam("String_Node_Str") String expand,@QueryParam("String_Node_Str") @DefaultValue("String_Node_Str") Integer limit,@QueryParam("String_Node_Str") @DefaultValue("String_Node_Str") Integer offset,@QueryParam("String_Node_Str") String user_ip,@QueryParam("String_Node_Str") String user_agent,@QueryParam("String_Node_Str") String xforwarderfor,@Context HttpHeaders headers,@Context HttpServletRequest request) throws WebApplicationException {
  log.info("String_Node_Str" + offset + "String_Node_Str"+ limit+ "String_Node_Str");
  org.dspace.core.Context context=null;
  List<Bitstream> bitstreams=new ArrayList<Bitstream>();
  try {
    context=createContext(getUser(headers));
    org.dspace.content.Bitstream[] dspaceBitstreams=org.dspace.content.Bitstream.findAll(context);
    if (!((limit != null) && (limit >= 0) && (offset != null)&& (offset >= 0))) {
      log.warn("String_Node_Str");
      limit=100;
      offset=0;
    }
    for (int i=offset; (i < (offset + limit)) && (i < dspaceBitstreams.length); i++) {
      if (AuthorizeManager.authorizeActionBoolean(context,dspaceBitstreams[i],org.dspace.core.Constants.READ)) {
        if (dspaceBitstreams[i].getParentObject() != null) {
          bitstreams.add(new Bitstream(dspaceBitstreams[i],expand));
          writeStats(dspaceBitstreams[i],UsageEvent.Action.VIEW,user_ip,user_agent,xforwarderfor,headers,request,context);
        }
      }
    }
    context.complete();
    log.trace("String_Node_Str");
  }
 catch (  SQLException e) {
    processException("String_Node_Str" + e,context);
  }
catch (  ContextException e) {
    processException("String_Node_Str" + e.getMessage(),context);
  }
 finally {
    processFinally(context);
  }
  return bitstreams.toArray(new Bitstream[0]);
}