Program: 90631
Project: 90631
Buggy source:
/** 
 * Parse a servlet request to a portal URL.
 * @param request  the servlet request to parse.
 * @return the portal URL.
 */
public PortalURL parse(HttpServletRequest request){
  if (LOG.isDebugEnabled()) {
    LOG.debug("String_Node_Str" + request.getRequestURI());
  }
  String contextPath=request.getContextPath();
  String servletName=request.getServletPath();
  String urlBase=request.getScheme() + "String_Node_Str" + request.getServerName()+ "String_Node_Str"+ request.getServerPort();
  PortalURL portalURL=new RelativePortalURLImpl(urlBase,contextPath,servletName,this,request);
  String pathInfo=request.getPathInfo();
  if (pathInfo == null) {
    if (servletName.contains("String_Node_Str") && !servletName.endsWith("String_Node_Str")) {
      int idx=servletName.indexOf("String_Node_Str") + "String_Node_Str".length();
      pathInfo=servletName.substring(idx);
      servletName=servletName.substring(0,idx);
      portalURL=new RelativePortalURLImpl(urlBase,contextPath,servletName,this,request);
    }
 else {
      return portalURL;
    }
  }
  if (LOG.isDebugEnabled()) {
    LOG.debug("String_Node_Str" + pathInfo);
  }
  StringBuilder renderPath=new StringBuilder();
  if (pathInfo.charAt(0) != '/') {
    renderPath.append('/');
  }
  int ind=pathInfo.indexOf("String_Node_Str" + PREFIX);
  if (ind < 0) {
    renderPath.append(pathInfo);
    pathInfo="String_Node_Str";
  }
 else {
    renderPath.append(pathInfo.substring(0,ind));
    pathInfo=pathInfo.substring(ind);
  }
  portalURL.setRenderPath(renderPath.toString());
  if (LOG.isDebugEnabled()) {
    LOG.debug("String_Node_Str" + renderPath.toString() + "String_Node_Str"+ pathInfo);
  }
  ServletContext sc=request.getServletContext();
  DriverConfiguration dc=(DriverConfiguration)sc.getAttribute(AttributeKeys.DRIVER_CONFIG);
  PublicRenderParameterMapper prpm=dc.getPublicRenderParameterService().getPRPMapper(renderPath.toString());
  portalURL.setPublicRenderParameterMapper(prpm);
  Collection<String> pids=dc.getPageConfig(renderPath.toString()).getPortletIds();
  portalURL.setPortletIds(pids);
  StringBuilder vstr=new StringBuilder();
  if (LOG.isDebugEnabled()) {
    vstr.append("String_Node_Str");
  }
  for (  String pid : pids) {
    String appName=PortletWindowConfig.fromId(pid).getContextPath();
    try {
      String pv=dc.getPortletRegistryService().getPortletApplication(appName).getVersion();
      portalURL.setVersion(pid,pv);
      if (LOG.isDebugEnabled()) {
        vstr.append(pid).append("String_Node_Str").append(pv).append("String_Node_Str");
      }
    }
 catch (    Exception e) {
      LOG.error("String_Node_Str" + appName);
    }
  }
  if (LOG.isDebugEnabled()) {
    LOG.debug(vstr.toString());
  }
  ArrayList<String> portletIds=new ArrayList<String>();
  if (pathInfo.length() > 2) {
    String[] tokens=pathInfo.split("String_Node_Str" + PREFIX);
    for (    String t : tokens) {
      String type, val;
      String[] vals;
      if (t.length() < 3) {
        continue;
      }
 else {
        type=t.substring(0,2);
        val=t.substring(2);
        vals=val.split(DELIM);
      }
      int index=-1;
      String pid=null;
      if ((vals[0].length() > 0) && vals[0].matches("String_Node_Str")) {
        try {
          index=Integer.parseInt(vals[0]);
          if ((index >= 0) && (index < portletIds.size())) {
            pid=portletIds.get(index);
          }
        }
 catch (        Exception e) {
          LOG.error("String_Node_Str" + vals[0] + "String_Node_Str"+ e.toString());
        }
      }
      if (type.equals(PORTLET_ID)) {
        portletIds.add(Integer.parseInt(vals[1]),urlDecode(vals[0]));
        continue;
      }
      if (type.equals(CACHE_LEVEL)) {
        portalURL.setCacheability(urlDecode(vals[0]));
        continue;
      }
      if (type.equals(RESOURCE_ID)) {
        portalURL.setResourceID(urlDecode(vals[0]));
        continue;
      }
      if (type.equals(RESOURCE)) {
        portalURL.setTargetWindow(pid);
        portalURL.setType(URLType.Resource);
        continue;
      }
      if (type.equals(RENDER)) {
        portalURL.setTargetWindow(pid);
        portalURL.setType(URLType.Render);
        continue;
      }
      if (type.equals(ACTION)) {
        portalURL.setTargetWindow(pid);
        portalURL.setType(URLType.Action);
        continue;
      }
      if (type.equals(AJAX_ACTION)) {
        portalURL.setTargetWindow(pid);
        portalURL.setType(URLType.AjaxAction);
        continue;
      }
      if (type.equals(PARTIAL_ACTION)) {
        portalURL.setTargetWindow(pid);
        portalURL.setType(URLType.PartialAction);
        continue;
      }
      if (type.equals(WINDOW_STATE)) {
        portalURL.setWindowState(pid,new WindowState(urlDecode(vals[1])));
        continue;
      }
      if (type.equals(PORTLET_MODE)) {
        portalURL.setPortletMode(pid,new PortletMode(urlDecode(vals[1])));
        continue;
      }
      StringBuilder dbgstr=new StringBuilder();
      if (LOG.isDebugEnabled()) {
        dbgstr.append("String_Node_Str").append(pid).append("String_Node_Str").append(vals[1]);
      }
      String values=vals[1];
      if (type.equals(PUBLIC_RENDER_PARAM)) {
        if (vals.length != 3) {
          LOG.warn("String_Node_Str" + val);
        }
 else {
          values=vals[2];
        }
      }
      String[] pVals=values.split(VALUE_DELIM);
      String[] paramValues=null;
      String paramName=null;
      if (pVals.length > 2) {
        for (int i=0; i < pVals.length; i++) {
          if (pVals[i].equals(VALUE_NULL)) {
            pVals[i]=null;
          }
 else {
            pVals[i]=urlDecode(pVals[i]);
          }
        }
        paramName=pVals[0];
        paramValues=Arrays.copyOfRange(pVals,1,pVals.length);
      }
      if (LOG.isDebugEnabled()) {
        dbgstr.append("String_Node_Str").append(paramName);
        dbgstr.append("String_Node_Str").append(Arrays.toString(paramValues));
        LOG.debug(dbgstr.toString());
      }
      if (type.equals(RENDER_PARAM)) {
        portalURL.addParameter(new PortalURLParameter(pid,paramName,paramValues));
        continue;
      }
      if (type.equals(ACTION_PARAM)) {
        portalURL.addParameter(new PortalURLParameter(pid,paramName,paramValues,PortalURLParameter.PARAM_TYPE_ACTION));
        continue;
      }
      if (type.equals(RESOURCE_PARAM)) {
        portalURL.addParameter(new PortalURLParameter(pid,paramName,paramValues,PortalURLParameter.PARAM_TYPE_RESOURCE));
        continue;
      }
      if (type.equals(PUBLIC_RENDER_PARAM)) {
        PublicRenderParameterMapper mapper=portalURL.getPublicRenderParameterMapper();
        int prpGroup=mapper.getIndex(pid,paramName);
        if (prpGroup >= 0) {
          mapper.setValues(prpGroup,paramValues);
        }
 else {
          StringBuilder sb=new StringBuilder("String_Node_Str");
          sb.append(pid).append("String_Node_Str").append(paramName);
          LOG.warn(sb.toString());
        }
        continue;
      }
    }
  }
  if (LOG.isDebugEnabled()) {
    LOG.debug("String_Node_Str" + portletIds.size() + "String_Node_Str"+ Arrays.toString(portletIds.toArray()));
  }
  return portalURL;
}

Fixed version (ground truth):
/** 
 * Parse a servlet request to a portal URL.
 * @param request  the servlet request to parse.
 * @return the portal URL.
 */
public PortalURL parse(HttpServletRequest request){
  if (LOG.isDebugEnabled()) {
    LOG.debug("String_Node_Str" + request.getRequestURI());
  }
  String contextPath=request.getContextPath();
  String servletName=request.getServletPath();
  String urlBase=request.getScheme() + "String_Node_Str" + request.getServerName()+ "String_Node_Str"+ request.getServerPort();
  PortalURL portalURL=new RelativePortalURLImpl(urlBase,contextPath,servletName,this,request);
  String pathInfo=request.getPathInfo();
  if (pathInfo == null) {
    if (servletName.contains("String_Node_Str") && !servletName.endsWith("String_Node_Str")) {
      int idx=servletName.indexOf("String_Node_Str") + "String_Node_Str".length();
      pathInfo=servletName.substring(idx);
      servletName=servletName.substring(0,idx);
      portalURL=new RelativePortalURLImpl(urlBase,contextPath,servletName,this,request);
    }
 else {
      return portalURL;
    }
  }
  if (LOG.isDebugEnabled()) {
    LOG.debug("String_Node_Str" + pathInfo);
  }
  StringBuilder renderPath=new StringBuilder();
  if (pathInfo.charAt(0) != '/') {
    renderPath.append('/');
  }
  int ind=pathInfo.indexOf("String_Node_Str" + PREFIX);
  if (ind < 0) {
    renderPath.append(pathInfo);
    pathInfo="String_Node_Str";
  }
 else {
    renderPath.append(pathInfo.substring(0,ind));
    pathInfo=pathInfo.substring(ind);
  }
  portalURL.setRenderPath(renderPath.toString());
  if (LOG.isDebugEnabled()) {
    LOG.debug("String_Node_Str" + renderPath.toString() + "String_Node_Str"+ pathInfo);
  }
  ServletContext sc=request.getServletContext();
  DriverConfiguration dc=(DriverConfiguration)sc.getAttribute(AttributeKeys.DRIVER_CONFIG);
  PublicRenderParameterMapper prpm=dc.getPublicRenderParameterService().getPRPMapper(renderPath.toString());
  portalURL.setPublicRenderParameterMapper(prpm);
  Collection<String> pids=dc.getPageConfig(renderPath.toString()).getPortletIds();
  portalURL.setPortletIds(pids);
  StringBuilder vstr=new StringBuilder();
  if (LOG.isDebugEnabled()) {
    vstr.append("String_Node_Str");
  }
  for (  String pid : pids) {
    String appName=PortletWindowConfig.fromId(pid).getContextPath();
    try {
      String pv=dc.getPortletRegistryService().getPortletApplication(appName).getVersion();
      portalURL.setVersion(pid,pv);
      if (LOG.isDebugEnabled()) {
        vstr.append(pid).append("String_Node_Str").append(pv).append("String_Node_Str");
      }
    }
 catch (    Exception e) {
      LOG.error("String_Node_Str" + appName);
    }
  }
  if (LOG.isDebugEnabled()) {
    LOG.debug(vstr.toString());
  }
  ArrayList<String> portletIds=new ArrayList<String>();
  if (pathInfo.length() > 2) {
    String[] tokens=pathInfo.split("String_Node_Str" + PREFIX);
    for (    String t : tokens) {
      String type, val;
      String[] vals;
      if (t.length() < 3) {
        continue;
      }
 else {
        type=t.substring(0,2);
        val=t.substring(2);
        vals=val.split(DELIM);
      }
      int index=-1;
      String pid=null;
      if ((vals[0].length() > 0) && vals[0].matches("String_Node_Str")) {
        try {
          index=Integer.parseInt(vals[0]);
          if ((index >= 0) && (index < portletIds.size())) {
            pid=portletIds.get(index);
          }
        }
 catch (        Exception e) {
          LOG.error("String_Node_Str" + vals[0] + "String_Node_Str"+ e.toString());
        }
      }
      if (type.equals(PORTLET_ID)) {
        portletIds.add(Integer.parseInt(vals[1]),urlDecode(vals[0]));
        continue;
      }
      if (type.equals(CACHE_LEVEL)) {
        portalURL.setCacheability(urlDecode(vals[0]));
        continue;
      }
      if (type.equals(RESOURCE_ID)) {
        portalURL.setResourceID(urlDecode(vals[0]));
        continue;
      }
      if (type.equals(RESOURCE)) {
        portalURL.setTargetWindow(pid);
        portalURL.setType(URLType.Resource);
        continue;
      }
      if (type.equals(RENDER)) {
        portalURL.setTargetWindow(pid);
        portalURL.setType(URLType.Render);
        continue;
      }
      if (type.equals(ACTION)) {
        portalURL.setTargetWindow(pid);
        portalURL.setType(URLType.Action);
        continue;
      }
      if (type.equals(AJAX_ACTION)) {
        portalURL.setTargetWindow(pid);
        portalURL.setType(URLType.AjaxAction);
        continue;
      }
      if (type.equals(PARTIAL_ACTION)) {
        portalURL.setTargetWindow(pid);
        portalURL.setType(URLType.PartialAction);
        continue;
      }
      if (type.equals(WINDOW_STATE)) {
        portalURL.setWindowState(pid,new WindowState(urlDecode(vals[1])));
        continue;
      }
      if (type.equals(PORTLET_MODE)) {
        portalURL.setPortletMode(pid,new PortletMode(urlDecode(vals[1])));
        continue;
      }
      StringBuilder dbgstr=new StringBuilder();
      if (LOG.isDebugEnabled()) {
        dbgstr.append("String_Node_Str").append(pid).append("String_Node_Str").append(vals[1]);
      }
      String values=vals[1];
      if (type.equals(PUBLIC_RENDER_PARAM)) {
        if (vals.length != 3) {
          LOG.warn("String_Node_Str" + val);
        }
 else {
          values=vals[2];
        }
      }
      String[] pVals=values.split(VALUE_DELIM);
      String[] paramValues=new String[0];
      String paramName="String_Node_Str";
      if (pVals.length > 1) {
        for (int i=0; i < pVals.length; i++) {
          if (pVals[i].equals(VALUE_NULL)) {
            pVals[i]=null;
          }
 else {
            pVals[i]=urlDecode(pVals[i]);
          }
        }
      }
      if (pVals.length <= 1 || pVals[0] == null) {
        LOG.warn("String_Node_Str" + values);
      }
 else {
        paramName=pVals[0];
        paramValues=Arrays.copyOfRange(pVals,1,pVals.length);
      }
      if (LOG.isDebugEnabled()) {
        dbgstr.append("String_Node_Str").append(paramName);
        dbgstr.append("String_Node_Str").append(Arrays.toString(paramValues));
        LOG.debug(dbgstr.toString());
      }
      if (type.equals(RENDER_PARAM)) {
        portalURL.addParameter(new PortalURLParameter(pid,paramName,paramValues));
        continue;
      }
      if (type.equals(ACTION_PARAM)) {
        portalURL.addParameter(new PortalURLParameter(pid,paramName,paramValues,PortalURLParameter.PARAM_TYPE_ACTION));
        continue;
      }
      if (type.equals(RESOURCE_PARAM)) {
        portalURL.addParameter(new PortalURLParameter(pid,paramName,paramValues,PortalURLParameter.PARAM_TYPE_RESOURCE));
        continue;
      }
      if (type.equals(PUBLIC_RENDER_PARAM)) {
        PublicRenderParameterMapper mapper=portalURL.getPublicRenderParameterMapper();
        int prpGroup=mapper.getIndex(pid,paramName);
        if (prpGroup >= 0) {
          mapper.setValues(prpGroup,paramValues);
        }
 else {
          StringBuilder sb=new StringBuilder("String_Node_Str");
          sb.append(pid).append("String_Node_Str").append(paramName);
          LOG.warn(sb.toString());
        }
        continue;
      }
    }
  }
  if (portalURL.getType() == URLType.Render || portalURL.getType() == URLType.Portal) {
    portalURL.handleServletRequestParams();
  }
  if (LOG.isDebugEnabled()) {
    LOG.debug("String_Node_Str" + portletIds.size() + "String_Node_Str"+ Arrays.toString(portletIds.toArray()));
  }
  return portalURL;
}