Program: 120652
Project: 120652
Buggy source:
public void initialize(Monitor monitor,TalendJetEmitter jetEmitter,String componentFamily,String templateName,String templateLanguage,String codePart) throws JETException {
  IProgressMonitor progressMonitor=BasicMonitor.toIProgressMonitor(monitor);
  progressMonitor.beginTask("String_Node_Str",10);
  progressMonitor.subTask(CodeGenPlugin.getPlugin().getString("String_Node_Str",new Object[]{jetEmitter.templateURI}));
  ByteArrayOutputStream outputStream=null;
  InputStream contents=null;
  try {
    JETCompiler jetCompiler=null;
    if (jetEmitter.templateURIPath == null) {
      jetCompiler=new TalendJETCompiler(jetEmitter.templateURI,jetEmitter.encoding,jetEmitter.classLoader);
    }
 else {
      jetCompiler=new TalendJETCompiler(jetEmitter.templateURIPath,jetEmitter.templateURI,jetEmitter.encoding,jetEmitter.classLoader);
    }
    progressMonitor.subTask(CodeGenPlugin.getPlugin().getString("String_Node_Str",new Object[]{jetCompiler.getResolvedTemplateURI()}));
    jetCompiler.parse();
    jetCompiler.getSkeleton().setPackageName("String_Node_Str" + componentFamily);
    jetCompiler.getSkeleton().setClassName(templateName + codePart + templateLanguage);
    progressMonitor.worked(1);
    outputStream=new ByteArrayOutputStream();
    jetCompiler.generate(outputStream);
    contents=new ByteArrayInputStream(outputStream.toByteArray());
    progressMonitor.subTask(CodeGenPlugin.getPlugin().getString("String_Node_Str",new Object[]{project.getName()}));
    String packageName=jetCompiler.getSkeleton().getPackageName();
    StringTokenizer stringTokenizer=new StringTokenizer(packageName,"String_Node_Str");
    IProgressMonitor subProgressMonitor=new SubProgressMonitor(progressMonitor,1);
    subProgressMonitor.beginTask("String_Node_Str",stringTokenizer.countTokens() + 4);
    subProgressMonitor.subTask(CodeGenPlugin.getPlugin().getString("String_Node_Str"));
    IFolder sourceContainer=project.getFolder("String_Node_Str");
    while (stringTokenizer.hasMoreElements()) {
      String folderName=stringTokenizer.nextToken();
      sourceContainer=sourceContainer.getFolder(new Path(folderName));
      if (!sourceContainer.exists()) {
        try {
          sourceContainer.create(true,true,new SubProgressMonitor(subProgressMonitor,1));
        }
 catch (        Exception e) {
          ExceptionHandler.process(e);
        }
      }
    }
    boolean needRebuild=true;
    IFile targetFile=sourceContainer.getFile(new Path(jetCompiler.getSkeleton().getClassName() + "String_Node_Str"));
    if (!targetFile.exists()) {
      subProgressMonitor.subTask(CodeGenPlugin.getPlugin().getString("String_Node_Str",new Object[]{targetFile.getFullPath()}));
      targetFile.create(contents,true,new SubProgressMonitor(subProgressMonitor,1));
    }
 else {
      ByteArrayOutputStream baos=new ByteArrayOutputStream();
      DataInputStream dis=new DataInputStream(targetFile.getContents());
      int len=0;
      byte[] buf=new byte[1024];
      while (((len=dis.read(buf))) != -1) {
        baos.write(buf,0,len);
      }
      dis.close();
      String currentContent=baos.toString();
      String newContent=outputStream.toString();
      currentContent=currentContent.replace("String_Node_Str","String_Node_Str");
      newContent=newContent.replace("String_Node_Str","String_Node_Str");
      if (!newContent.equals(currentContent)) {
        subProgressMonitor.subTask(CodeGenPlugin.getPlugin().getString("String_Node_Str",new Object[]{targetFile.getFullPath()}));
        targetFile.setContents(contents,true,true,new SubProgressMonitor(subProgressMonitor,1));
      }
 else {
        needRebuild=false;
      }
    }
    if (needRebuild || jetEmitter.method == null) {
      subProgressMonitor.subTask(CodeGenPlugin.getPlugin().getString("String_Node_Str",new Object[]{project.getName()}));
      project.build(IncrementalProjectBuilder.INCREMENTAL_BUILD,new SubProgressMonitor(subProgressMonitor,1));
      IMarker[] markers=targetFile.findMarkers(IMarker.PROBLEM,true,IResource.DEPTH_INFINITE);
      boolean errors=false;
      for (int i=0; i < markers.length; ++i) {
        IMarker marker=markers[i];
        if (marker.getAttribute(IMarker.SEVERITY,IMarker.SEVERITY_INFO) == IMarker.SEVERITY_ERROR) {
          errors=true;
          subProgressMonitor.subTask(marker.getAttribute(IMarker.MESSAGE) + "String_Node_Str" + (CodeGenPlugin.getPlugin().getString("String_Node_Str",new Object[]{targetFile.getLocation(),marker.getAttribute(IMarker.LINE_NUMBER)})));
          log.error(jetEmitter.templateURI.substring(jetEmitter.templateURI.lastIndexOf("String_Node_Str") + 1) + Messages.getString("String_Node_Str",marker.getAttribute(IMarker.MESSAGE),(CodeGenPlugin.getPlugin().getString("String_Node_Str",new Object[]{targetFile.getLocation(),marker.getAttribute(IMarker.LINE_NUMBER)}))));
          classAvailable=false;
        }
      }
      if (!errors) {
        subProgressMonitor.subTask(CodeGenPlugin.getPlugin().getString("String_Node_Str",new Object[]{jetCompiler.getSkeleton().getClassName() + "String_Node_Str"}));
        URL url=new File(project.getLocation() + "String_Node_Str" + javaProject.getOutputLocation().removeFirstSegments(1)+ "String_Node_Str").toURL();
        URLClassLoader theClassLoader=new URLClassLoader(new URL[]{url},jetEmitter.classLoader);
        Class theClass=theClassLoader.loadClass((packageName.length() == 0 ? "String_Node_Str" : packageName + "String_Node_Str") + jetCompiler.getSkeleton().getClassName());
        String methodName=jetCompiler.getSkeleton().getMethodName();
        Method[] methods=theClass.getDeclaredMethods();
        for (int i=0; i < methods.length; ++i) {
          if (methods[i].getName().equals(methodName)) {
            jetEmitter.setMethod(methods[i]);
            break;
          }
        }
      }
    }
    subProgressMonitor.done();
  }
 catch (  CoreException exception) {
    TalendDebugHandler.debug(exception);
    throw new JETException(Messages.getString("String_Node_Str") + templateName + codePart+ templateLanguage,exception);
  }
catch (  Exception exception) {
    TalendDebugHandler.debug(exception);
    throw new JETException(Messages.getString("String_Node_Str") + templateName + codePart+ templateLanguage,exception);
  }
 finally {
    try {
      contents.close();
    }
 catch (    Exception e) {
    }
    try {
      outputStream.close();
    }
 catch (    Exception e) {
    }
    progressMonitor.done();
  }
}

Fixed version (ground truth):
public void initialize(Monitor monitor,TalendJetEmitter jetEmitter,String componentFamily,String templateName,String templateLanguage,String codePart) throws JETException {
  IProgressMonitor progressMonitor=BasicMonitor.toIProgressMonitor(monitor);
  progressMonitor.beginTask("String_Node_Str",10);
  progressMonitor.subTask(CodeGenPlugin.getPlugin().getString("String_Node_Str",new Object[]{jetEmitter.templateURI}));
  ByteArrayOutputStream outputStream=null;
  InputStream contents=null;
  try {
    JETCompiler jetCompiler=null;
    if (jetEmitter.templateURIPath == null) {
      jetCompiler=new TalendJETCompiler(jetEmitter.templateURI,jetEmitter.encoding,jetEmitter.classLoader);
    }
 else {
      jetCompiler=new TalendJETCompiler(jetEmitter.templateURIPath,jetEmitter.templateURI,jetEmitter.encoding,jetEmitter.classLoader);
    }
    progressMonitor.subTask(CodeGenPlugin.getPlugin().getString("String_Node_Str",new Object[]{jetCompiler.getResolvedTemplateURI()}));
    jetCompiler.parse();
    jetCompiler.getSkeleton().setPackageName("String_Node_Str" + componentFamily);
    jetCompiler.getSkeleton().setClassName(templateName + codePart + templateLanguage);
    progressMonitor.worked(1);
    outputStream=new ByteArrayOutputStream();
    jetCompiler.generate(outputStream);
    contents=new ByteArrayInputStream(outputStream.toByteArray());
    progressMonitor.subTask(CodeGenPlugin.getPlugin().getString("String_Node_Str",new Object[]{project.getName()}));
    String packageName=jetCompiler.getSkeleton().getPackageName();
    StringTokenizer stringTokenizer=new StringTokenizer(packageName,"String_Node_Str");
    IProgressMonitor subProgressMonitor=new SubProgressMonitor(progressMonitor,1);
    subProgressMonitor.beginTask("String_Node_Str",stringTokenizer.countTokens() + 4);
    subProgressMonitor.subTask(CodeGenPlugin.getPlugin().getString("String_Node_Str"));
    IFolder sourceContainer=project.getFolder("String_Node_Str");
    while (stringTokenizer.hasMoreElements()) {
      String folderName=stringTokenizer.nextToken();
      sourceContainer=sourceContainer.getFolder(new Path(folderName));
      if (!sourceContainer.exists()) {
        try {
          sourceContainer.create(true,true,new SubProgressMonitor(subProgressMonitor,1));
        }
 catch (        Exception e) {
          ExceptionHandler.process(e);
        }
      }
    }
    boolean needRebuild=true;
    IFile targetFile=sourceContainer.getFile(new Path(jetCompiler.getSkeleton().getClassName() + "String_Node_Str"));
    if (!targetFile.exists()) {
      subProgressMonitor.subTask(CodeGenPlugin.getPlugin().getString("String_Node_Str",new Object[]{targetFile.getFullPath()}));
      targetFile.create(contents,true,new SubProgressMonitor(subProgressMonitor,1));
    }
 else {
      ByteArrayOutputStream baos=new ByteArrayOutputStream();
      DataInputStream dis=new DataInputStream(targetFile.getContents());
      int len=0;
      byte[] buf=new byte[1024];
      while (((len=dis.read(buf))) != -1) {
        baos.write(buf,0,len);
      }
      dis.close();
      String currentContent=baos.toString();
      String newContent=outputStream.toString();
      currentContent=currentContent.replace("String_Node_Str","String_Node_Str");
      newContent=newContent.replace("String_Node_Str","String_Node_Str");
      if (!newContent.equals(currentContent)) {
        subProgressMonitor.subTask(CodeGenPlugin.getPlugin().getString("String_Node_Str",new Object[]{targetFile.getFullPath()}));
        targetFile.setContents(contents,true,true,new SubProgressMonitor(subProgressMonitor,1));
      }
 else {
        needRebuild=false;
      }
    }
    if (needRebuild || jetEmitter.method == null) {
      subProgressMonitor.subTask(CodeGenPlugin.getPlugin().getString("String_Node_Str",new Object[]{project.getName()}));
      project.build(IncrementalProjectBuilder.INCREMENTAL_BUILD,new SubProgressMonitor(subProgressMonitor,1));
      IMarker[] markers=targetFile.findMarkers(IMarker.PROBLEM,true,IResource.DEPTH_INFINITE);
      boolean errors=false;
      for (int i=0; i < markers.length; ++i) {
        IMarker marker=markers[i];
        if (marker.getAttribute(IMarker.SEVERITY,IMarker.SEVERITY_INFO) == IMarker.SEVERITY_ERROR) {
          errors=true;
          subProgressMonitor.subTask(marker.getAttribute(IMarker.MESSAGE) + "String_Node_Str" + (CodeGenPlugin.getPlugin().getString("String_Node_Str",new Object[]{targetFile.getLocation(),marker.getAttribute(IMarker.LINE_NUMBER)})));
          log.error(jetEmitter.templateURI.substring(jetEmitter.templateURI.lastIndexOf("String_Node_Str") + 1) + Messages.getString("String_Node_Str",marker.getAttribute(IMarker.MESSAGE),(CodeGenPlugin.getPlugin().getString("String_Node_Str",new Object[]{targetFile.getLocation(),marker.getAttribute(IMarker.LINE_NUMBER)}))));
          setClassAvailable(false);
        }
      }
      if (!errors) {
        subProgressMonitor.subTask(CodeGenPlugin.getPlugin().getString("String_Node_Str",new Object[]{jetCompiler.getSkeleton().getClassName() + "String_Node_Str"}));
        URL url=new File(project.getLocation() + "String_Node_Str" + javaProject.getOutputLocation().removeFirstSegments(1)+ "String_Node_Str").toURL();
        URLClassLoader theClassLoader=new URLClassLoader(new URL[]{url},jetEmitter.classLoader);
        Class theClass=theClassLoader.loadClass((packageName.length() == 0 ? "String_Node_Str" : packageName + "String_Node_Str") + jetCompiler.getSkeleton().getClassName());
        String methodName=jetCompiler.getSkeleton().getMethodName();
        Method[] methods=theClass.getDeclaredMethods();
        for (int i=0; i < methods.length; ++i) {
          if (methods[i].getName().equals(methodName)) {
            jetEmitter.setMethod(methods[i]);
            break;
          }
        }
      }
    }
    subProgressMonitor.done();
  }
 catch (  CoreException exception) {
    TalendDebugHandler.debug(exception);
    throw new JETException(Messages.getString("String_Node_Str") + templateName + codePart+ templateLanguage,exception);
  }
catch (  Exception exception) {
    TalendDebugHandler.debug(exception);
    throw new JETException(Messages.getString("String_Node_Str") + templateName + codePart+ templateLanguage,exception);
  }
 finally {
    try {
      contents.close();
    }
 catch (    Exception e) {
    }
    try {
      outputStream.close();
    }
 catch (    Exception e) {
    }
    progressMonitor.done();
  }
}