Program: 52044
Project: 52044
Buggy source:
/** 
 * Update bitstream data. It change bitstream data by editing database rows. It can throw WebApplicationException caused by: SQLException if there was problem with database editing or reading, IOException if there was problem with reading from inputstream, Exception if there was another problem.
 * @param bitstreamId Id of bistream, which will be updated.
 * @param is Inputstream filled with new data.
 * @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 Return response if bitstream was updated. Response codes:OK(200), NOT_FOUND(404) if id of bitstream was bad. And UNAUTHORIZED(401) if user is not allowed to update bitstream.
 * @throws WebApplicationException This exception can be thrown in this cases: Problem with reading or writing to database. Or problem with reading from inputstream.
 */
@PUT @Path("String_Node_Str") public Response updateBitstreamData(@PathParam("String_Node_Str") Integer bitstreamId,InputStream is,@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" + bitstreamId + "String_Node_Str");
  org.dspace.core.Context context=null;
  try {
    context=createContext(getUser(headers));
    org.dspace.content.Bitstream dspaceBitstream=findBitstream(context,bitstreamId,org.dspace.core.Constants.WRITE);
    writeStats(dspaceBitstream,UsageEvent.Action.UPDATE,user_ip,user_agent,xforwarderfor,headers,request);
    log.trace("String_Node_Str");
    int newBitstreamId=BitstreamStorageManager.store(context,is);
    log.trace("String_Node_Str");
    TableRow originalBitstreamRow=DatabaseManager.find(context,"String_Node_Str",bitstreamId);
    TableRow bitstream=DatabaseManager.find(context,"String_Node_Str",newBitstreamId);
    log.trace("String_Node_Str");
    String internal_id=originalBitstreamRow.getStringColumn("String_Node_Str");
    Long size_bytes=originalBitstreamRow.getLongColumn("String_Node_Str");
    originalBitstreamRow.setColumn("String_Node_Str",bitstream.getStringColumn("String_Node_Str"));
    originalBitstreamRow.setColumn("String_Node_Str",bitstream.getLongColumn("String_Node_Str"));
    bitstream.setColumn("String_Node_Str",internal_id);
    bitstream.setColumn("String_Node_Str",size_bytes);
    DatabaseManager.update(context,originalBitstreamRow);
    BitstreamStorageManager.delete(context,newBitstreamId);
    context.complete();
  }
 catch (  SQLException e) {
    processException("String_Node_Str" + bitstreamId + "String_Node_Str"+ e,context);
  }
catch (  IOException e) {
    processException("String_Node_Str" + bitstreamId + "String_Node_Str"+ e,context);
  }
catch (  ContextException e) {
    processException("String_Node_Str" + bitstreamId + "String_Node_Str"+ e.getMessage(),context);
  }
 finally {
    processFinally(context);
  }
  log.info("String_Node_Str" + bitstreamId + "String_Node_Str");
  return Response.ok().build();
}

Fixed version (ground truth):
/** 
 * Update bitstream data. It change bitstream data by editing database rows. It can throw WebApplicationException caused by: SQLException if there was problem with database editing or reading, IOException if there was problem with reading from inputstream, Exception if there was another problem.
 * @param bitstreamId Id of bistream, which will be updated.
 * @param is Inputstream filled with new data.
 * @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 Return response if bitstream was updated. Response codes:OK(200), NOT_FOUND(404) if id of bitstream was bad. And UNAUTHORIZED(401) if user is not allowed to update bitstream.
 * @throws WebApplicationException This exception can be thrown in this cases: Problem with reading or writing to database. Or problem with reading from inputstream.
 */
@PUT @Path("String_Node_Str") public Response updateBitstreamData(@PathParam("String_Node_Str") Integer bitstreamId,InputStream is,@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" + bitstreamId + "String_Node_Str");
  org.dspace.core.Context context=null;
  try {
    context=createContext(getUser(headers));
    org.dspace.content.Bitstream dspaceBitstream=findBitstream(context,bitstreamId,org.dspace.core.Constants.WRITE);
    writeStats(dspaceBitstream,UsageEvent.Action.UPDATE,user_ip,user_agent,xforwarderfor,headers,request,context);
    log.trace("String_Node_Str");
    int newBitstreamId=BitstreamStorageManager.store(context,is);
    log.trace("String_Node_Str");
    TableRow originalBitstreamRow=DatabaseManager.find(context,"String_Node_Str",bitstreamId);
    TableRow bitstream=DatabaseManager.find(context,"String_Node_Str",newBitstreamId);
    log.trace("String_Node_Str");
    String internal_id=originalBitstreamRow.getStringColumn("String_Node_Str");
    Long size_bytes=originalBitstreamRow.getLongColumn("String_Node_Str");
    originalBitstreamRow.setColumn("String_Node_Str",bitstream.getStringColumn("String_Node_Str"));
    originalBitstreamRow.setColumn("String_Node_Str",bitstream.getLongColumn("String_Node_Str"));
    bitstream.setColumn("String_Node_Str",internal_id);
    bitstream.setColumn("String_Node_Str",size_bytes);
    DatabaseManager.update(context,originalBitstreamRow);
    BitstreamStorageManager.delete(context,newBitstreamId);
    context.complete();
  }
 catch (  SQLException e) {
    processException("String_Node_Str" + bitstreamId + "String_Node_Str"+ e,context);
  }
catch (  IOException e) {
    processException("String_Node_Str" + bitstreamId + "String_Node_Str"+ e,context);
  }
catch (  ContextException e) {
    processException("String_Node_Str" + bitstreamId + "String_Node_Str"+ e.getMessage(),context);
  }
 finally {
    processFinally(context);
  }
  log.info("String_Node_Str" + bitstreamId + "String_Node_Str");
  return Response.ok().build();
}