Program: 89015
Project: 89015
Buggy source:
/** 
 * Adds a post.
 * @param anyId can be a accountId or groupId
 * @param target define target stream: profile-stream, group-stream
 * @return Result
 */
public static Result addPost(Long anyId,String target){
  Account account=Component.currentAccount();
  Form<Post> filledForm=postForm.bindFromRequest();
  if (target.equals(Post.GROUP)) {
    Group group=Group.findById(anyId);
    if (Secured.isMemberOfGroup(group,account)) {
      if (filledForm.hasErrors()) {
        flash("String_Node_Str",Messages.get("String_Node_Str"));
      }
 else {
        Post post=filledForm.get();
        post.owner=Component.currentAccount();
        post.group=group;
        post.create();
        NotificationService.getInstance().createNotification(post,Post.GROUP);
      }
    }
 else {
      flash("String_Node_Str",Messages.get("String_Node_Str"));
    }
    return redirect(controllers.routes.GroupController.view(group.id,PAGE));
  }
  if (target.equals(Post.PROFILE)) {
    Account profile=Account.findById(anyId);
    if (Secured.isFriend(profile) || profile.equals(account) || Secured.isAdmin()) {
      if (filledForm.hasErrors()) {
        flash("String_Node_Str",Messages.get("String_Node_Str"));
      }
 else {
        Post post=filledForm.get();
        post.account=profile;
        post.owner=account;
        post.create();
        if (!account.equals(profile)) {
          NotificationService.getInstance().createNotification(post,Post.PROFILE);
        }
      }
      return redirect(controllers.routes.ProfileController.stream(anyId,PAGE));
    }
    flash("String_Node_Str",Messages.get("String_Node_Str"));
    return redirect(controllers.routes.ProfileController.stream(anyId,PAGE));
  }
  if (target.equals(Post.STREAM)) {
    Account profile=Account.findById(anyId);
    if (profile.equals(account)) {
      if (filledForm.hasErrors()) {
        flash("String_Node_Str",Messages.get("String_Node_Str"));
      }
 else {
        Post post=filledForm.get();
        post.account=profile;
        post.owner=account;
        post.create();
      }
      return redirect(controllers.routes.Application.stream(PAGE));
    }
    flash("String_Node_Str",Messages.get("String_Node_Str"));
    return redirect(controllers.routes.Application.stream(PAGE));
  }
  return redirect(controllers.routes.Application.index());
}

Fixed version (ground truth):
/** 
 * Adds a post.
 * @param anyId can be a accountId or groupId
 * @param target define target stream: profile-stream, group-stream
 * @return Result
 */
@Transactional public static Result addPost(Long anyId,String target){
  Account account=Component.currentAccount();
  Form<Post> filledForm=postForm.bindFromRequest();
  if (target.equals(Post.GROUP)) {
    Group group=Group.findById(anyId);
    if (Secured.isMemberOfGroup(group,account)) {
      if (filledForm.hasErrors()) {
        flash("String_Node_Str",Messages.get("String_Node_Str"));
      }
 else {
        final Post post=filledForm.get();
        post.owner=Component.currentAccount();
        post.group=group;
        JPA.withTransaction(new F.Callback0(){
          @Override public void invoke() throws Throwable {
            post.create();
          }
        }
);
        NotificationService.getInstance().createNotification(post,Post.GROUP);
      }
    }
 else {
      flash("String_Node_Str",Messages.get("String_Node_Str"));
    }
    return redirect(controllers.routes.GroupController.view(group.id,PAGE));
  }
  if (target.equals(Post.PROFILE)) {
    Account profile=Account.findById(anyId);
    if (Secured.isFriend(profile) || profile.equals(account) || Secured.isAdmin()) {
      if (filledForm.hasErrors()) {
        flash("String_Node_Str",Messages.get("String_Node_Str"));
      }
 else {
        final Post post=filledForm.get();
        post.account=profile;
        post.owner=account;
        JPA.withTransaction(new F.Callback0(){
          @Override public void invoke() throws Throwable {
            post.create();
          }
        }
);
        if (!account.equals(profile)) {
          NotificationService.getInstance().createNotification(post,Post.PROFILE);
        }
      }
      return redirect(controllers.routes.ProfileController.stream(anyId,PAGE));
    }
    flash("String_Node_Str",Messages.get("String_Node_Str"));
    return redirect(controllers.routes.ProfileController.stream(anyId,PAGE));
  }
  if (target.equals(Post.STREAM)) {
    Account profile=Account.findById(anyId);
    if (profile.equals(account)) {
      if (filledForm.hasErrors()) {
        flash("String_Node_Str",Messages.get("String_Node_Str"));
      }
 else {
        final Post post=filledForm.get();
        post.account=profile;
        post.owner=account;
        JPA.withTransaction(new F.Callback0(){
          @Override public void invoke() throws Throwable {
            post.create();
          }
        }
);
      }
      return redirect(controllers.routes.Application.stream(PAGE));
    }
    flash("String_Node_Str",Messages.get("String_Node_Str"));
    return redirect(controllers.routes.Application.stream(PAGE));
  }
  return redirect(controllers.routes.Application.index());
}