Buggy code:
public class TemplateCache { private static final String ASTERISKSTR = "*" ; private static final char ASTERISK = '*' ; private static final char SLASH = '//' ; private static final String LOCALE_PART_SEPARATOR = "_" ; private static final Logger LOG = Logger . getLogger ( "freemarker.cache" ) ; private final TemplateLoader templateLoader ; private final CacheStorage storage ; private final TemplateLookupStrategy templateLookupStrategy ; private final TemplateNameFormat templateNameFormat ; private final boolean isStorageConcurrent ; private long delay = 5000 ; private boolean localizedLookup = true ; private Configuration config ; public TemplateCache ( ) { } public TemplateCache ( TemplateLoader templateLoader ) { } public TemplateCache ( TemplateLoader templateLoader , CacheStorage cacheStorage ) { } public TemplateCache ( TemplateLoader templateLoader , Configuration config ) { } public TemplateCache ( TemplateLoader templateLoader , CacheStorage cacheStorage , Configuration config ) { } public TemplateCache ( TemplateLoader templateLoader , CacheStorage cacheStorage , TemplateLookupStrategy templateLookupStrategy , TemplateNameFormat templateNameFormat , Configuration config ) { } public void setConfiguration ( Configuration config ) { } public TemplateLoader getTemplateLoader ( ) { } public CacheStorage getCacheStorage ( ) { } public TemplateLookupStrategy getTemplateLookupStrategy ( ) { } public TemplateNameFormat getTemplateNameFormat ( ) { } public TemplateCache . MaybeMissingTemplate getTemplate ( String name , Locale locale , Object customLookupCondition , String encoding , boolean parseAsFTL ) throws IOException { } public Template getTemplate ( String name , Locale locale , String encoding , boolean parseAsFTL ) throws IOException { } protected static TemplateLoader createLegacyDefaultTemplateLoader ( ) { } private Template getTemplate ( final TemplateLoader templateLoader , final String name , final Locale locale , final Object customLookupCondition , final String encoding , final boolean parseAsFTL ) throws IOException { } private static final Method INIT_CAUSE = TemplateCache . getInitCauseMethod ( ) ; private static final Method getInitCauseMethod ( ) { } private void throwLoadFailedException ( Exception e ) throws IOException { } private void storeNegativeLookup ( TemplateCache . TemplateKey tk , TemplateCache . CachedTemplate cachedTemplate , Exception e ) { } private void storeCached ( TemplateCache . TemplateKey tk , TemplateCache . CachedTemplate cachedTemplate ) { } private Template loadTemplate ( final TemplateLoader templateLoader , final Object source , final String name , final String sourceName , final Locale locale , final Object customLookupCondition , final String initialEncoding , final boolean parseAsFTL ) throws IOException { Template template ; String actualEncoding ; { if ( parseAsFTL ) { try { final Reader reader = templateLoader . getReader ( source , initialEncoding ) ; try { template = new Template ( name , sourceName , reader , config , initialEncoding ) ; } finally { reader . close ( ) ; } actualEncoding = initialEncoding ; } catch ( Template wee ) { actualEncoding = wee . getTemplateSpecifiedEncoding ( ) ; if ( TemplateCache . LOG . isDebugEnabled ( ) ) { TemplateCache . LOG . debug ( ( ( ( ( ( "Initial<seq2seq4repair_space>encoding<seq2seq4repair_space>\"" + initialEncoding ) + "\"<seq2seq4repair_space>was<seq2seq4repair_space>incorrect,<seq2seq4repair_space>re-reading<seq2seq4repair_space>with<seq2seq4repair_space>\"" ) + actualEncoding ) + "\".<seq2seq4repair_space>Template:<seq2seq4repair_space>" ) + sourceName ) ) ; } final Reader reader = templateLoader . getReader ( source , actualEncoding ) ; try { template = new Template ( name , sourceName , reader , config , 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 ( ) ; } <START_BUG> template = Template . getPlainTextTemplate ( name , sw . toString ( ) , config ) ; <END_BUG> actualEncoding = initialEncoding ; } } template . setLocale ( locale ) ; template . setCustomLookupCondition ( customLookupCondition ) ; template . setEncoding ( actualEncoding ) ; return template ; } public long getDelay ( ) { } public void setDelay ( long delay ) { } public boolean getLocalizedLookup ( ) { } public void setLocalizedLookup ( boolean localizedLookup ) { } public void clear ( ) { } public void removeTemplate ( String name , Locale locale , String encoding , boolean parse ) throws IOException { } public void removeTemplate ( String name , Locale locale , Object customLookupCondition , String encoding , boolean parse ) throws IOException { } private String buildDebugName ( String name , Locale locale , Object customLookupCondition , String encoding , boolean parse ) { } public static String getFullTemplatePath ( Environment env , String baseName , String targetName ) { } private TemplateLookupResult lookupTemplate ( String name , Locale locale , Object customLookupCondition ) throws IOException { } private TemplateLookupResult lookupTemplateWithAcquisitionStrategy ( String path ) throws IOException { } private Object findTemplateSourceAndLog ( String path ) throws IOException { } private Object modifyForConfIcI ( Object templateSource ) { } private String concatPath ( List path , int from , int to ) { } private static final class TemplateKey { private final String name ; private final Locale locale ; private final Object customLookupCondition ; private final String encoding ; private final boolean parse ; TemplateKey ( String name , Locale locale , Object customLookupCondition , String encoding , boolean parse ) { } public boolean equals ( Object o ) { } private boolean nullSafeEquals ( Object o1 , Object o2 ) { } public int hashCode ( ) { } } private static final class CachedTemplate implements Serializable , Cloneable { private static final long serialVersionUID = 1L ; Object templateOrException ; Object source ; long lastChecked ; long lastModified ; public TemplateCache . CachedTemplate cloneCachedTemplate ( ) { } }

Fix:
template = Template . getPlainTextTemplate ( name , sourceName , sw . toString ( ) , config ) ;