Program: 7491
Project: 7491
Buggy source:
/** 
 * Processes an HTML app launcher request. This method loads the app launcher template from storage and replaces all template variables with their corresponding search results and values.
 * @param request        the request to process
 * @param appId          the app identifier to launch (or null)
 * @throws StorageException if the app template couln't be found
 * @throws IOException if the template file couldn't be read properly
 */
protected static void processApp(Request request,String appId) throws StorageException, IOException {
  ApplicationContext ctx=ApplicationContext.getInstance();
  Path path;
  Binary template;
  InputStreamReader is;
  BufferedReader reader;
  String line;
  Array files;
  Object obj;
  StringBuilder res=new StringBuilder();
  path=FileRequestHandler.PATH_FILES.child("String_Node_Str",false);
  obj=ctx.getStorage().load(path);
  if (obj instanceof Binary) {
    template=(Binary)obj;
  }
 else {
    throw new StorageException("String_Node_Str");
  }
  is=new InputStreamReader(template.openStream(),"String_Node_Str");
  reader=new BufferedReader(is);
  while ((line=reader.readLine()) != null) {
    if (line.contains("String_Node_Str")) {
      res.append(line.replace("String_Node_Str",JsSerializer.serialize(appId)));
      res.append("String_Node_Str");
    }
 else     if (line.contains("String_Node_Str")) {
      res.append(line.replace("String_Node_Str",request.getRootUrl()));
      res.append("String_Node_Str");
    }
 else     if (line.contains("String_Node_Str")) {
      files=findFileResources("String_Node_Str");
      for (int i=0; i < files.size(); i++) {
        res.append(line.replace("String_Node_Str",files.getString(i,"String_Node_Str")));
        res.append("String_Node_Str");
      }
    }
 else     if (line.contains("String_Node_Str")) {
      files=findFileResources("String_Node_Str");
      for (int i=0; i < files.size(); i++) {
        res.append(line.replace("String_Node_Str",files.getString(i,"String_Node_Str")));
        res.append("String_Node_Str");
      }
    }
 else {
      res.append(line);
      res.append("String_Node_Str");
    }
  }
  reader.close();
  request.sendText(Mime.HTML[0],res.toString());
}

Fixed version (ground truth):
/** 
 * Processes an HTML app launcher request. This method loads the app launcher template from storage and replaces all template variables with their corresponding search results and values.
 * @param request        the request to process
 * @param appId          the app identifier to launch (or null)
 * @throws StorageException if the app template couln't be found
 * @throws IOException if the template file couldn't be read properly
 */
protected static void processApp(Request request,String appId) throws StorageException, IOException {
  ApplicationContext ctx=ApplicationContext.getInstance();
  Path path;
  Binary template;
  InputStreamReader is;
  BufferedReader reader;
  String line;
  Array files;
  Object obj;
  StringBuilder res=new StringBuilder();
  path=FileRequestHandler.PATH_FILES.child("String_Node_Str",false);
  obj=ctx.getStorage().load(path);
  if (obj instanceof Binary) {
    template=(Binary)obj;
  }
 else {
    throw new StorageException("String_Node_Str");
  }
  is=new InputStreamReader(template.openStream(),"String_Node_Str");
  reader=new BufferedReader(is);
  while ((line=reader.readLine()) != null) {
    if (line.contains("String_Node_Str")) {
      if (appId == null) {
        res.append(line.replace("String_Node_Str","String_Node_Str"));
      }
 else {
        res.append(line.replace("String_Node_Str","String_Node_Str" + appId + "String_Node_Str"));
      }
      res.append("String_Node_Str");
    }
 else     if (line.contains("String_Node_Str")) {
      res.append(line.replace("String_Node_Str",request.getRootUrl()));
      res.append("String_Node_Str");
    }
 else     if (line.contains("String_Node_Str")) {
      files=findFileResources("String_Node_Str");
      for (int i=0; i < files.size(); i++) {
        res.append(line.replace("String_Node_Str",files.getString(i,"String_Node_Str")));
        res.append("String_Node_Str");
      }
    }
 else     if (line.contains("String_Node_Str")) {
      files=findFileResources("String_Node_Str");
      for (int i=0; i < files.size(); i++) {
        res.append(line.replace("String_Node_Str",files.getString(i,"String_Node_Str")));
        res.append("String_Node_Str");
      }
    }
 else {
      res.append(line);
      res.append("String_Node_Str");
    }
  }
  reader.close();
  request.sendText(Mime.HTML[0],res.toString());
}