Program: 63396
Project: 63396
Buggy source:
/** 
 * Determine the URL path to the persistence unit
 * @param pxmlURL - Encoded URL containing the pu
 * @return
 * @throws IOException
 */
public static URL computePURootURL(URL pxmlURL,String descriptorLocation) throws IOException, URISyntaxException {
  StringTokenizer tokenizer=new StringTokenizer(descriptorLocation,"String_Node_Str");
  int descriptorDepth=tokenizer.countTokens() - 1;
  URL result;
  String protocol=pxmlURL.getProtocol();
  if ("String_Node_Str".equals(protocol)) {
    StringBuffer path=new StringBuffer();
    boolean firstElement=true;
    for (int i=0; i < descriptorDepth; i++) {
      if (!firstElement) {
        path.append("String_Node_Str");
      }
      path.append("String_Node_Str");
      firstElement=false;
    }
    result=new URL(pxmlURL,path.toString());
  }
 else   if ("String_Node_Str".equals(protocol)) {
    JarURLConnection conn=JarURLConnection.class.cast(pxmlURL.openConnection());
    result=conn.getJarFileURL();
  }
 else   if ("String_Node_Str".equals(protocol)) {
    String spec=pxmlURL.getFile();
    int separator=spec.lastIndexOf("String_Node_Str");
    if (separator == -1) {
      separator=spec.length() - 1;
    }
    result=new URL("String_Node_Str","String_Node_Str",spec.substring(0,separator++));
  }
 else   if ("String_Node_Str".equals(protocol)) {
    String spec=pxmlURL.getFile();
    int separator=spec.lastIndexOf("String_Node_Str");
    if (separator == -1) {
      separator=spec.length();
    }
 else {
      separator+=2;
      if (spec.regionMatches(true,separator - 6,"String_Node_Str",0,4) && spec.regionMatches(true,separator,WEBINF_CLASSES_STR,0,WEBINF_CLASSES_LEN)) {
        separator+=WEBINF_CLASSES_LEN;
      }
    }
    result=new URL("String_Node_Str","String_Node_Str",spec.substring(0,separator));
  }
 else   if ("String_Node_Str".equals(protocol)) {
    result=new URL("String_Node_Str" + pxmlURL.getAuthority());
  }
 else   if ("String_Node_Str".equals(protocol)) {
    result=new URL("String_Node_Str" + pxmlURL.getAuthority());
  }
 else {
    StringBuffer path=new StringBuffer();
    for (int i=0; i < descriptorDepth; i++) {
      path.append("String_Node_Str");
    }
    result=new URL(pxmlURL,path.toString());
  }
  result=fixUNC(result);
  return result;
}

Fixed version (ground truth):
/** 
 * Determine the URL path to the persistence unit
 * @param pxmlURL - Encoded URL containing the pu
 * @return
 * @throws IOException
 */
public static URL computePURootURL(URL pxmlURL,String descriptorLocation) throws IOException, URISyntaxException {
  StringTokenizer tokenizer=new StringTokenizer(descriptorLocation,"String_Node_Str");
  int descriptorDepth=tokenizer.countTokens() - 1;
  URL result;
  String protocol=pxmlURL.getProtocol();
  if ("String_Node_Str".equals(protocol)) {
    StringBuffer path=new StringBuffer();
    boolean firstElement=true;
    for (int i=0; i < descriptorDepth; i++) {
      if (!firstElement) {
        path.append("String_Node_Str");
      }
      path.append("String_Node_Str");
      firstElement=false;
    }
    result=new URL(pxmlURL,path.toString());
  }
 else   if ("String_Node_Str".equals(protocol)) {
    JarURLConnection conn=JarURLConnection.class.cast(pxmlURL.openConnection());
    result=conn.getJarFileURL();
  }
 else   if ("String_Node_Str".equals(protocol)) {
    String spec=pxmlURL.getFile();
    int separator=spec.lastIndexOf("String_Node_Str");
    if (separator == -1) {
      separator=spec.length() - 1;
    }
    result=new File(spec.substring(0,separator++)).toURL();
  }
 else   if ("String_Node_Str".equals(protocol)) {
    String spec=pxmlURL.getFile();
    int separator=spec.lastIndexOf("String_Node_Str");
    if (separator == -1) {
      separator=spec.length();
    }
 else {
      separator+=2;
      if (spec.regionMatches(true,separator - 6,"String_Node_Str",0,4) && spec.regionMatches(true,separator,WEBINF_CLASSES_STR,0,WEBINF_CLASSES_LEN)) {
        separator+=WEBINF_CLASSES_LEN;
      }
    }
    result=new URL("String_Node_Str","String_Node_Str",spec.substring(0,separator));
  }
 else   if ("String_Node_Str".equals(protocol)) {
    result=new URL("String_Node_Str" + pxmlURL.getAuthority());
  }
 else   if ("String_Node_Str".equals(protocol)) {
    result=new URL("String_Node_Str" + pxmlURL.getAuthority());
  }
 else {
    StringBuffer path=new StringBuffer();
    for (int i=0; i < descriptorDepth; i++) {
      path.append("String_Node_Str");
    }
    result=new URL(pxmlURL,path.toString());
  }
  result=fixUNC(result);
  return result;
}