Program: 90642
Project: 90642
Buggy source:
/** 
 * Converts a portal URL to a URL string.
 * @param portalURL  the portal URL to convert.
 * @return a URL string representing the portal URL.
 */
public String toString(PortalURL portalURL){
  StringBuffer buffer=new StringBuffer();
  buffer.append(portalURL.getServletPath().startsWith("String_Node_Str") ? "String_Node_Str" : "String_Node_Str").append(portalURL.getServletPath());
  if (portalURL.getRenderPath() != null) {
    buffer.append("String_Node_Str").append(portalURL.getRenderPath());
  }
  if (portalURL.getResourceWindow() != null) {
    buffer.append("String_Node_Str");
    buffer.append(PREFIX).append(RESOURCE).append(encodeCharacters(portalURL.getResourceWindow()));
  }
  if (portalURL.getActionWindow() != null) {
    buffer.append("String_Node_Str");
    buffer.append(PREFIX).append(ACTION).append(encodeCharacters(portalURL.getActionWindow()));
  }
  for (Iterator it=portalURL.getPortletModes().entrySet().iterator(); it.hasNext(); ) {
    Map.Entry entry=(Map.Entry)it.next();
    buffer.append("String_Node_Str").append(encodeControlParameter(PORTLET_MODE,entry.getKey().toString(),entry.getValue().toString()));
  }
  for (Iterator it=portalURL.getWindowStates().entrySet().iterator(); it.hasNext(); ) {
    Map.Entry entry=(Map.Entry)it.next();
    buffer.append("String_Node_Str").append(encodeControlParameter(WINDOW_STATE,entry.getKey().toString(),entry.getValue().toString()));
  }
  StringBuffer query=new StringBuffer("String_Node_Str");
  boolean firstParam=true;
  for (Iterator it=portalURL.getParameters().iterator(); it.hasNext(); ) {
    PortalURLParameter param=(PortalURLParameter)it.next();
    if (portalURL.getActionWindow() != null && portalURL.getActionWindow().equals(param.getWindowId()) || (portalURL.getResourceWindow() != null && portalURL.getResourceWindow().equals(param.getWindowId()))) {
      for (int i=0; i < param.getValues().length; i++) {
        if (firstParam) {
          firstParam=false;
        }
 else {
          query.append("String_Node_Str");
        }
        query.append(encodeQueryParam(param.getName())).append("String_Node_Str").append(encodeQueryParam(param.getValues()[i]));
      }
    }
 else     if (param.getValues() != null && param.getValues().length > 0) {
      String valueString=encodeMultiValues(param.getValues());
      if (valueString.length() > 0) {
        buffer.append("String_Node_Str").append(encodeControlParameter(RENDER_PARAM,param.getWindowId(),param.getName()));
        buffer.append("String_Node_Str").append(valueString);
      }
    }
  }
  StringUtils.encode(buffer);
  if (query.length() > 1) {
    return buffer.append(query).toString();
  }
  Map<String,String[]> publicParamList=portalURL.getPublicParameters();
  if (publicParamList != null) {
    for (Iterator iter=publicParamList.keySet().iterator(); iter.hasNext(); ) {
      String paramname=(String)iter.next();
      String[] tmp=(String[])publicParamList.get(paramname);
      String valueString=encodeMultiValues(tmp);
      if (valueString.length() > 0) {
        buffer.append("String_Node_Str").append(encodePublicParamname(PUBLIC_RENDER_PARAM,paramname));
        buffer.append("String_Node_Str").append(valueString);
      }
    }
  }
  return buffer.append(query).toString();
}

Fixed version (ground truth):
/** 
 * Converts a portal URL to a URL string.
 * @param portalURL  the portal URL to convert.
 * @return a URL string representing the portal URL.
 */
public String toString(PortalURL portalURL){
  StringBuffer buffer=new StringBuffer();
  buffer.append(portalURL.getServletPath().startsWith("String_Node_Str") ? "String_Node_Str" : "String_Node_Str").append(portalURL.getServletPath());
  if (portalURL.getRenderPath() != null) {
    buffer.append("String_Node_Str").append(portalURL.getRenderPath());
  }
  if (portalURL.getResourceWindow() != null) {
    buffer.append("String_Node_Str");
    buffer.append(PREFIX).append(RESOURCE).append(encodeCharacters(portalURL.getResourceWindow()));
  }
  if (portalURL.getActionWindow() != null) {
    buffer.append("String_Node_Str");
    buffer.append(PREFIX).append(ACTION).append(encodeCharacters(portalURL.getActionWindow()));
  }
  for (Iterator it=portalURL.getPortletModes().entrySet().iterator(); it.hasNext(); ) {
    Map.Entry entry=(Map.Entry)it.next();
    buffer.append("String_Node_Str").append(encodeControlParameter(PORTLET_MODE,entry.getKey().toString(),entry.getValue().toString()));
  }
  for (Iterator it=portalURL.getWindowStates().entrySet().iterator(); it.hasNext(); ) {
    Map.Entry entry=(Map.Entry)it.next();
    buffer.append("String_Node_Str").append(encodeControlParameter(WINDOW_STATE,entry.getKey().toString(),entry.getValue().toString()));
  }
  StringBuffer query=new StringBuffer("String_Node_Str");
  boolean firstParam=true;
  for (Iterator it=portalURL.getParameters().iterator(); it.hasNext(); ) {
    PortalURLParameter param=(PortalURLParameter)it.next();
    if (portalURL.getActionWindow() != null && portalURL.getActionWindow().equals(param.getWindowId()) || (portalURL.getResourceWindow() != null && portalURL.getResourceWindow().equals(param.getWindowId()))) {
      for (int i=0; i < param.getValues().length; i++) {
        if (firstParam) {
          firstParam=false;
        }
 else {
          query.append("String_Node_Str");
        }
        query.append(encodeQueryParam(param.getName())).append("String_Node_Str").append(encodeQueryParam(param.getValues()[i]));
      }
    }
 else     if (param.getValues() != null && param.getValues().length > 0) {
      String valueString=encodeMultiValues(param.getValues());
      if (valueString.length() > 0) {
        buffer.append("String_Node_Str").append(encodeControlParameter(RENDER_PARAM,param.getWindowId(),param.getName()));
        buffer.append("String_Node_Str").append(valueString);
      }
    }
  }
  StringUtils.encode(buffer);
  Map<String,String[]> publicParamList=portalURL.getPublicParameters();
  if (publicParamList != null) {
    for (Iterator iter=publicParamList.keySet().iterator(); iter.hasNext(); ) {
      String paramname=(String)iter.next();
      String[] tmp=(String[])publicParamList.get(paramname);
      String valueString=encodeMultiValues(tmp);
      if (valueString.length() > 0) {
        buffer.append("String_Node_Str").append(encodePublicParamname(PUBLIC_RENDER_PARAM,paramname));
        buffer.append("String_Node_Str").append(valueString);
      }
    }
  }
  if (query.length() > 1) {
    return buffer.append(query).toString();
  }
  return buffer.append(query).toString();
}