Program: 153605
Project: 153605
Buggy source:
public boolean handle(Throwable e,HttpServletRequest request,HttpServletResponse response) throws IOException, ServletException {
  try {
    if (!(e instanceof PathNotFoundException)) {
      return false;
    }
    URLResolver urlResolver=new URLResolver(request.getPathInfo(),request.getServerName());
    JCRNodeWrapper pageNode;
    String parentPath=StringUtils.substringBeforeLast(urlResolver.getPath(),"String_Node_Str");
    String newName=StringUtils.substringAfterLast(urlResolver.getPath(),"String_Node_Str");
    newName=StringUtils.substringBefore(newName,"String_Node_Str");
    JCRSessionWrapper session=JCRSessionFactory.getInstance().getCurrentUserSession(urlResolver.getWorkspace(),urlResolver.getLocale());
    try {
      JCRNodeWrapper parent=session.getNode(parentPath);
      if (parent.isNodeType("String_Node_Str")) {
        pageNode=parent;
      }
 else {
        pageNode=JCRContentUtils.getParentOfType(parent,"String_Node_Str");
      }
      if (pageNode == null) {
        return false;
      }
      try {
        JCRNodeWrapper node=pageNode.getNode(newName);
        String link=request.getContextPath() + request.getServletPath() + "String_Node_Str"+ StringUtils.substringBefore(request.getPathInfo().substring(1),"String_Node_Str")+ "String_Node_Str"+ urlResolver.getWorkspace()+ "String_Node_Str"+ urlResolver.getLocale()+ node.getPath();
        link+="String_Node_Str";
        response.sendRedirect(link);
      }
 catch (      PathNotFoundException e1) {
        if (null != pageNode) {
          String link=request.getContextPath() + request.getServletPath() + "String_Node_Str"+ StringUtils.substringBefore(request.getPathInfo().substring(1),"String_Node_Str")+ "String_Node_Str"+ urlResolver.getWorkspace()+ "String_Node_Str"+ urlResolver.getLocale()+ pageNode.getPath();
          link+="String_Node_Str" + URLEncoder.encode(newName,"String_Node_Str");
          response.sendRedirect(link);
          return true;
        }
        logger.debug("String_Node_Str",e1);
      }
    }
 catch (    PathNotFoundException e1) {
      return false;
    }
  }
 catch (  Exception e1) {
    logger.error(e1.getMessage(),e1);
  }
  return false;
}

Fixed version (ground truth):
public boolean handle(Throwable e,HttpServletRequest request,HttpServletResponse response) throws IOException, ServletException {
  try {
    if (!(e instanceof PathNotFoundException)) {
      return false;
    }
    URLResolver urlResolver=new URLResolver(request.getPathInfo(),request.getServerName());
    JCRNodeWrapper pageNode;
    String parentPath=StringUtils.substringBeforeLast(urlResolver.getPath(),"String_Node_Str");
    String newName=StringUtils.substringAfterLast(urlResolver.getPath(),"String_Node_Str");
    newName=StringUtils.substringBefore(newName,"String_Node_Str");
    JCRSessionWrapper session=JCRSessionFactory.getInstance().getCurrentUserSession(urlResolver.getWorkspace(),urlResolver.getLocale());
    try {
      JCRNodeWrapper parent=session.getNode(parentPath);
      if (parent.isNodeType("String_Node_Str")) {
        pageNode=parent;
      }
 else {
        pageNode=JCRContentUtils.getParentOfType(parent,"String_Node_Str");
      }
      boolean isWiki=false;
      if (pageNode.hasProperty("String_Node_Str")) {
        NodeIterator iterator=JCRContentUtils.getDescendantNodes((JCRNodeWrapper)pageNode.getProperty("String_Node_Str").getNode(),"String_Node_Str");
        if (iterator.hasNext()) {
          isWiki=true;
        }
      }
      if (pageNode == null || !isWiki) {
        return false;
      }
      try {
        JCRNodeWrapper node=pageNode.getNode(newName);
        String link=request.getContextPath() + request.getServletPath() + "String_Node_Str"+ StringUtils.substringBefore(request.getPathInfo().substring(1),"String_Node_Str")+ "String_Node_Str"+ urlResolver.getWorkspace()+ "String_Node_Str"+ urlResolver.getLocale()+ node.getPath();
        link+="String_Node_Str";
        response.sendRedirect(link);
      }
 catch (      PathNotFoundException e1) {
        if (null != pageNode) {
          String link=request.getContextPath() + request.getServletPath() + "String_Node_Str"+ StringUtils.substringBefore(request.getPathInfo().substring(1),"String_Node_Str")+ "String_Node_Str"+ urlResolver.getWorkspace()+ "String_Node_Str"+ urlResolver.getLocale()+ pageNode.getPath();
          link+="String_Node_Str" + URLEncoder.encode(newName,"String_Node_Str");
          response.sendRedirect(link);
          return true;
        }
        logger.debug("String_Node_Str",e1);
      }
    }
 catch (    PathNotFoundException e1) {
      return false;
    }
  }
 catch (  Exception e1) {
    logger.error(e1.getMessage(),e1);
  }
  return false;
}