Program: 28632
Project: 28632
Buggy source:
private InputStream renderHtml(String contextPath,CacheEntry cacheEntry,ProxyDirContext proxyDirContext) throws IOException, ServletException {
  String name=cacheEntry.name;
  ByteArrayOutputStream stream=new ByteArrayOutputStream();
  OutputStreamWriter osWriter=null;
  try {
    osWriter=new OutputStreamWriter(stream,"String_Node_Str");
  }
 catch (  Exception e) {
    osWriter=new OutputStreamWriter(stream);
  }
  PrintWriter writer=new PrintWriter(osWriter);
  StringBuilder sb=new StringBuilder();
  String rewrittenContextPath=rewriteUrl(contextPath);
  String dirTitle=MessageFormat.format(rb.getString(DIR_TITLE_INFO),name);
  sb.append("String_Node_Str");
  sb.append("String_Node_Str");
  sb.append("String_Node_Str");
  sb.append(dirTitle);
  sb.append("String_Node_Str");
  sb.append("String_Node_Str");
  sb.append(org.apache.catalina.util.TomcatCSS.TOMCAT_CSS);
  sb.append("String_Node_Str");
  sb.append("String_Node_Str");
  sb.append("String_Node_Str");
  sb.append("String_Node_Str");
  sb.append(dirTitle);
  String parentDirectory=name;
  if (parentDirectory.endsWith("String_Node_Str")) {
    parentDirectory=parentDirectory.substring(0,parentDirectory.length() - 1);
  }
  int slash=parentDirectory.lastIndexOf('/');
  if (slash >= 0) {
    String parent=name.substring(0,slash);
    String dirParent=MessageFormat.format(rb.getString(DIR_PARENT_INFO),parent);
    sb.append("String_Node_Str");
    sb.append(rewrittenContextPath);
    if (parent.equals("String_Node_Str"))     parent="String_Node_Str";
    sb.append(rewriteUrl(parent));
    if (!parent.endsWith("String_Node_Str"))     sb.append("String_Node_Str");
    sb.append("String_Node_Str");
    sb.append("String_Node_Str");
    sb.append(dirParent);
    sb.append("String_Node_Str");
    sb.append("String_Node_Str");
  }
  sb.append("String_Node_Str");
  sb.append("String_Node_Str");
  sb.append("String_Node_Str" + "String_Node_Str");
  sb.append("String_Node_Str");
  sb.append("String_Node_Str");
  sb.append(rb.getString(DIR_FILENAME_INFO));
  sb.append("String_Node_Str");
  sb.append("String_Node_Str");
  sb.append(rb.getString(DIR_SIZE_INFO));
  sb.append("String_Node_Str");
  sb.append("String_Node_Str");
  sb.append(rb.getString(DIR_LAST_MODIFIED_INFO));
  sb.append("String_Node_Str");
  sb.append("String_Node_Str");
  try {
    Enumeration<NameClassPair> enumeration=proxyDirContext.list(cacheEntry.name);
    if (sortedBy.equals(SortedBy.LAST_MODIFIED)) {
      ArrayList<NameClassPair> list=Collections.list(enumeration);
      Comparator<NameClassPair> c=new LastModifiedComparator(proxyDirContext,cacheEntry.name);
      Collections.sort(list,c);
      enumeration=Collections.enumeration(list);
    }
 else     if (sortedBy.equals(SortedBy.SIZE)) {
      ArrayList<NameClassPair> list=Collections.list(enumeration);
      Comparator<NameClassPair> c=new SizeComparator(proxyDirContext,cacheEntry.name);
      Collections.sort(list,c);
      enumeration=Collections.enumeration(list);
    }
    boolean shade=false;
    while (enumeration.hasMoreElements()) {
      NameClassPair ncPair=enumeration.nextElement();
      String resourceName=ncPair.getName();
      String trimmed=resourceName;
      if (trimmed.equalsIgnoreCase("String_Node_Str") || trimmed.equalsIgnoreCase("String_Node_Str"))       continue;
      CacheEntry childCacheEntry=proxyDirContext.lookupCache(cacheEntry.name + resourceName);
      if (!childCacheEntry.exists) {
        continue;
      }
      sb.append("String_Node_Str");
      if (shade)       sb.append("String_Node_Str");
      sb.append("String_Node_Str");
      shade=!shade;
      sb.append("String_Node_Str");
      sb.append("String_Node_Str");
      sb.append(rewrittenContextPath);
      resourceName=rewriteUrl(name + resourceName);
      sb.append(resourceName);
      if (childCacheEntry.context != null)       sb.append("String_Node_Str");
      sb.append("String_Node_Str");
      sb.append(RequestUtil.filter(trimmed));
      if (childCacheEntry.context != null)       sb.append("String_Node_Str");
      sb.append("String_Node_Str");
      sb.append("String_Node_Str");
      if (childCacheEntry.context != null)       sb.append("String_Node_Str");
 else       sb.append(renderSize(childCacheEntry.attributes.getContentLength()));
      sb.append("String_Node_Str");
      sb.append("String_Node_Str");
      sb.append(childCacheEntry.attributes.getLastModifiedHttp());
      sb.append("String_Node_Str");
      sb.append("String_Node_Str");
    }
  }
 catch (  NamingException e) {
    throw new ServletException("String_Node_Str",e);
  }
  sb.append("String_Node_Str");
  sb.append("String_Node_Str");
  String readme=getReadme(cacheEntry.context);
  if (readme != null) {
    sb.append(readme);
    sb.append("String_Node_Str");
  }
  String serverInfo=ServerInfo.getPublicServerInfo();
  if (serverInfo != null && !serverInfo.isEmpty()) {
    sb.append("String_Node_Str").append(serverInfo).append("String_Node_Str");
  }
  sb.append("String_Node_Str");
  sb.append("String_Node_Str");
  writer.write(sb.toString());
  writer.flush();
  return (new ByteArrayInputStream(stream.toByteArray()));
}

Fixed version (ground truth):
private InputStream renderHtml(String contextPath,CacheEntry cacheEntry,ProxyDirContext proxyDirContext) throws IOException, ServletException {
  String name=cacheEntry.name;
  ByteArrayOutputStream stream=new ByteArrayOutputStream();
  OutputStreamWriter osWriter=null;
  try {
    osWriter=new OutputStreamWriter(stream,"String_Node_Str");
  }
 catch (  Exception e) {
    osWriter=new OutputStreamWriter(stream);
  }
  PrintWriter writer=new PrintWriter(osWriter);
  StringBuilder sb=new StringBuilder();
  String rewrittenContextPath=rewriteUrl(contextPath);
  String dirTitle=MessageFormat.format(rb.getString(DIR_TITLE_INFO),name);
  sb.append("String_Node_Str");
  sb.append("String_Node_Str");
  sb.append("String_Node_Str");
  sb.append(dirTitle);
  sb.append("String_Node_Str");
  sb.append("String_Node_Str");
  sb.append(org.apache.catalina.util.TomcatCSS.TOMCAT_CSS);
  sb.append("String_Node_Str");
  sb.append("String_Node_Str");
  sb.append("String_Node_Str");
  sb.append("String_Node_Str");
  sb.append(dirTitle);
  String parentDirectory=name;
  if (parentDirectory.endsWith("String_Node_Str")) {
    parentDirectory=parentDirectory.substring(0,parentDirectory.length() - 1);
  }
  int slash=parentDirectory.lastIndexOf('/');
  if (slash >= 0) {
    String parent=name.substring(0,slash);
    String dirParent=MessageFormat.format(rb.getString(DIR_PARENT_INFO),parent);
    sb.append("String_Node_Str");
    sb.append(rewrittenContextPath);
    if (parent.equals("String_Node_Str"))     parent="String_Node_Str";
    sb.append(rewriteUrl(parent));
    if (!parent.endsWith("String_Node_Str"))     sb.append("String_Node_Str");
    sb.append("String_Node_Str");
    sb.append("String_Node_Str");
    sb.append(dirParent);
    sb.append("String_Node_Str");
    sb.append("String_Node_Str");
  }
  sb.append("String_Node_Str");
  sb.append("String_Node_Str");
  sb.append("String_Node_Str" + "String_Node_Str");
  sb.append("String_Node_Str");
  sb.append("String_Node_Str");
  sb.append(rb.getString(DIR_FILENAME_INFO));
  sb.append("String_Node_Str");
  sb.append("String_Node_Str");
  sb.append(rb.getString(DIR_SIZE_INFO));
  sb.append("String_Node_Str");
  sb.append("String_Node_Str");
  sb.append(rb.getString(DIR_LAST_MODIFIED_INFO));
  sb.append("String_Node_Str");
  sb.append("String_Node_Str");
  try {
    Enumeration<NameClassPair> enumeration=proxyDirContext.list(cacheEntry.name);
    if (sortedBy.equals(SortedBy.LAST_MODIFIED)) {
      ArrayList<NameClassPair> list=Collections.list(enumeration);
      Comparator<NameClassPair> c=new LastModifiedComparator(proxyDirContext,cacheEntry.name);
      Collections.sort(list,c);
      enumeration=Collections.enumeration(list);
    }
 else     if (sortedBy.equals(SortedBy.SIZE)) {
      ArrayList<NameClassPair> list=Collections.list(enumeration);
      Comparator<NameClassPair> c=new SizeComparator(proxyDirContext,cacheEntry.name);
      Collections.sort(list,c);
      enumeration=Collections.enumeration(list);
    }
    boolean shade=false;
    HtmlEntityEncoder htmlEntityEncoder=new HtmlEntityEncoder();
    while (enumeration.hasMoreElements()) {
      NameClassPair ncPair=enumeration.nextElement();
      String resourceName=ncPair.getName();
      String trimmed=resourceName;
      if (trimmed.equalsIgnoreCase("String_Node_Str") || trimmed.equalsIgnoreCase("String_Node_Str"))       continue;
      CacheEntry childCacheEntry=proxyDirContext.lookupCache(cacheEntry.name + resourceName);
      if (!childCacheEntry.exists) {
        continue;
      }
      sb.append("String_Node_Str");
      if (shade)       sb.append("String_Node_Str");
      sb.append("String_Node_Str");
      shade=!shade;
      sb.append("String_Node_Str");
      sb.append("String_Node_Str");
      sb.append(rewrittenContextPath);
      resourceName=rewriteUrl(name + resourceName);
      sb.append(resourceName);
      if (childCacheEntry.context != null)       sb.append("String_Node_Str");
      sb.append("String_Node_Str");
      sb.append(htmlEntityEncoder.encode(trimmed));
      if (childCacheEntry.context != null)       sb.append("String_Node_Str");
      sb.append("String_Node_Str");
      sb.append("String_Node_Str");
      if (childCacheEntry.context != null)       sb.append("String_Node_Str");
 else       sb.append(renderSize(childCacheEntry.attributes.getContentLength()));
      sb.append("String_Node_Str");
      sb.append("String_Node_Str");
      sb.append(childCacheEntry.attributes.getLastModifiedHttp());
      sb.append("String_Node_Str");
      sb.append("String_Node_Str");
    }
  }
 catch (  NamingException e) {
    throw new ServletException("String_Node_Str",e);
  }
  sb.append("String_Node_Str");
  sb.append("String_Node_Str");
  String readme=getReadme(cacheEntry.context);
  if (readme != null) {
    sb.append(readme);
    sb.append("String_Node_Str");
  }
  String serverInfo=ServerInfo.getPublicServerInfo();
  if (serverInfo != null && !serverInfo.isEmpty()) {
    sb.append("String_Node_Str").append(serverInfo).append("String_Node_Str");
  }
  sb.append("String_Node_Str");
  sb.append("String_Node_Str");
  writer.write(sb.toString());
  writer.flush();
  return (new ByteArrayInputStream(stream.toByteArray()));
}