Program: 153687
Project: 153687
Buggy source:
public boolean sendIssueToSubscribers(final JCRNodeWrapper node,final RenderContext renderContext,final Map<String,String> newsletterVersions) throws Exception {
  logger.info("String_Node_Str",node.getPath());
  long timer=System.currentTimeMillis();
  final boolean personalized=node.hasProperty(J_PERSONALIZED) && node.getProperty(J_PERSONALIZED).getBoolean();
  JCRTemplate.getInstance().doExecuteWithSystemSession(null,"String_Node_Str",new JCRCallback<Boolean>(){
    public Boolean doInJCR(    JCRSessionWrapper session) throws RepositoryException {
      boolean saveSession=false;
      PaginatedList<Subscription> l=null;
      int total=0;
      int offset=0;
      JCRNodeWrapper target=node.getParent();
      do {
        l=subscriptionService.getSubscriptions(target.getIdentifier(),true,true,null,false,offset,READ_CHUNK_SIZE,session);
        total=l.getTotalSize();
        for (        Subscription subscription : l.getData()) {
          if (StringUtils.isEmpty(subscription.getEmail())) {
            logger.warn("String_Node_Str",subscription.getSubscriber());
            continue;
          }
          String username=JahiaUserManagerService.GUEST_USERNAME;
          JahiaSite site=null;
          try {
            site=siteService.getSiteByKey(node.getResolveSite().getSiteKey());
          }
 catch (          JahiaException ignored) {
          }
          if (personalized && subscription.isRegisteredUser() && subscription.getSubscriber() != null) {
            username=subscription.getName();
          }
          JCRUserNode user=subscription.isRegisteredUser() ? userService.lookupUserByPath(subscription.getSubscriber()) : userService.lookupUserByPath(JahiaUserManagerService.GUEST_USERPATH);
          RenderContext letterContext=new RenderContext(renderContext.getRequest(),renderContext.getResponse(),user.getJahiaUser());
          letterContext.setEditMode(renderContext.isEditMode());
          letterContext.setServletPath(renderContext.getServletPath());
          letterContext.setWorkspace(renderContext.getWorkspace());
          Locale language=subscription.isRegisteredUser() ? UserPreferencesHelper.getPreferredLocale(user,site) : LanguageCodeConverters.languageCodeToLocale(subscription.getProperties().get(J_PREFERRED_LANGUAGE));
          if (language == null) {
            language=LanguageCodeConverters.languageCodeToLocale(site != null ? site.getDefaultLanguage() : SettingsBean.getInstance().getDefaultLanguageCode());
          }
          String confirmationKey=subscription.getConfirmationKey();
          if (confirmationKey == null) {
            try {
              JCRNodeWrapper subscriptionNode=session.getNodeByUUID(subscription.getId());
              confirmationKey=subscriptionService.generateConfirmationKey(subscriptionNode);
              letterContext.getRequest().setAttribute("String_Node_Str",UnsubscribeAction.generateUnsubscribeLink(target,confirmationKey,renderContext.getRequest()));
              subscriptionNode.setProperty(SubscriptionService.J_CONFIRMATION_KEY,confirmationKey);
              saveSession=true;
            }
 catch (            RepositoryException e) {
              logger.warn("String_Node_Str" + subscription.getSubscriber(),e);
            }
          }
 else {
            letterContext.getRequest().setAttribute("String_Node_Str",UnsubscribeAction.generateUnsubscribeLink(target,confirmationKey,renderContext.getRequest()));
          }
          sendIssue(letterContext,node,subscription.getEmail(),username,"String_Node_Str",language,"String_Node_Str",newsletterVersions);
        }
        offset+=READ_CHUNK_SIZE;
      }
 while (offset < total);
      if (saveSession) {
        session.save();
      }
      return Boolean.TRUE;
    }
  }
);
  node.checkout();
  node.setProperty(J_SCHEDULED,(Value)null);
  node.setProperty(J_LAST_SENT,Calendar.getInstance());
  node.getSession().save();
  JCRPublicationService publicationService=JCRPublicationService.getInstance();
  if (publicationService != null) {
    publicationService.publish(Collections.singletonList(node.getIdentifier()),node.getSession().getWorkspace().getName(),Constants.LIVE_WORKSPACE,Collections.singletonList("String_Node_Str"));
  }
  logger.info("String_Node_Str",node.getPath(),System.currentTimeMillis() - timer);
  return true;
}

Fixed version (ground truth):
public boolean sendIssueToSubscribers(final JCRNodeWrapper node,final RenderContext renderContext,final Map<String,String> newsletterVersions) throws Exception {
  logger.info("String_Node_Str",node.getPath());
  long timer=System.currentTimeMillis();
  final boolean personalized=node.hasProperty(J_PERSONALIZED) && node.getProperty(J_PERSONALIZED).getBoolean();
  JCRTemplate.getInstance().doExecuteWithSystemSession(null,"String_Node_Str",new JCRCallback<Boolean>(){
    public Boolean doInJCR(    JCRSessionWrapper session) throws RepositoryException {
      boolean saveSession=false;
      PaginatedList<Subscription> l=null;
      int total=0;
      int offset=0;
      JCRNodeWrapper target=node.getParent();
      do {
        l=subscriptionService.getSubscriptions(target.getIdentifier(),true,true,null,false,offset,READ_CHUNK_SIZE,session);
        total=l.getTotalSize();
        for (        Subscription subscription : l.getData()) {
          if (StringUtils.isEmpty(subscription.getEmail())) {
            logger.warn("String_Node_Str",subscription.getSubscriber());
            continue;
          }
          JahiaSite site=null;
          try {
            site=siteService.getSiteByKey(node.getResolveSite().getSiteKey());
          }
 catch (          JahiaException ignored) {
          }
          JahiaUser letterUser=personalized && subscription.isRegisteredUser() && subscription.getSubscriber() != null ? userService.lookupUserByPath(subscription.getSubscriber()).getJahiaUser() : userService.lookupUserByPath(JahiaUserManagerService.GUEST_USERPATH).getJahiaUser();
          JCRUserNode contextUser=subscription.isRegisteredUser() ? userService.lookupUserByPath(subscription.getSubscriber()) : userService.lookupUserByPath(JahiaUserManagerService.GUEST_USERPATH);
          RenderContext letterContext=new RenderContext(renderContext.getRequest(),renderContext.getResponse(),contextUser.getJahiaUser());
          letterContext.setEditMode(renderContext.isEditMode());
          letterContext.setServletPath(renderContext.getServletPath());
          letterContext.setWorkspace(renderContext.getWorkspace());
          Locale language=subscription.isRegisteredUser() ? UserPreferencesHelper.getPreferredLocale(contextUser,site) : LanguageCodeConverters.languageCodeToLocale(subscription.getProperties().get(J_PREFERRED_LANGUAGE));
          if (language == null) {
            language=LanguageCodeConverters.languageCodeToLocale(site != null ? site.getDefaultLanguage() : SettingsBean.getInstance().getDefaultLanguageCode());
          }
          String confirmationKey=subscription.getConfirmationKey();
          if (confirmationKey == null) {
            try {
              JCRNodeWrapper subscriptionNode=session.getNodeByUUID(subscription.getId());
              confirmationKey=subscriptionService.generateConfirmationKey(subscriptionNode);
              letterContext.getRequest().setAttribute("String_Node_Str",UnsubscribeAction.generateUnsubscribeLink(target,confirmationKey,renderContext.getRequest()));
              subscriptionNode.setProperty(SubscriptionService.J_CONFIRMATION_KEY,confirmationKey);
              saveSession=true;
            }
 catch (            RepositoryException e) {
              logger.warn("String_Node_Str" + subscription.getSubscriber(),e);
            }
          }
 else {
            letterContext.getRequest().setAttribute("String_Node_Str",UnsubscribeAction.generateUnsubscribeLink(target,confirmationKey,renderContext.getRequest()));
          }
          sendIssue(letterContext,node,subscription.getEmail(),letterUser,"String_Node_Str",language,"String_Node_Str",newsletterVersions);
        }
        offset+=READ_CHUNK_SIZE;
      }
 while (offset < total);
      if (saveSession) {
        session.save();
      }
      return Boolean.TRUE;
    }
  }
);
  node.checkout();
  node.setProperty(J_SCHEDULED,(Value)null);
  node.setProperty(J_LAST_SENT,Calendar.getInstance());
  node.getSession().save();
  JCRPublicationService publicationService=JCRPublicationService.getInstance();
  if (publicationService != null) {
    publicationService.publish(Collections.singletonList(node.getIdentifier()),node.getSession().getWorkspace().getName(),Constants.LIVE_WORKSPACE,Collections.singletonList("String_Node_Str"));
  }
  logger.info("String_Node_Str",node.getPath(),System.currentTimeMillis() - timer);
  return true;
}