Program: 153692
Project: 153692
Buggy source:
public String doInJCR(JCRSessionWrapper session) throws RepositoryException {
  boolean isEdit=renderContext.isEditMode();
  String previousWorkspace=renderContext.getWorkspace();
  Resource previousResource=renderContext.getMainResource();
  JCRSiteNode previousSite=renderContext.getSite();
  String previousServletPath=renderContext.getServletPath();
  HashMap<String,Object> removedAttributes=new HashMap<String,Object>();
  try {
    renderContext.setEditMode(false);
    renderContext.setWorkspace(workspace);
    renderContext.setServletPath("String_Node_Str");
    JCRNodeWrapper node=session.getNodeByIdentifier(id);
    Resource resource=new Resource(node,"String_Node_Str",null,"String_Node_Str");
    renderContext.setMainResource(resource);
    renderContext.setSite(node.getResolveSite());
    @SuppressWarnings("String_Node_Str") Enumeration attributeNames=renderContext.getRequest().getAttributeNames();
    while (attributeNames.hasMoreElements()) {
      String attr=(String)attributeNames.nextElement();
      if (!attr.startsWith("String_Node_Str")) {
        removedAttributes.put(attr,renderContext.getRequest().getAttribute(attr));
        renderContext.getRequest().removeAttribute(attr);
      }
    }
    String out=renderService.render(resource,renderContext);
    out=htmlExternalizationService.externalize(out,renderContext);
    newsletterVersions.put(key,out);
    String title=node.getName();
    if (node.hasProperty("String_Node_Str")) {
      title=node.getProperty("String_Node_Str").getString();
    }
    newsletterVersions.put(key + "String_Node_Str",title);
  }
 catch (  RenderException e) {
    throw new RepositoryException(e);
  }
 finally {
    renderContext.setEditMode(isEdit);
    renderContext.setWorkspace(previousWorkspace);
    renderContext.setMainResource(previousResource);
    renderContext.setSite(previousSite);
    renderContext.setServletPath(previousServletPath);
    for (    String key : removedAttributes.keySet()) {
      renderContext.getRequest().setAttribute(key,removedAttributes.get(key));
    }
  }
  return null;
}

Fixed version (ground truth):
public String doInJCR(JCRSessionWrapper session) throws RepositoryException {
  boolean isEdit=renderContext.isEditMode();
  String previousWorkspace=renderContext.getWorkspace();
  Resource previousResource=renderContext.getMainResource();
  JCRSiteNode previousSite=renderContext.getSite();
  SiteInfo previousSiteInfo=renderContext.getSiteInfo();
  String previousServletPath=renderContext.getServletPath();
  HashMap<String,Object> removedAttributes=new HashMap<String,Object>();
  try {
    renderContext.setEditMode(false);
    renderContext.setWorkspace(workspace);
    renderContext.setServletPath("String_Node_Str");
    JCRNodeWrapper node=session.getNodeByIdentifier(id);
    Resource resource=new Resource(node,"String_Node_Str",null,"String_Node_Str");
    renderContext.setMainResource(resource);
    renderContext.setSite(node.getResolveSite());
    renderContext.setSiteInfo(new SiteInfo(node.getResolveSite()));
    @SuppressWarnings("String_Node_Str") Enumeration attributeNames=renderContext.getRequest().getAttributeNames();
    while (attributeNames.hasMoreElements()) {
      String attr=(String)attributeNames.nextElement();
      if (!attr.startsWith("String_Node_Str")) {
        removedAttributes.put(attr,renderContext.getRequest().getAttribute(attr));
        renderContext.getRequest().removeAttribute(attr);
      }
    }
    String out=renderService.render(resource,renderContext);
    out=htmlExternalizationService.externalize(out,renderContext);
    newsletterVersions.put(key,out);
    String title=node.getName();
    if (node.hasProperty("String_Node_Str")) {
      title=node.getProperty("String_Node_Str").getString();
    }
    newsletterVersions.put(key + "String_Node_Str",title);
  }
 catch (  RenderException e) {
    throw new RepositoryException(e);
  }
 finally {
    renderContext.setEditMode(isEdit);
    renderContext.setWorkspace(previousWorkspace);
    renderContext.setMainResource(previousResource);
    renderContext.setSite(previousSite);
    renderContext.setSiteInfo(previousSiteInfo);
    renderContext.setServletPath(previousServletPath);
    for (    String key : removedAttributes.keySet()) {
      renderContext.getRequest().setAttribute(key,removedAttributes.get(key));
    }
  }
  return null;
}