Program: 57836
Project: 57836
Buggy source:
static void generateDirectoryStructure(JspWriter out,HttpServletRequest req,HttpServletResponse resp,Configuration conf) throws IOException, InterruptedException {
  final String dir=JspHelper.validatePath(StringEscapeUtils.unescapeHtml(req.getParameter("String_Node_Str")));
  if (dir == null) {
    out.print("String_Node_Str");
    return;
  }
  String tokenString=req.getParameter(JspHelper.DELEGATION_PARAMETER_NAME);
  UserGroupInformation ugi=JspHelper.getUGI(req,conf);
  String namenodeInfoPortStr=req.getParameter("String_Node_Str");
  int namenodeInfoPort=-1;
  if (namenodeInfoPortStr != null)   namenodeInfoPort=Integer.parseInt(namenodeInfoPortStr);
  final String nnAddr=req.getParameter(JspHelper.NAMENODE_ADDRESS);
  if (nnAddr == null) {
    out.print(JspHelper.NAMENODE_ADDRESS + "String_Node_Str");
    return;
  }
  DFSClient dfs=getDFSClient(ugi,nnAddr,conf);
  String target=dir;
  final HdfsFileStatus targetStatus=dfs.getFileInfo(target);
  if (targetStatus == null) {
    out.print("String_Node_Str" + StringEscapeUtils.escapeHtml(target) + "String_Node_Str");
    JspHelper.printGotoForm(out,namenodeInfoPort,tokenString,target,nnAddr);
  }
 else {
    if (!targetStatus.isDir()) {
      List<LocatedBlock> blocks=dfs.getNamenode().getBlockLocations(dir,0,1).getLocatedBlocks();
      LocatedBlock firstBlock=null;
      DatanodeInfo[] locations=null;
      if (blocks.size() > 0) {
        firstBlock=blocks.get(0);
        locations=firstBlock.getLocations();
      }
      if (locations == null || locations.length == 0) {
        out.print("String_Node_Str");
      }
 else {
        DatanodeInfo chosenNode=JspHelper.bestNode(firstBlock,conf);
        String fqdn=canonicalize(chosenNode.getIpAddr());
        int datanodePort=chosenNode.getXferPort();
        String redirectLocation=HttpConfig.getSchemePrefix() + fqdn + "String_Node_Str"+ chosenNode.getInfoPort()+ "String_Node_Str"+ firstBlock.getBlock().getBlockId()+ "String_Node_Str"+ firstBlock.getBlock().getNumBytes()+ "String_Node_Str"+ firstBlock.getBlock().getGenerationStamp()+ "String_Node_Str"+ URLEncoder.encode(dir,"String_Node_Str")+ "String_Node_Str"+ datanodePort+ "String_Node_Str"+ namenodeInfoPort+ JspHelper.getDelegationTokenUrlParam(tokenString)+ JspHelper.getUrlParam(JspHelper.NAMENODE_ADDRESS,nnAddr);
        resp.sendRedirect(redirectLocation);
      }
      return;
    }
    String[] headings={"String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str"};
    out.print("String_Node_Str");
    JspHelper.printPathWithLinks(dir,out,namenodeInfoPort,tokenString,nnAddr);
    out.print("String_Node_Str");
    JspHelper.printGotoForm(out,namenodeInfoPort,tokenString,dir,nnAddr);
    out.print("String_Node_Str");
    File f=new File(dir);
    String parent;
    if ((parent=f.getParent()) != null)     out.print("String_Node_Str" + req.getRequestURL() + "String_Node_Str"+ parent+ "String_Node_Str"+ namenodeInfoPort+ JspHelper.getDelegationTokenUrlParam(tokenString)+ JspHelper.getUrlParam(JspHelper.NAMENODE_ADDRESS,nnAddr)+ "String_Node_Str");
    DirectoryListing thisListing=dfs.listPaths(target,HdfsFileStatus.EMPTY_NAME);
    if (thisListing == null || thisListing.getPartialListing().length == 0) {
      out.print("String_Node_Str");
    }
 else {
      JspHelper.addTableHeader(out);
      int row=0;
      JspHelper.addTableRow(out,headings,row++);
      String cols[]=new String[headings.length];
      do {
        HdfsFileStatus[] files=thisListing.getPartialListing();
        for (int i=0; i < files.length; i++) {
          String localFileName=files[i].getLocalName();
          if (!files[i].isDir()) {
            cols[1]="String_Node_Str";
            cols[2]=StringUtils.byteDesc(files[i].getLen());
            cols[3]=Short.toString(files[i].getReplication());
            cols[4]=StringUtils.byteDesc(files[i].getBlockSize());
          }
 else {
            cols[1]="String_Node_Str";
            cols[2]="String_Node_Str";
            cols[3]="String_Node_Str";
            cols[4]="String_Node_Str";
          }
          String datanodeUrl=req.getRequestURL() + "String_Node_Str" + URLEncoder.encode(files[i].getFullName(target),"String_Node_Str")+ "String_Node_Str"+ namenodeInfoPort+ JspHelper.getDelegationTokenUrlParam(tokenString)+ JspHelper.getUrlParam(JspHelper.NAMENODE_ADDRESS,nnAddr);
          cols[0]="String_Node_Str" + datanodeUrl + "String_Node_Str"+ HtmlQuoting.quoteHtmlChars(localFileName)+ "String_Node_Str";
          cols[5]=lsDateFormat.format(new Date((files[i].getModificationTime())));
          cols[6]=files[i].getPermission().toString();
          cols[7]=files[i].getOwner();
          cols[8]=files[i].getGroup();
          JspHelper.addTableRow(out,cols,row++);
        }
        if (!thisListing.hasMore()) {
          break;
        }
        thisListing=dfs.listPaths(target,thisListing.getLastName());
      }
 while (thisListing != null);
      JspHelper.addTableFooter(out);
    }
  }
  out.print("String_Node_Str" + HttpConfig.getSchemePrefix() + canonicalize(nnAddr)+ "String_Node_Str"+ namenodeInfoPort+ "String_Node_Str");
  dfs.close();
}

Fixed version (ground truth):
static void generateDirectoryStructure(JspWriter out,HttpServletRequest req,HttpServletResponse resp,Configuration conf) throws IOException, InterruptedException {
  final String dir=JspHelper.validatePath(StringEscapeUtils.unescapeHtml(req.getParameter("String_Node_Str")));
  if (dir == null) {
    out.print("String_Node_Str");
    return;
  }
  String tokenString=req.getParameter(JspHelper.DELEGATION_PARAMETER_NAME);
  UserGroupInformation ugi=JspHelper.getUGI(req,conf);
  String namenodeInfoPortStr=req.getParameter("String_Node_Str");
  int namenodeInfoPort=-1;
  if (namenodeInfoPortStr != null)   namenodeInfoPort=Integer.parseInt(namenodeInfoPortStr);
  final String nnAddr=req.getParameter(JspHelper.NAMENODE_ADDRESS);
  if (nnAddr == null) {
    out.print(JspHelper.NAMENODE_ADDRESS + "String_Node_Str");
    return;
  }
  DFSClient dfs=getDFSClient(ugi,nnAddr,conf);
  String target=dir;
  final HdfsFileStatus targetStatus=dfs.getFileInfo(target);
  if (targetStatus == null) {
    out.print("String_Node_Str" + StringEscapeUtils.escapeHtml(target) + "String_Node_Str");
    JspHelper.printGotoForm(out,namenodeInfoPort,tokenString,target,nnAddr);
  }
 else {
    if (!targetStatus.isDir()) {
      List<LocatedBlock> blocks=dfs.getNamenode().getBlockLocations(dir,0,1).getLocatedBlocks();
      LocatedBlock firstBlock=null;
      DatanodeInfo[] locations=null;
      if (blocks.size() > 0) {
        firstBlock=blocks.get(0);
        locations=firstBlock.getLocations();
      }
      if (locations == null || locations.length == 0) {
        out.print("String_Node_Str");
      }
 else {
        DatanodeInfo chosenNode=JspHelper.bestNode(firstBlock,conf);
        String fqdn=canonicalize(chosenNode.getIpAddr());
        int datanodePort=chosenNode.getXferPort();
        String redirectLocation=HttpConfig.getSchemePrefix() + fqdn + "String_Node_Str"+ chosenNode.getInfoPort()+ "String_Node_Str"+ firstBlock.getBlock().getBlockId()+ "String_Node_Str"+ firstBlock.getBlock().getNumBytes()+ "String_Node_Str"+ firstBlock.getBlock().getGenerationStamp()+ "String_Node_Str"+ URLEncoder.encode(dir,"String_Node_Str")+ "String_Node_Str"+ datanodePort+ "String_Node_Str"+ namenodeInfoPort+ JspHelper.getDelegationTokenUrlParam(tokenString)+ JspHelper.getUrlParam(JspHelper.NAMENODE_ADDRESS,nnAddr);
        resp.sendRedirect(redirectLocation);
      }
      return;
    }
    String[] headings={"String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str"};
    out.print("String_Node_Str");
    JspHelper.printPathWithLinks(dir,out,namenodeInfoPort,tokenString,nnAddr);
    out.print("String_Node_Str");
    JspHelper.printGotoForm(out,namenodeInfoPort,tokenString,dir,nnAddr);
    out.print("String_Node_Str");
    File f=new File(dir);
    String parent;
    if ((parent=f.getParent()) != null)     out.print("String_Node_Str" + req.getRequestURL() + "String_Node_Str"+ parent+ "String_Node_Str"+ namenodeInfoPort+ JspHelper.getDelegationTokenUrlParam(tokenString)+ JspHelper.getUrlParam(JspHelper.NAMENODE_ADDRESS,nnAddr)+ "String_Node_Str");
    DirectoryListing thisListing=dfs.listPaths(target,HdfsFileStatus.EMPTY_NAME);
    if (thisListing == null || thisListing.getPartialListing().length == 0) {
      out.print("String_Node_Str");
    }
 else {
      JspHelper.addTableHeader(out);
      int row=0;
      JspHelper.addTableRow(out,headings,row++);
      String cols[]=new String[headings.length];
      do {
        HdfsFileStatus[] files=thisListing.getPartialListing();
        for (int i=0; i < files.length; i++) {
          String localFileName=files[i].getLocalName();
          if (!files[i].isDir()) {
            cols[1]="String_Node_Str";
            cols[2]=StringUtils.byteDesc(files[i].getLen());
            cols[3]=Short.toString(files[i].getReplication());
            cols[4]=StringUtils.byteDesc(files[i].getBlockSize());
          }
 else {
            cols[1]="String_Node_Str";
            cols[2]="String_Node_Str";
            cols[3]="String_Node_Str";
            cols[4]="String_Node_Str";
          }
          String datanodeUrl=req.getRequestURL() + "String_Node_Str" + URLEncoder.encode(files[i].getFullName(target),"String_Node_Str")+ "String_Node_Str"+ namenodeInfoPort+ JspHelper.getDelegationTokenUrlParam(tokenString)+ JspHelper.getUrlParam(JspHelper.NAMENODE_ADDRESS,nnAddr);
          cols[0]="String_Node_Str" + datanodeUrl + "String_Node_Str"+ HtmlQuoting.quoteHtmlChars(localFileName)+ "String_Node_Str";
          cols[5]=new SimpleDateFormat("String_Node_Str").format(new Date((files[i].getModificationTime())));
          cols[6]=files[i].getPermission().toString();
          cols[7]=files[i].getOwner();
          cols[8]=files[i].getGroup();
          JspHelper.addTableRow(out,cols,row++);
        }
        if (!thisListing.hasMore()) {
          break;
        }
        thisListing=dfs.listPaths(target,thisListing.getLastName());
      }
 while (thisListing != null);
      JspHelper.addTableFooter(out);
    }
  }
  out.print("String_Node_Str" + HttpConfig.getSchemePrefix() + canonicalize(nnAddr)+ "String_Node_Str"+ namenodeInfoPort+ "String_Node_Str");
  dfs.close();
}