Program: 88992
Project: 88992
Buggy source:
/** 
 * New file is uploaded.
 * @param target Target of the file (e.g. "group")
 * @param id ID of the target (e.g. group ID)
 * @return Result
 */
@Transactional public Result upload(String target,Long id){
  final int maxTotalSize=Play.application().configuration().getInt("String_Node_Str");
  final int maxFileSize=Play.application().configuration().getInt("String_Node_Str");
  Call ret=controllers.routes.Application.index();
  Group group;
  if (target.equals(Media.GROUP)) {
    group=Group.findById(id);
    if (!Secured.uploadMedia(group)) {
      return redirect(controllers.routes.Application.index());
    }
    ret=controllers.routes.GroupController.media(id);
  }
 else {
    return redirect(ret);
  }
  String[] contentLength=request().headers().get("String_Node_Str");
  if (contentLength != null) {
    int size=Integer.parseInt(contentLength[0]);
    if (Media.byteAsMB(size) > maxTotalSize) {
      flash("String_Node_Str","String_Node_Str" + maxTotalSize + "String_Node_Str");
      return redirect(ret);
    }
  }
 else {
    flash("String_Node_Str","String_Node_Str");
    return redirect(ret);
  }
  MultipartFormData body=request().body().asMultipartFormData();
  List<Http.MultipartFormData.FilePart> uploads=body.getFiles();
  List<Media> mediaList=new ArrayList<Media>();
  if (!uploads.isEmpty()) {
    for (    FilePart upload : uploads) {
      Media med=new Media();
      med.title=upload.getFilename();
      med.mimetype=upload.getContentType();
      med.fileName=upload.getFilename();
      med.file=upload.getFile();
      med.owner=Component.currentAccount();
      if (Media.byteAsMB(med.file.length()) > maxFileSize) {
        flash("String_Node_Str","String_Node_Str" + med.title + "String_Node_Str"+ maxFileSize+ "String_Node_Str");
        return redirect(ret);
      }
      String error="String_Node_Str" + med.title + "String_Node_Str";
      if (target.equals(Media.GROUP)) {
        med.temporarySender=Component.currentAccount();
        med.group=group;
        if (med.existsInGroup(group)) {
          flash("String_Node_Str",error);
          return redirect(ret);
        }
      }
      mediaList.add(med);
    }
    for (    Media m : mediaList) {
      try {
        m.create();
        if (m.group != null) {
          NotificationService.getInstance().createNotification(m,Media.MEDIA_NEW_MEDIA);
        }
      }
 catch (      Exception e) {
        return internalServerError(e.getMessage());
      }
    }
    flash("String_Node_Str","String_Node_Str");
    return redirect(ret);
  }
 else {
    flash("String_Node_Str","String_Node_Str");
    return redirect(ret);
  }
}

Fixed version (ground truth):
/** 
 * New file is uploaded.
 * @param target Target of the file (e.g. "group")
 * @param id ID of the target (e.g. group ID)
 * @return Result
 */
@Transactional public Result upload(String target,Long id){
  final int maxTotalSize=conf.getInt("String_Node_Str");
  final int maxFileSize=conf.getInt("String_Node_Str");
  Call ret=controllers.routes.Application.index();
  Group group;
  if (target.equals(Media.GROUP)) {
    group=Group.findById(id);
    if (!Secured.uploadMedia(group)) {
      return redirect(controllers.routes.Application.index());
    }
    ret=controllers.routes.GroupController.media(id);
  }
 else {
    return redirect(ret);
  }
  String[] contentLength=request().headers().get("String_Node_Str");
  if (contentLength != null) {
    int size=Integer.parseInt(contentLength[0]);
    if (Media.byteAsMB(size) > maxTotalSize) {
      flash("String_Node_Str","String_Node_Str" + maxTotalSize + "String_Node_Str");
      return redirect(ret);
    }
  }
 else {
    flash("String_Node_Str","String_Node_Str");
    return redirect(ret);
  }
  MultipartFormData body=request().body().asMultipartFormData();
  List<Http.MultipartFormData.FilePart> uploads=body.getFiles();
  List<Media> mediaList=new ArrayList<Media>();
  if (!uploads.isEmpty()) {
    for (    FilePart upload : uploads) {
      Media med=new Media();
      med.title=upload.getFilename();
      med.mimetype=upload.getContentType();
      med.fileName=upload.getFilename();
      med.file=upload.getFile();
      med.owner=Component.currentAccount();
      if (Media.byteAsMB(med.file.length()) > maxFileSize) {
        flash("String_Node_Str","String_Node_Str" + med.title + "String_Node_Str"+ maxFileSize+ "String_Node_Str");
        return redirect(ret);
      }
      String error="String_Node_Str" + med.title + "String_Node_Str";
      if (target.equals(Media.GROUP)) {
        med.temporarySender=Component.currentAccount();
        med.group=group;
        if (med.existsInGroup(group)) {
          flash("String_Node_Str",error);
          return redirect(ret);
        }
      }
      mediaList.add(med);
    }
    for (    Media m : mediaList) {
      try {
        m.create();
        if (m.group != null) {
          NotificationService.getInstance().createNotification(m,Media.MEDIA_NEW_MEDIA);
        }
      }
 catch (      Exception e) {
        return internalServerError(e.getMessage());
      }
    }
    flash("String_Node_Str","String_Node_Str");
    return redirect(ret);
  }
 else {
    flash("String_Node_Str","String_Node_Str");
    return redirect(ret);
  }
}