Program: 15525
Project: 15525
Buggy source:
private Template loadTemplate(final TemplateLoader templateLoader,final Object source,final String name,final String sourceName,Locale locale,final Object customLookupCondition,String initialEncoding,final boolean parseAsFTL) throws IOException {
  final TemplateConfigurer tc;
  try {
    tc=templateConfigurers != null ? templateConfigurers.get(sourceName,source) : null;
  }
 catch (  TemplateConfigurerFactoryException e) {
    throw newIOException("String_Node_Str",e);
  }
  if (tc != null) {
    tc.setParentConfiguration(config);
    if (tc.isEncodingSet()) {
      initialEncoding=tc.getEncoding();
    }
    if (tc.isLocaleSet()) {
      locale=tc.getLocale();
    }
  }
  Template template;
{
    if (parseAsFTL) {
      try {
        final Reader reader=templateLoader.getReader(source,initialEncoding);
        try {
          template=new Template(name,sourceName,reader,config,tc,initialEncoding);
        }
  finally {
          reader.close();
        }
      }
 catch (      Template.WrongEncodingException wee) {
        String actualEncoding=wee.getTemplateSpecifiedEncoding();
        if (LOG.isDebugEnabled()) {
          LOG.debug("String_Node_Str" + initialEncoding + "String_Node_Str"+ actualEncoding+ "String_Node_Str"+ sourceName);
        }
        final Reader reader=templateLoader.getReader(source,actualEncoding);
        try {
          template=new Template(name,sourceName,reader,config,tc,actualEncoding);
        }
  finally {
          reader.close();
        }
      }
    }
 else {
      final StringWriter sw=new StringWriter();
      final char[] buf=new char[4096];
      final Reader reader=templateLoader.getReader(source,initialEncoding);
      try {
        fetchChars:         while (true) {
          int charsRead=reader.read(buf);
          if (charsRead > 0) {
            sw.write(buf,0,charsRead);
          }
 else           if (charsRead < 0) {
            break fetchChars;
          }
        }
      }
  finally {
        reader.close();
      }
      template=Template.getPlainTextTemplate(name,sourceName,sw.toString(),config);
      template.setEncoding(initialEncoding);
    }
  }
  if (tc != null) {
    tc.configure(template);
  }
  template.setLocale(locale);
  template.setCustomLookupCondition(customLookupCondition);
  return template;
}

Fixed version (ground truth):
private Template loadTemplate(final TemplateLoader templateLoader,final Object source,final String name,final String sourceName,Locale locale,final Object customLookupCondition,String initialEncoding,final boolean parseAsFTL) throws IOException {
  final TemplateConfigurer tc;
  try {
    tc=templateConfigurers != null ? templateConfigurers.get(sourceName,source) : null;
  }
 catch (  TemplateConfigurerFactoryException e) {
    throw newIOException("String_Node_Str",e);
  }
  if (tc != null) {
    if (tc.isEncodingSet()) {
      initialEncoding=tc.getEncoding();
    }
    if (tc.isLocaleSet()) {
      locale=tc.getLocale();
    }
  }
  Template template;
{
    if (parseAsFTL) {
      try {
        final Reader reader=templateLoader.getReader(source,initialEncoding);
        try {
          template=new Template(name,sourceName,reader,config,tc,initialEncoding);
        }
  finally {
          reader.close();
        }
      }
 catch (      Template.WrongEncodingException wee) {
        String actualEncoding=wee.getTemplateSpecifiedEncoding();
        if (LOG.isDebugEnabled()) {
          LOG.debug("String_Node_Str" + initialEncoding + "String_Node_Str"+ actualEncoding+ "String_Node_Str"+ sourceName);
        }
        final Reader reader=templateLoader.getReader(source,actualEncoding);
        try {
          template=new Template(name,sourceName,reader,config,tc,actualEncoding);
        }
  finally {
          reader.close();
        }
      }
    }
 else {
      final StringWriter sw=new StringWriter();
      final char[] buf=new char[4096];
      final Reader reader=templateLoader.getReader(source,initialEncoding);
      try {
        fetchChars:         while (true) {
          int charsRead=reader.read(buf);
          if (charsRead > 0) {
            sw.write(buf,0,charsRead);
          }
 else           if (charsRead < 0) {
            break fetchChars;
          }
        }
      }
  finally {
        reader.close();
      }
      template=Template.getPlainTextTemplate(name,sourceName,sw.toString(),config);
      template.setEncoding(initialEncoding);
    }
  }
  if (tc != null) {
    tc.configure(template);
  }
  template.setLocale(locale);
  template.setCustomLookupCondition(customLookupCondition);
  return template;
}