Program: 88976
Project: 88976
Buggy source:
/** 
 * Adds a post.
 * @param anyId  can be a accountId or groupId
 * @param target define target stream: profile-stream, group-stream
 * @return Result
 */
@Transactional public Result addPost(Long anyId,String target){
  Account account=Component.currentAccount();
  Form<Post> filledForm=postForm.bindFromRequest();
  if (target.equals(Post.GROUP)) {
    Group group=groupManager.findById(anyId);
    if (Secured.isMemberOfGroup(group,account)) {
      if (filledForm.hasErrors()) {
        flash("String_Node_Str",messagesApi.get(Lang.defaultLang(),"String_Node_Str"));
      }
 else {
        Post post=filledForm.get();
        post.owner=Component.currentAccount();
        post.group=group;
        postManager.create(post);
        notificationService.createNotification(post,Post.GROUP);
      }
    }
 else {
      flash("String_Node_Str",messagesApi.get(Lang.defaultLang(),"String_Node_Str"));
    }
    return redirect(controllers.routes.GroupController.stream(group.id,PAGE,false));
  }
  if (target.equals(Post.PROFILE)) {
    Account profile=accountManager.findById(anyId);
    if (Secured.isNotNull(profile) && (Secured.isFriend(profile) || profile.equals(account) || Secured.isAdmin())) {
      if (filledForm.hasErrors()) {
        flash("String_Node_Str",messagesApi.get(Lang.defaultLang(),"String_Node_Str"));
      }
 else {
        Post post=filledForm.get();
        post.account=profile;
        post.owner=account;
        postManager.create(post);
        if (!account.equals(profile)) {
          notificationService.createNotification(post,Post.PROFILE);
        }
      }
      return redirect(controllers.routes.ProfileController.stream(anyId,PAGE,false));
    }
    flash("String_Node_Str",messagesApi.get(Lang.defaultLang(),"String_Node_Str"));
    return redirect(controllers.routes.ProfileController.stream(anyId,PAGE,false));
  }
  if (target.equals(Post.STREAM)) {
    Account profile=accountManager.findById(anyId);
    if (Secured.isNotNull(profile) && profile.equals(account)) {
      if (filledForm.hasErrors()) {
        flash("String_Node_Str",messagesApi.get(Lang.defaultLang(),"String_Node_Str"));
      }
 else {
        Post post=filledForm.get();
        post.account=profile;
        post.owner=account;
        postManager.create(post);
      }
      return redirect(controllers.routes.Application.stream(STREAM_FILTER,PAGE,false));
    }
    flash("String_Node_Str",messagesApi.get(Lang.defaultLang(),"String_Node_Str"));
    return redirect(controllers.routes.Application.stream(STREAM_FILTER,PAGE,false));
  }
  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 Result addPost(Long anyId,String target){
  Account account=Component.currentAccount();
  Form<Post> filledForm=postForm.bindFromRequest();
  if (target.equals(Post.GROUP)) {
    Group group=groupManager.findById(anyId);
    if (Secured.isMemberOfGroup(group,account)) {
      if (filledForm.hasErrors()) {
        flash("String_Node_Str",messagesApi.get(Lang.defaultLang(),"String_Node_Str"));
      }
 else {
        Post post=filledForm.get();
        post.owner=Component.currentAccount();
        post.group=group;
        postManager.create(post);
        notificationService.createNotification(post,Post.GROUP);
        LOG.info("String_Node_Str" + post.owner.id + "String_Node_Str"+ group.title);
      }
    }
 else {
      flash("String_Node_Str",messagesApi.get(Lang.defaultLang(),"String_Node_Str"));
    }
    return redirect(controllers.routes.GroupController.stream(group.id,PAGE,false));
  }
  if (target.equals(Post.PROFILE)) {
    Account profile=accountManager.findById(anyId);
    if (Secured.isNotNull(profile) && (Secured.isFriend(profile) || profile.equals(account) || Secured.isAdmin())) {
      if (filledForm.hasErrors()) {
        flash("String_Node_Str",messagesApi.get(Lang.defaultLang(),"String_Node_Str"));
      }
 else {
        Post post=filledForm.get();
        post.account=profile;
        post.owner=account;
        postManager.create(post);
        if (!account.equals(profile)) {
          notificationService.createNotification(post,Post.PROFILE);
        }
      }
      return redirect(controllers.routes.ProfileController.stream(anyId,PAGE,false));
    }
    flash("String_Node_Str",messagesApi.get(Lang.defaultLang(),"String_Node_Str"));
    return redirect(controllers.routes.ProfileController.stream(anyId,PAGE,false));
  }
  if (target.equals(Post.STREAM)) {
    Account profile=accountManager.findById(anyId);
    if (Secured.isNotNull(profile) && profile.equals(account)) {
      if (filledForm.hasErrors()) {
        flash("String_Node_Str",messagesApi.get(Lang.defaultLang(),"String_Node_Str"));
      }
 else {
        Post post=filledForm.get();
        post.account=profile;
        post.owner=account;
        postManager.create(post);
      }
      return redirect(controllers.routes.Application.stream(STREAM_FILTER,PAGE,false));
    }
    flash("String_Node_Str",messagesApi.get(Lang.defaultLang(),"String_Node_Str"));
    return redirect(controllers.routes.Application.stream(STREAM_FILTER,PAGE,false));
  }
  return redirect(controllers.routes.Application.index());
}