Program: 3591
Project: 3591
Buggy source:
/** 
 * Process the input from the upload logo page
 * @param context   current DSpace context
 * @param request   current servlet request object
 * @param response  current servlet response object
 */
private void processUploadLogo(Context context,HttpServletRequest request,HttpServletResponse response) throws ServletException, IOException, SQLException, AuthorizeException {
  FileUploadRequest wrapper=new FileUploadRequest(request);
  Community community=Community.find(context,UIUtil.getIntParameter(wrapper,"String_Node_Str"));
  Collection collection=Collection.find(context,UIUtil.getIntParameter(wrapper,"String_Node_Str"));
  File temp=wrapper.getFile("String_Node_Str");
  InputStream is=new BufferedInputStream(new FileInputStream(temp));
  Bitstream logoBS;
  if (community != null) {
    logoBS=community.setLogo(is);
  }
 else {
    logoBS=collection.setLogo(is);
  }
  String noPath=wrapper.getFilesystemName("String_Node_Str");
  while (noPath.indexOf('/') > -1) {
    noPath=noPath.substring(noPath.indexOf('/') + 1);
  }
  while (noPath.indexOf('\\') > -1) {
    noPath=noPath.substring(noPath.indexOf('\\') + 1);
  }
  logoBS.setName(noPath);
  logoBS.setSource(wrapper.getFilesystemName("String_Node_Str"));
  BitstreamFormat bf=FormatIdentifier.guessFormat(context,logoBS);
  logoBS.setFormat(bf);
  logoBS.update();
  if (community != null) {
    community.update();
    request.setAttribute("String_Node_Str",community);
    JSPManager.showJSP(request,response,"String_Node_Str");
  }
 else {
    collection.update();
    request.setAttribute("String_Node_Str",collection);
    JSPManager.showJSP(request,response,"String_Node_Str");
  }
  temp.delete();
  context.complete();
}

Fixed version (ground truth):
/** 
 * Process the input from the upload logo page
 * @param context   current DSpace context
 * @param request   current servlet request object
 * @param response  current servlet response object
 */
private void processUploadLogo(Context context,HttpServletRequest request,HttpServletResponse response) throws ServletException, IOException, SQLException, AuthorizeException {
  FileUploadRequest wrapper=new FileUploadRequest(request);
  Community community=Community.find(context,UIUtil.getIntParameter(wrapper,"String_Node_Str"));
  Collection collection=Collection.find(context,UIUtil.getIntParameter(wrapper,"String_Node_Str"));
  File temp=wrapper.getFile("String_Node_Str");
  InputStream is=new BufferedInputStream(new FileInputStream(temp));
  Bitstream logoBS;
  if (collection == null) {
    logoBS=community.setLogo(is);
  }
 else {
    logoBS=collection.setLogo(is);
  }
  String noPath=wrapper.getFilesystemName("String_Node_Str");
  while (noPath.indexOf('/') > -1) {
    noPath=noPath.substring(noPath.indexOf('/') + 1);
  }
  while (noPath.indexOf('\\') > -1) {
    noPath=noPath.substring(noPath.indexOf('\\') + 1);
  }
  logoBS.setName(noPath);
  logoBS.setSource(wrapper.getFilesystemName("String_Node_Str"));
  BitstreamFormat bf=FormatIdentifier.guessFormat(context,logoBS);
  logoBS.setFormat(bf);
  logoBS.update();
  if (collection == null) {
    community.update();
    request.setAttribute("String_Node_Str",community);
    JSPManager.showJSP(request,response,"String_Node_Str");
  }
 else {
    collection.update();
    request.setAttribute("String_Node_Str",collection);
    request.setAttribute("String_Node_Str",community);
    JSPManager.showJSP(request,response,"String_Node_Str");
  }
  temp.delete();
  context.complete();
}