Program: 122839
Project: 122839
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()}));
    javaProject.open(new SubProgressMonitor(progressMonitor,1));
    IPackageFragmentRoot[] packageFragmentRoots=javaProject.getPackageFragmentRoots();
    IPackageFragmentRoot sourcePackageFragmentRoot=null;
    for (int j=0; j < packageFragmentRoots.length; ++j) {
      IPackageFragmentRoot packageFragmentRoot=packageFragmentRoots[j];
      if (packageFragmentRoot.getKind() == IPackageFragmentRoot.K_SOURCE) {
        sourcePackageFragmentRoot=packageFragmentRoot;
        break;
      }
    }
    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"));
    IContainer sourceContainer=(IContainer)sourcePackageFragmentRoot.getCorrespondingResource();
    while (stringTokenizer.hasMoreElements()) {
      String folderName=stringTokenizer.nextToken();
      sourceContainer=sourceContainer.getFolder(new Path(folderName));
      if (!sourceContainer.exists()) {
        try {
          ((IFolder)sourceContainer).create(true,true,new SubProgressMonitor(subProgressMonitor,1));
        }
 catch (        Exception e) {
          ExceptionHandler.process(e);
        }
      }
    }
    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 {
      subProgressMonitor.subTask(CodeGenPlugin.getPlugin().getString("String_Node_Str",new Object[]{targetFile.getFullPath()}));
      targetFile.setContents(contents,true,true,new SubProgressMonitor(subProgressMonitor,1));
    }
    subProgressMonitor.subTask(CodeGenPlugin.getPlugin().getString("String_Node_Str",new Object[]{project.getName()}));
    if (!ComponentCompilations.getMarkers()) {
      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)}))));
      }
    }
    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()}));
    IPackageFragmentRoot[] packageFragmentRoots=javaProject.getPackageFragmentRoots();
    IPackageFragmentRoot sourcePackageFragmentRoot=null;
    for (int j=0; j < packageFragmentRoots.length; ++j) {
      IPackageFragmentRoot packageFragmentRoot=packageFragmentRoots[j];
      if (packageFragmentRoot.getKind() == IPackageFragmentRoot.K_SOURCE) {
        sourcePackageFragmentRoot=packageFragmentRoot;
        break;
      }
    }
    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"));
    IContainer sourceContainer=(IContainer)sourcePackageFragmentRoot.getCorrespondingResource();
    while (stringTokenizer.hasMoreElements()) {
      String folderName=stringTokenizer.nextToken();
      sourceContainer=sourceContainer.getFolder(new Path(folderName));
      if (!sourceContainer.exists()) {
        try {
          ((IFolder)sourceContainer).create(true,true,new SubProgressMonitor(subProgressMonitor,1));
        }
 catch (        Exception e) {
          ExceptionHandler.process(e);
        }
      }
    }
    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 {
      subProgressMonitor.subTask(CodeGenPlugin.getPlugin().getString("String_Node_Str",new Object[]{targetFile.getFullPath()}));
      targetFile.setContents(contents,true,true,new SubProgressMonitor(subProgressMonitor,1));
    }
    subProgressMonitor.subTask(CodeGenPlugin.getPlugin().getString("String_Node_Str",new Object[]{project.getName()}));
    if (!ComponentCompilations.getMarkers()) {
      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)}))));
      }
    }
    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();
  }
}