nus-yam/ex-repair huggingface dataset:
Program: 15567
Project: 15567
Buggy source:
/** 
 * @param blamedAssignmentTargetVarName Used for assignments that use  {@code +=} and such, in which case the {@code blamed} expressionparameter will be null  {@code null} and this parameter will be non-{null}.
 */
private static _ErrorDescriptionBuilder newDesciptionBuilder(Expression blamed,String blamedAssignmentTargetVarName,TemplateModel model,String expectedTypesDesc,Class[] expectedTypes,Environment env) throws InvalidReferenceException {
  if (model == null)   throw InvalidReferenceException.getInstance(blamed,env);
  _ErrorDescriptionBuilder errorDescBuilder=new _ErrorDescriptionBuilder(unexpectedTypeErrorDescription(expectedTypesDesc,blamedAssignmentTargetVarName,model)).blame(blamed).showBlamer(true);
  if (model instanceof _UnexpectedTypeErrorExplainerTemplateModel) {
    Object[] tip=((_UnexpectedTypeErrorExplainerTemplateModel)model).explainTypeError(expectedTypes);
    if (tip != null) {
      errorDescBuilder.tip(tip);
    }
  }
  return errorDescBuilder;
}

Fixed version (ground truth):
/** 
 * @param blamedAssignmentTargetVarName Used for assignments that use  {@code +=} and such, in which case the {@code blamed} expressionparameter will be null  {@code null} and this parameter will be non-{null}.
 */
private static _ErrorDescriptionBuilder newDesciptionBuilder(Expression blamed,String blamedAssignmentTargetVarName,TemplateModel model,String expectedTypesDesc,Class[] expectedTypes,Environment env) throws InvalidReferenceException {
  if (model == null)   throw InvalidReferenceException.getInstance(blamed,env);
  _ErrorDescriptionBuilder errorDescBuilder=new _ErrorDescriptionBuilder(unexpectedTypeErrorDescription(expectedTypesDesc,blamed,blamedAssignmentTargetVarName,model)).blame(blamed).showBlamer(true);
  if (model instanceof _UnexpectedTypeErrorExplainerTemplateModel) {
    Object[] tip=((_UnexpectedTypeErrorExplainerTemplateModel)model).explainTypeError(expectedTypes);
    if (tip != null) {
      errorDescBuilder.tip(tip);
    }
  }
  return errorDescBuilder;
}
Program: 15568
Project: 15568
Buggy source:
protected final Expression deepCloneWithIdentifierReplaced_inner(String replacedIdentifier,Expression replacement,ReplacemenetState replacementState){
  try {
    BuiltIn clone=(BuiltIn)clone();
    clone.target=target.deepCloneWithIdentifierReplaced(replacedIdentifier,replacement,replacementState);
    return clone;
  }
 catch (  CloneNotSupportedException e) {
    throw new RuntimeException("String_Node_Str" + e);
  }
}

Fixed version (ground truth):
protected Expression deepCloneWithIdentifierReplaced_inner(String replacedIdentifier,Expression replacement,ReplacemenetState replacementState){
  try {
    BuiltIn clone=(BuiltIn)clone();
    clone.target=target.deepCloneWithIdentifierReplaced(replacedIdentifier,replacement,replacementState);
    return clone;
  }
 catch (  CloneNotSupportedException e) {
    throw new RuntimeException("String_Node_Str" + e);
  }
}
Program: 15569
Project: 15569
Buggy source:
/** 
 * This should return an equivalent new expression object (or an identifier replacement expression). The position need not be filled, unless it will be different from the position of what were cloning. 
 */
protected abstract Expression deepCloneWithIdentifierReplaced_inner(String replacedIdentifier,Expression replacement,ReplacemenetState replacementState);

Fixed version (ground truth):
/** 
 * This should return an equivalent new expression object (or an identifier replacement expression). The position need not be filled, unless it will be different from the position of what we were cloning. 
 */
protected abstract Expression deepCloneWithIdentifierReplaced_inner(String replacedIdentifier,Expression replacement,ReplacemenetState replacementState);
Program: 15570
Project: 15570
Buggy source:
void loopForItemsElement(Environment env,TemplateElement nestedBlock,String loopVarName) throws NonSequenceOrCollectionException, TemplateModelException, InvalidReferenceException, TemplateException, IOException {
  try {
    if (index == ITEMS_ELEMENT_EXECUTED_MARKER) {
      throw new _MiscTemplateException(env,"String_Node_Str");
    }
    this.loopVarName=loopVarName;
    executeNestedBlock(env,nestedBlock);
  }
  finally {
    this.loopVarName=null;
    index=ITEMS_ELEMENT_EXECUTED_MARKER;
  }
}

Fixed version (ground truth):
void loopForItemsElement(Environment env,TemplateElement nestedBlock,String loopVarName) throws NonSequenceOrCollectionException, TemplateModelException, InvalidReferenceException, TemplateException, IOException {
  try {
    if (alreadyEntered) {
      throw new _MiscTemplateException(env,"String_Node_Str");
    }
    alreadyEntered=true;
    this.loopVarName=loopVarName;
    executeNestedBlock(env,nestedBlock);
  }
  finally {
    this.loopVarName=null;
  }
}
Program: 15571
Project: 15571
Buggy source:
public void close() throws IOException {
  if (lineBuf.length() > 0) {
    lines.add(lineBuf.toString());
    lineBuf.setLength(0);
  }
  super.close();
}

Fixed version (ground truth):
public void close() throws IOException {
  if (lineBuf.length() > 0) {
    lines.add(lineBuf.toString());
    lineBuf.setLength(0);
  }
  super.close();
  closed=true;
}
Program: 15572
Project: 15572
Buggy source:
public int read(char cbuf[],int off,int len) throws IOException {
  int numchars=in.read(cbuf,off,len);
  for (int i=off; i < off + numchars; i++) {
    char c=cbuf[i];
    handleChar(c);
  }
  return numchars;
}

Fixed version (ground truth):
public int read(char cbuf[],int off,int len) throws IOException {
  try {
    int numchars=in.read(cbuf,off,len);
    for (int i=off; i < off + numchars; i++) {
      char c=cbuf[i];
      handleChar(c);
    }
    return numchars;
  }
 catch (  IOException e) {
    throw rememberException(e);
  }
}
Program: 15574
Project: 15574
Buggy source:
/** 
 * Returns a trivial template, one that is just a single block of plain text, no dynamic content. (Used by the cache module to create unparsed templates.)
 * @param name the path of the template file relative to the directory what you use to storethe templates. See  {@link #getName} for more details.
 * @param content the block of text that this template represents
 * @param config the configuration to which this template belongs
 */
static public Template getPlainTextTemplate(String name,String content,Configuration config){
  Template template=new Template(name,null,config,true);
  template.rootElement=new TextBlock(content);
  template.actualTagSyntax=config.getTagSyntax();
  DebuggerService.registerTemplate(template);
  return template;
}

Fixed version (ground truth):
/** 
 * Creates a   {@link Template} that only contains a single block of static text, no dynamic content.
 * @param name See  {@link #getName} for more details.
 * @param sourceName See  {@link #getSourceName} for more details. If {@code null}, it will be the same as the   {@code name}.
 * @param content the block of text that this template represents
 * @param config the configuration to which this template belongs
 * @since 2.3.22
 */
static public Template getPlainTextTemplate(String name,String sourceName,String content,Configuration config){
  Template template=new Template(name,sourceName,config,true);
  template.rootElement=new TextBlock(content);
  template.actualTagSyntax=config.getTagSyntax();
  DebuggerService.registerTemplate(template);
  return template;
}
Program: 15575
Project: 15575
Buggy source:
protected String dump(boolean canonical){
  StringBuffer sb=new StringBuffer();
  if (canonical)   sb.append('<');
  sb.append('@');
  MessageUtil.appendExpressionAsUntearable(sb,nameExp);
  boolean nameIsInParen=sb.charAt(sb.length() - 1) == ')';
  if (positionalArgs != null) {
    for (int i=0; i < positionalArgs.size(); i++) {
      Expression argExp=(Expression)positionalArgs.get(i);
      if (i != 0) {
        sb.append(',');
      }
      sb.append(' ');
      sb.append(argExp.getCanonicalForm());
    }
  }
 else {
    List entries=getSortedNamedArgs();
    for (int i=0; i < entries.size(); i++) {
      Map.Entry entry=(Map.Entry)entries.get(i);
      Expression argExp=(Expression)entry.getValue();
      sb.append(' ');
      sb.append(CoreUtils.toFTLTopLevelIdentifierReference((String)entry.getKey()));
      sb.append('=');
      MessageUtil.appendExpressionAsUntearable(sb,argExp);
    }
  }
  if (canonical) {
    if (nestedBlock == null) {
      sb.append("String_Node_Str");
    }
 else {
      sb.append('>');
      sb.append(nestedBlock.getCanonicalForm());
      sb.append("String_Node_Str");
      if (!nameIsInParen && (nameExp instanceof Identifier || (nameExp instanceof Dot && ((Dot)nameExp).onlyHasIdentifiers()))) {
        sb.append(nameExp.getCanonicalForm());
      }
      sb.append('>');
    }
  }
  return sb.toString();
}

Fixed version (ground truth):
protected String dump(boolean canonical){
  StringBuffer sb=new StringBuffer();
  if (canonical)   sb.append('<');
  sb.append('@');
  MessageUtil.appendExpressionAsUntearable(sb,nameExp);
  boolean nameIsInParen=sb.charAt(sb.length() - 1) == ')';
  if (positionalArgs != null) {
    for (int i=0; i < positionalArgs.size(); i++) {
      Expression argExp=(Expression)positionalArgs.get(i);
      if (i != 0) {
        sb.append(',');
      }
      sb.append(' ');
      sb.append(argExp.getCanonicalForm());
    }
  }
 else {
    List entries=getSortedNamedArgs();
    for (int i=0; i < entries.size(); i++) {
      Map.Entry entry=(Map.Entry)entries.get(i);
      Expression argExp=(Expression)entry.getValue();
      sb.append(' ');
      sb.append(CoreUtils.toFTLTopLevelIdentifierReference((String)entry.getKey()));
      sb.append('=');
      MessageUtil.appendExpressionAsUntearable(sb,argExp);
    }
  }
  if (bodyParameterNames != null && !bodyParameterNames.isEmpty()) {
    sb.append("String_Node_Str");
    for (int i=0; i < bodyParameterNames.size(); i++) {
      if (i != 0) {
        sb.append("String_Node_Str");
      }
      sb.append(CoreUtils.toFTLTopLevelIdentifierReference((String)bodyParameterNames.get(i)));
    }
  }
  if (canonical) {
    if (nestedBlock == null) {
      sb.append("String_Node_Str");
    }
 else {
      sb.append('>');
      sb.append(nestedBlock.getCanonicalForm());
      sb.append("String_Node_Str");
      if (!nameIsInParen && (nameExp instanceof Identifier || (nameExp instanceof Dot && ((Dot)nameExp).onlyHasIdentifiers()))) {
        sb.append(nameExp.getCanonicalForm());
      }
      sb.append('>');
    }
  }
  return sb.toString();
}
Program: 15577
Project: 15577
Buggy source:
private Template loadTemplate(TemplateLoader loader,String name,Locale locale,String encoding,boolean parse,Object source) throws IOException {
  Template template;
  Reader reader=loader.getReader(source,encoding);
  try {
    if (parse) {
      try {
        template=new Template(name,reader,config,encoding);
      }
 catch (      Template.WrongEncodingException wee) {
        encoding=wee.specifiedEncoding;
        reader.close();
        reader=loader.getReader(source,encoding);
        template=new Template(name,reader,config,encoding);
      }
      template.setLocale(locale);
    }
 else {
      StringWriter sw=new StringWriter();
      char[] buf=new char[4096];
      for (; ; ) {
        int charsRead=reader.read(buf);
        if (charsRead > 0) {
          sw.write(buf,0,charsRead);
        }
 else         if (charsRead == -1) {
          break;
        }
      }
      template=Template.getPlainTextTemplate(name,sw.toString(),config);
      template.setLocale(locale);
    }
    template.setEncoding(encoding);
  }
  finally {
    reader.close();
  }
  return template;
}

Fixed version (ground truth):
private Template loadTemplate(TemplateLoader loader,String name,String sourceName,Locale locale,String encoding,boolean parse,Object source) throws IOException {
  Template template;
  Reader reader=loader.getReader(source,encoding);
  try {
    if (parse) {
      try {
        template=new Template(name,sourceName,reader,config,encoding);
      }
 catch (      Template.WrongEncodingException wee) {
        encoding=wee.specifiedEncoding;
        reader.close();
        reader=loader.getReader(source,encoding);
        template=new Template(name,sourceName,reader,config,encoding);
      }
      template.setLocale(locale);
    }
 else {
      StringWriter sw=new StringWriter();
      char[] buf=new char[4096];
      for (; ; ) {
        int charsRead=reader.read(buf);
        if (charsRead > 0) {
          sw.write(buf,0,charsRead);
        }
 else         if (charsRead == -1) {
          break;
        }
      }
      template=Template.getPlainTextTemplate(name,sw.toString(),config);
      template.setLocale(locale);
    }
    template.setEncoding(encoding);
  }
  finally {
    reader.close();
  }
  return template;
}
Program: 15578
Project: 15578
Buggy source:
/** 
 * Closes the template source. This is the last method that is called by the   {@link TemplateCache} for a template source. {@link TemplateCache} ensures thatthis method will be called on every object that is returned from {@link #findTemplateSource(String)}.
 * @param templateSource the template source that should be closed.
 */
public void closeTemplateSource(Object templateSource) throws IOException ;

Fixed version (ground truth):
/** 
 * Closes the template source. This is the last method that is called by the   {@link TemplateCache} for a templatesource, except that  {@link Object#equals(Object)} is might called later too. {@link TemplateCache} ensures thatthis method will be called on every object that is returned from  {@link #findTemplateSource(String)}.
 * @param templateSource the template source that should be closed.
 */
public void closeTemplateSource(Object templateSource) throws IOException ;
Program: 15580
Project: 15580
Buggy source:
/** 
 * Setis if localized template lookup is enabled or not.
 */
public void setLocalizedLookup(boolean localizedLookup){
synchronized (this) {
    this.localizedLookup=localizedLookup;
  }
}

Fixed version (ground truth):
/** 
 * Setis if localized template lookup is enabled or not.
 */
public void setLocalizedLookup(boolean localizedLookup){
synchronized (this) {
    if (this.localizedLookup != localizedLookup) {
      this.localizedLookup=localizedLookup;
      clear();
    }
  }
}
Program: 15581
Project: 15581
Buggy source:
/** 
 * Enables/disables localized template lookup. Enabled by default. <p> With the default   {@link TemplateLookupStrategy}, localized lookup works like this: Let's say your locale setting is   {@code Locale("en", "AU")}, and you call   {@link Configuration#getTemplate(String) cfg.getTemplate("foo.ftl")}. Then FreeMarker will look for the template under these names, stopping at the first that exists:  {@code "foo_en_AU.ftl"},   {@code "foo_en.ftl"},   {@code "foo.ftl"}. See the description of the default value at  {@link #setTemplateLookupStrategy(TemplateLookupStrategy)} for a more details. If you need to generate differenttemplate names, use  {@link #setTemplateLookupStrategy(TemplateLookupStrategy)} with your custom{@link TemplateLookupStrategy}. <p> Historical note: Despite what the API documentation said earlier, this method is <em>not</em> thread-safe. While setting it can't cause any serious problems, and in fact it works well on most hardware, it's not guaranteed that FreeMarker will see the update in all threads.
 */
public void setLocalizedLookup(boolean localizedLookup){
  this.localizedLookup=localizedLookup;
  cache.setLocalizedLookup(localizedLookup);
}

Fixed version (ground truth):
/** 
 * Enables/disables localized template lookup. Enabled by default. <p> With the default   {@link TemplateLookupStrategy}, localized lookup works like this: Let's say your locale setting is   {@code Locale("en", "AU")}, and you call   {@link Configuration#getTemplate(String) cfg.getTemplate("foo.ftl")}. Then FreeMarker will look for the template under these names, stopping at the first that exists:  {@code "foo_en_AU.ftl"},   {@code "foo_en.ftl"},   {@code "foo.ftl"}. See the description of the default value at  {@link #setTemplateLookupStrategy(TemplateLookupStrategy)} for a more details. If you need to generate differenttemplate names, use  {@link #setTemplateLookupStrategy(TemplateLookupStrategy)} with your custom{@link TemplateLookupStrategy}. <p>Note that changing the value of this setting causes the template cache to be emptied so that old lookup results won't be reused (since 2.3.22).  <p> Historical note: Despite what the API documentation said earlier, this method is <em>not</em> thread-safe. While setting it can't cause any serious problems, and in fact it works well on most hardware, it's not guaranteed that FreeMarker will see the update in all threads.
 */
public void setLocalizedLookup(boolean localizedLookup){
  this.localizedLookup=localizedLookup;
  cache.setLocalizedLookup(localizedLookup);
}
Program: 15584
Project: 15584
Buggy source:
/** 
 * Don't override this method to adjust FreeMarker settings! Override the protected methods for that, such as  {@link #createTemplateLoader(String)},   {@link #createObjectWrapper()}. Also note that lot of things can be changed with init-params instead of overriding methods.
 */
public void init() throws ServletException {
  try {
    initialize();
  }
 catch (  Exception e) {
    throw new ServletException("String_Node_Str" + this.getClass().getName() + "String_Node_Str",e);
  }
}

Fixed version (ground truth):
/** 
 * Don't override this method to adjust FreeMarker settings! Override the protected methods for that, such as  {@link #createConfiguration()},   {@link #createTemplateLoader(String)},   {@link #createDefaultObjectWrapper()}, etc. Also note that lot of things can be changed with init-params instead of overriding methods, so if you override settings, usually you should only override their defaults.
 */
public void init() throws ServletException {
  try {
    initialize();
  }
 catch (  Exception e) {
    throw new ServletException("String_Node_Str" + this.getClass().getName() + "String_Node_Str",e);
  }
}
Program: 15585
Project: 15585
Buggy source:
/** 
 * Override this to specify what the default   {@link ObjectWrapper} will be when the{@code object_wrapper} Servlet init-param wasn't specified. Note that this is called by{@link #createConfiguration()}, and so if that was also overidden but improperly then this method might won't be ever called. <p> The default implementation calls   {@link Configuration#getDefaultObjectWrapper(freemarker.template.Version)}. You should also pass in the version paramter when creating an   {@link ObjectWrapper} that supports that. You can getthe version by calling  {@link #getConfiguration()} and then {@link Configuration#getIncompatibleImprovements()}.
 * @since 2.3.22
 */
protected ObjectWrapper createDefaultObjectWrapper(){
  return Configuration.getDefaultObjectWrapper(config.getIncompatibleImprovements());
}

Fixed version (ground truth):
/** 
 * Override this to specify what the default   {@link ObjectWrapper} will be when the{@code object_wrapper} Servlet init-param wasn't specified. Note that this is called by{@link #createConfiguration()}, and so if that was also overidden but improperly then this method might won't be ever called. Also note that if you set the   {@code object_wrapper} in {@link #createConfiguration()}, then this won't be called, since then that has already specified the default. <p> The default implementation calls   {@link Configuration#getDefaultObjectWrapper(freemarker.template.Version)}. You should also pass in the version paramter when creating an   {@link ObjectWrapper} that supports that. You can getthe version by calling  {@link #getConfiguration()} and then {@link Configuration#getIncompatibleImprovements()}.
 * @since 2.3.22
 */
protected ObjectWrapper createDefaultObjectWrapper(){
  return Configuration.getDefaultObjectWrapper(config.getIncompatibleImprovements());
}
Program: 15586
Project: 15586
Buggy source:
protected final String getTemplatePath(){
  return templatePath;
}

Fixed version (ground truth):
/** 
 * {@code null} if the {@code template_loader} setting was set in a custom {@link #createConfiguration()}. 
 */
protected final String getTemplatePath(){
  return templatePath;
}
Program: 15587
Project: 15587
Buggy source:
/** 
 * This method is called from   {@link #init()} to create theFreeMarker configuration object that this servlet will use for template loading. This is a hook that allows you to custom-configure the configuration object in a subclass. The default implementation returns a new  {@link Configuration}instance.
 */
protected Configuration createConfiguration(){
  return new Configuration();
}

Fixed version (ground truth):
/** 
 * Creates the FreeMarker   {@link Configuration} singleton and (when overidden) maybe sets its defaults. Servletinit-params will be applied later, and thus can overwrite the settings specified here. <p> By overriding this method you can set your preferred  {@link Configuration} setting defaults, as only the settingsfor which an init-param was specified will be overwritten later. (Note that  {@link FreemarkerServlet} also hasits own defaults for a few settings, but since 2.3.22, the servlet detects if those settings were already set here and then it won't overwrite them.) <p> The default implementation simply creates a new instance with  {@link Configuration#Configuration()} and returnsit.
 */
protected Configuration createConfiguration(){
  return new Configuration();
}
Program: 15589
Project: 15589
Buggy source:
public void setObjectWrapper(ObjectWrapper objectWrapper){
  ObjectWrapper prevObjectWrapper=getObjectWrapper();
  super.setObjectWrapper(objectWrapper);
  objectWrapperWasSet=true;
  if (objectWrapper != prevObjectWrapper) {
    try {
      setSharedVariablesFromRewrappableSharedVariables();
    }
 catch (    TemplateModelException e) {
      throw new RuntimeException("String_Node_Str",e);
    }
  }
}

Fixed version (ground truth):
public void setObjectWrapper(ObjectWrapper objectWrapper){
  ObjectWrapper prevObjectWrapper=getObjectWrapper();
  super.setObjectWrapper(objectWrapper);
  objectWrapperExplicitlySet=true;
  if (objectWrapper != prevObjectWrapper) {
    try {
      setSharedVariablesFromRewrappableSharedVariables();
    }
 catch (    TemplateModelException e) {
      throw new RuntimeException("String_Node_Str",e);
    }
  }
}
Program: 15590
Project: 15590
Buggy source:
/** 
 * Sets a   {@link TemplateLoader} that is used to look up and load templates;as a side effect the template cache will be emptied. By providing your own  {@link TemplateLoader} implementation, you can load templates from whatever kind ofstorages, like from relational databases, NoSQL-storages, etc. <p>Convenience methods exists to install commonly used loaders, instead of using this method: {@link #setClassForTemplateLoading(Class,String)},   {@link #setDirectoryForTemplateLoading(File)}, and  {@link #setServletContextForTemplateLoading(Object,String)}. <p>You can chain several   {@link TemplateLoader}-s together with   {@link MultiTemplateLoader}. <p>Default value: You should always set the template loader instead of relying on the default value. (But if you still care what it is, before "incompatible improvements" 2.3.21 it's a   {@link FileTemplateLoader}that uses the current directory as its root; as it's hard tell what that directory will be, it's not very useful and dangerous. Starting with "incompatible improvements" 2.3.21 the default is   {@code null}.)    <p>Note that setting the template loader will re-create the template cache, so all its content will be lost.
 */
public void setTemplateLoader(TemplateLoader templateLoader){
synchronized (this) {
    if (cache.getTemplateLoader() != templateLoader) {
      recreateTemplateCacheWith(templateLoader,cache.getCacheStorage());
      templateLoaderWasSet=true;
    }
  }
}

Fixed version (ground truth):
/** 
 * Sets a   {@link TemplateLoader} that is used to look up and load templates;as a side effect the template cache will be emptied. By providing your own  {@link TemplateLoader} implementation, you can load templates from whatever kind ofstorages, like from relational databases, NoSQL-storages, etc. <p>Convenience methods exists to install commonly used loaders, instead of using this method: {@link #setClassForTemplateLoading(Class,String)},   {@link #setDirectoryForTemplateLoading(File)}, and  {@link #setServletContextForTemplateLoading(Object,String)}. <p>You can chain several   {@link TemplateLoader}-s together with   {@link MultiTemplateLoader}. <p>Default value: You should always set the template loader instead of relying on the default value. (But if you still care what it is, before "incompatible improvements" 2.3.21 it's a   {@link FileTemplateLoader}that uses the current directory as its root; as it's hard tell what that directory will be, it's not very useful and dangerous. Starting with "incompatible improvements" 2.3.21 the default is   {@code null}.)    <p>Note that setting the template loader will re-create the template cache, so all its content will be lost.
 */
public void setTemplateLoader(TemplateLoader templateLoader){
synchronized (this) {
    if (cache.getTemplateLoader() != templateLoader) {
      recreateTemplateCacheWith(templateLoader,cache.getCacheStorage());
    }
    templateLoaderExplicitlySet=true;
  }
}
Program: 15591
Project: 15591
Buggy source:
/** 
 * Use   {@link #Configuration(Version)} instead if possible; see the meaning of the parameter there.If the default value of a setting depends on the  {@code incompatibleImprovements} and the value of that settingwas never set in this  {@link Configuration} object through the public API, its value will be set to the defaultvalue appropriate for the new  {@code incompatibleImprovements}. (This adjustment of a setting value doesn't count as setting that setting, so setting   {@code incompatibleImprovements} for multiple times also works asexpected.) Note that if the  {@code template_loader} have to be changed because of this, the template cache willbe emptied.
 * @throws IllegalArgumentException if {@code incompatibleImmprovements} is greater than the current FreeMarkerversion, or less than 2.3.0, or  {@code null}.
 * @since 2.3.20
 */
public void setIncompatibleImprovements(Version incompatibleImprovements){
  _TemplateAPI.checkVersionNotNullAndSupported(incompatibleImprovements);
  boolean hadLegacyTLOWDefaults=this.incompatibleImprovements.intValue() < _TemplateAPI.VERSION_INT_2_3_21;
  this.incompatibleImprovements=incompatibleImprovements;
  if (hadLegacyTLOWDefaults != incompatibleImprovements.intValue() < _TemplateAPI.VERSION_INT_2_3_21) {
    if (!templateLoaderWasSet) {
      recreateTemplateCacheWith(getDefaultTemplateLoader(),cache.getCacheStorage());
    }
    if (!objectWrapperWasSet) {
      super.setObjectWrapper(getDefaultObjectWrapper(incompatibleImprovements));
    }
  }
}

Fixed version (ground truth):
/** 
 * Use   {@link #Configuration(Version)} instead if possible; see the meaning of the parameter there.If the default value of a setting depends on the  {@code incompatibleImprovements} and the value of that settingwas never set in this  {@link Configuration} object through the public API, its value will be set to the defaultvalue appropriate for the new  {@code incompatibleImprovements}. (This adjustment of a setting value doesn't count as setting that setting, so setting   {@code incompatibleImprovements} for multiple times also works asexpected.) Note that if the  {@code template_loader} have to be changed because of this, the template cache willbe emptied.
 * @throws IllegalArgumentException if {@code incompatibleImmprovements} is greater than the current FreeMarkerversion, or less than 2.3.0, or  {@code null}.
 * @since 2.3.20
 */
public void setIncompatibleImprovements(Version incompatibleImprovements){
  _TemplateAPI.checkVersionNotNullAndSupported(incompatibleImprovements);
  boolean hadLegacyTLOWDefaults=this.incompatibleImprovements.intValue() < _TemplateAPI.VERSION_INT_2_3_21;
  this.incompatibleImprovements=incompatibleImprovements;
  if (hadLegacyTLOWDefaults != incompatibleImprovements.intValue() < _TemplateAPI.VERSION_INT_2_3_21) {
    if (!templateLoaderExplicitlySet) {
      recreateTemplateCacheWith(getDefaultTemplateLoader(),cache.getCacheStorage());
    }
    if (!objectWrapperExplicitlySet) {
      super.setObjectWrapper(getDefaultObjectWrapper(incompatibleImprovements));
    }
  }
}
Program: 15593
Project: 15593
Buggy source:
/** 
 * Called for an object that aren't considered to be of a "basic" Java type, like for an application specific type, or for a W3C DOM node. In its default implementation, W3C   {@link Node}-s will be wrapped as   {@link NodeModel}-s (allows DOM tree traversal), Jython objects will be delegated to the   {@link JythonWrapper}, others will be wrapped using   {@link BeansWrapper#wrap(Object)}. <p> When you override this method, you should first decide if you want to wrap the object in a custom way (and if so then do it and return with the result), and if not, then you should call the super method (assuming the default behavior is fine with you).
 */
protected TemplateModel handleUnknownType(Object obj) throws TemplateModelException {
  if (obj instanceof Node) {
    return wrapDomNode(obj);
  }
  if (JYTHON_WRAPPER != null && JYTHON_OBJ_CLASS.isInstance(obj)) {
    return JYTHON_WRAPPER.wrap(obj);
  }
  return super.wrap(obj);
}

Fixed version (ground truth):
/** 
 * Called for an object that aren't considered to be of a "basic" Java type, like for an application specific type, or for a W3C DOM node. In its default implementation, W3C   {@link Node}-s will be wrapped as   {@link NodeModel}-s (allows DOM tree traversal), Jython objects will be delegated to the   {@code JythonWrapper}, others will be wrapped using   {@link BeansWrapper#wrap(Object)}. <p> When you override this method, you should first decide if you want to wrap the object in a custom way (and if so then do it and return with the result), and if not, then you should call the super method (assuming the default behavior is fine with you).
 */
protected TemplateModel handleUnknownType(Object obj) throws TemplateModelException {
  if (obj instanceof Node) {
    return wrapDomNode(obj);
  }
  if (JYTHON_WRAPPER != null && JYTHON_OBJ_CLASS.isInstance(obj)) {
    return JYTHON_WRAPPER.wrap(obj);
  }
  return super.wrap(obj);
}
Program: 15594
Project: 15594
Buggy source:
public TemplateModel get(String key) throws TemplateModelException {
  Object val=map.get(key);
  if (val == null) {
    if (key.length() == 1) {
      Character charKey=new Character(key.charAt(0));
      val=map.get(charKey);
      if (val == null && !(map.containsKey(key) || map.containsKey(charKey))) {
        return null;
      }
    }
 else     if (!map.containsKey(key)) {
      return null;
    }
  }
  return wrap(val);
}

Fixed version (ground truth):
public TemplateModel get(String key) throws TemplateModelException {
  Object val;
  try {
    val=map.get(key);
  }
 catch (  ClassCastException e) {
    throw new _TemplateModelException(e,new Object[]{"String_Node_Str",new _DelayedJQuote(key)});
  }
catch (  NullPointerException e) {
    throw new _TemplateModelException(e,new Object[]{"String_Node_Str",new _DelayedJQuote(key)});
  }
  if (val == null) {
    if (key.length() == 1 && !(map instanceof SortedMap)) {
      Character charKey=new Character(key.charAt(0));
      try {
        val=map.get(charKey);
        if (val == null && !(map.containsKey(key) || map.containsKey(charKey))) {
          return null;
        }
      }
 catch (      ClassCastException e) {
        throw new _TemplateModelException(e,new Object[]{"String_Node_Str",new _DelayedJQuote(charKey)});
      }
catch (      NullPointerException e) {
        throw new _TemplateModelException(e,new Object[]{"String_Node_Str",new _DelayedJQuote(charKey)});
      }
    }
 else     if (!map.containsKey(key)) {
      return null;
    }
  }
  return wrap(val);
}
Program: 15596
Project: 15596
Buggy source:
public void execute(Environment env,Map args,TemplateModel[] outArgs,final TemplateDirectiveBody body) throws TemplateException, IOException {
  try {
    SimpleTag tag=(SimpleTag)getTagInstance();
    final FreeMarkerPageContext pageContext=PageContextFactory.getCurrentPageContext();
    pageContext.pushWriter(new JspWriterAdapter(env.getOut()));
    try {
      tag.setJspContext(pageContext);
      JspTag parentTag=(JspTag)pageContext.peekTopTag(JspTag.class);
      if (parentTag != null) {
        tag.setParent(parentTag);
      }
      setupTag(tag,args,pageContext.getObjectWrapper());
      if (body != null) {
        tag.setJspBody(new JspFragment(){
          public JspContext getJspContext(){
            return pageContext;
          }
          public void invoke(          Writer out) throws JspException, IOException {
            try {
              body.render(out == null ? pageContext.getOut() : out);
            }
 catch (            TemplateException e) {
              throw new JspException(e);
            }
          }
        }
);
        pageContext.pushTopTag(tag);
        try {
          tag.doTag();
        }
  finally {
          pageContext.popTopTag();
        }
      }
 else {
        tag.doTag();
      }
    }
  finally {
      pageContext.popWriter();
    }
  }
 catch (  TemplateException e) {
    throw e;
  }
catch (  RuntimeException e) {
    throw e;
  }
catch (  Exception e) {
    throw new TemplateModelException(e);
  }
}

Fixed version (ground truth):
public void execute(Environment env,Map args,TemplateModel[] outArgs,final TemplateDirectiveBody body) throws TemplateException, IOException {
  try {
    SimpleTag tag=(SimpleTag)getTagInstance();
    final FreeMarkerPageContext pageContext=PageContextFactory.getCurrentPageContext();
    pageContext.pushWriter(new JspWriterAdapter(env.getOut()));
    try {
      tag.setJspContext(pageContext);
      JspTag parentTag=(JspTag)pageContext.peekTopTag(JspTag.class);
      if (parentTag != null) {
        tag.setParent(parentTag);
      }
      setupTag(tag,args,pageContext.getObjectWrapper());
      if (body != null) {
        tag.setJspBody(new JspFragment(){
          public JspContext getJspContext(){
            return pageContext;
          }
          public void invoke(          Writer out) throws JspException, IOException {
            try {
              body.render(out == null ? pageContext.getOut() : out);
            }
 catch (            TemplateException e) {
              throw new JspException(e);
            }
          }
        }
);
        pageContext.pushTopTag(tag);
        try {
          tag.doTag();
        }
  finally {
          pageContext.popTopTag();
        }
      }
 else {
        tag.doTag();
      }
    }
  finally {
      pageContext.popWriter();
    }
  }
 catch (  TemplateException e) {
    throw e;
  }
catch (  RuntimeException e) {
    throw e;
  }
catch (  Exception e) {
    throw new TemplateModelException("String_Node_Str",e);
  }
}
Program: 15598
Project: 15598
Buggy source:
public Object getAttribute(String name,int scope){
switch (scope) {
case PAGE_SCOPE:
{
      try {
        TemplateModel m=environment.getGlobalNamespace().get(name);
        if (m instanceof AdapterTemplateModel) {
          return ((AdapterTemplateModel)m).getAdaptedObject(OBJECT_CLASS);
        }
        if (m instanceof WrapperTemplateModel) {
          return ((WrapperTemplateModel)m).getWrappedObject();
        }
        if (m instanceof TemplateScalarModel) {
          return ((TemplateScalarModel)m).getAsString();
        }
        if (m instanceof TemplateNumberModel) {
          return ((TemplateNumberModel)m).getAsNumber();
        }
        if (m instanceof TemplateBooleanModel) {
          return Boolean.valueOf(((TemplateBooleanModel)m).getAsBoolean());
        }
        return m;
      }
 catch (      TemplateModelException e) {
        throw new UndeclaredThrowableException(e);
      }
    }
case REQUEST_SCOPE:
{
    return getRequest().getAttribute(name);
  }
case SESSION_SCOPE:
{
  HttpSession session=getSession(false);
  if (session == null) {
    return null;
  }
  return session.getAttribute(name);
}
case APPLICATION_SCOPE:
{
return getServletContext().getAttribute(name);
}
default :
{
throw new IllegalArgumentException("String_Node_Str" + scope);
}
}
}

Fixed version (ground truth):
public Object getAttribute(String name,int scope){
switch (scope) {
case PAGE_SCOPE:
{
      try {
        TemplateModel m=environment.getGlobalNamespace().get(name);
        if (m instanceof AdapterTemplateModel) {
          return ((AdapterTemplateModel)m).getAdaptedObject(OBJECT_CLASS);
        }
        if (m instanceof WrapperTemplateModel) {
          return ((WrapperTemplateModel)m).getWrappedObject();
        }
        if (m instanceof TemplateScalarModel) {
          return ((TemplateScalarModel)m).getAsString();
        }
        if (m instanceof TemplateNumberModel) {
          return ((TemplateNumberModel)m).getAsNumber();
        }
        if (m instanceof TemplateBooleanModel) {
          return Boolean.valueOf(((TemplateBooleanModel)m).getAsBoolean());
        }
        if (incompatibleImprovements >= _TemplateAPI.VERSION_INT_2_3_22) {
          if (m instanceof TemplateDateModel) {
            return ((TemplateDateModel)m).getAsDate();
          }
        }
        return m;
      }
 catch (      TemplateModelException e) {
        throw new UndeclaredThrowableException(e);
      }
    }
case REQUEST_SCOPE:
{
    return getRequest().getAttribute(name);
  }
case SESSION_SCOPE:
{
  HttpSession session=getSession(false);
  if (session == null) {
    return null;
  }
  return session.getAttribute(name);
}
case APPLICATION_SCOPE:
{
return getServletContext().getAttribute(name);
}
default :
{
throw new IllegalArgumentException("String_Node_Str" + scope);
}
}
}
Program: 15601
Project: 15601
Buggy source:
/** 
 * Gets the currently executing <em>custom</em> directive's call place information, or   {@code null} if there's noexecuting custom directive. This method currently only works for custom directives (that is, {@link TemplateDirectiveModel} and {@link TemplateTransformModel} and macro calls), and when those are calledfrom a template with the  {@code <@...>} syntax. This should only be called from the{@link TemplateDirectiveModel} that was invoked with {@code <@...>}. Otherwise it might gives you a different result, like right now usually a   {@code null}. 
 * @since 2.3.22
 */
public DirectiveCallPlace getCurrentDirectiveCallPlace(){
  int ln=instructionStack.size();
  if (ln == 0)   return null;
  TemplateElement te=(TemplateElement)instructionStack.get(ln - 1);
  return te instanceof UnifiedCall ? (UnifiedCall)te : null;
}

Fixed version (ground truth):
/** 
 * Gets the currently executing <em>custom</em> directive's call place information, or   {@code null} if there's noexecuting custom directive. This method currently only works for custom directives (that is, {@link TemplateDirectiveModel} and {@link TemplateTransformModel} and macro calls), and when those are calledfrom a template with the  {@code <@...>} syntax. This should only be called from the{@link TemplateDirectiveModel} that was invoked with {@code <@...>}. Otherwise it might gives you a different result, like right now usually a   {@code null}. 
 * @since 2.3.22
 */
public DirectiveCallPlace getCurrentDirectiveCallPlace(){
  int ln=instructionStack.size();
  if (ln == 0)   return null;
  TemplateElement te=(TemplateElement)instructionStack.get(ln - 1);
  if (te instanceof UnifiedCall)   return (UnifiedCall)te;
  if (te instanceof Macro && ln > 1 && instructionStack.get(ln - 2) instanceof UnifiedCall) {
    return (UnifiedCall)instructionStack.get(ln - 2);
  }
  return null;
}
Program: 15602
Project: 15602
Buggy source:
private TldLocation getExplicitlyMappedTldLocation(final String uri) throws SAXException, IOException, TaglibCreationException {
  while (true) {
    final TldLocation tldLocation=(TldLocation)tldLocations.get(uri);
    if (tldLocation != null) {
      return tldLocation;
    }
switch (nextTldLocationLookupPhase) {
case 0:
      addTldLocationsFromClasspathTlds();
    break;
case 1:
  addTldLocationsFromWebXml();
break;
case 2:
addTldLocationsFromWebInfPerLibTlds();
break;
case 3:
addTldLocationsFromMetaInfTlds();
break;
case 4:
addTldLocationsFromWebInfTlds();
break;
case 5:
return null;
default :
throw new BugException();
}
nextTldLocationLookupPhase++;
}
}

Fixed version (ground truth):
private TldLocation getExplicitlyMappedTldLocation(final String uri) throws SAXException, IOException, TaglibCreationException {
  while (true) {
    final TldLocation tldLocation=(TldLocation)tldLocations.get(uri);
    if (tldLocation != null) {
      return tldLocation;
    }
switch (nextTldLocationLookupPhase) {
case 0:
      addTldLocationsFromClasspathTlds();
    break;
case 1:
  addTldLocationsFromWebXml();
break;
case 2:
addTldLocationsFromWebInfTlds();
break;
case 3:
addTldLocationsFromMetaInfTlds();
break;
case 4:
return null;
default :
throw new BugException();
}
nextTldLocationLookupPhase++;
}
}
Program: 15603
Project: 15603
Buggy source:
private void addTldLocationsFromWebInfTlds() throws IOException, SAXException {
  LOG.debug("String_Node_Str");
  Set webinfEntryPaths=servletContext.getResourcePaths("String_Node_Str");
  if (webinfEntryPaths != null) {
    for (Iterator it=webinfEntryPaths.iterator(); it.hasNext(); ) {
      String webInfEntryPath=(String)it.next();
      if (webInfEntryPath.endsWith("String_Node_Str")) {
        addTldLocationFromTld(new ServletContextTldLocation(webInfEntryPath));
      }
    }
  }
}

Fixed version (ground truth):
private void addTldLocationsFromWebInfTlds() throws IOException, SAXException {
  LOG.debug("String_Node_Str");
  addTldLocationsFromServletContextResourceTlds("String_Node_Str");
}
Program: 15604
Project: 15604
Buggy source:
private List parseCommaSeparatedList(String value) throws ParseException {
  List valuesList=new ArrayList();
  String[] values=StringUtil.split(value,',');
  for (int i=0; i < values.length; i++) {
    final String s=values[i].trim();
    if (s.length() != 0) {
      valuesList.add(s);
    }
 else     if (i != values.length - 1) {
      throw new ParseException("String_Node_Str" + i,-1);
    }
  }
  return valuesList;
}

Fixed version (ground truth):
private List parseCommaSeparatedList(String value) throws ParseException {
  List valuesList=new ArrayList();
  String[] values=StringUtil.split(value,',');
  for (int i=0; i < values.length; i++) {
    final String s=values[i].trim();
    if (s.length() != 0) {
      valuesList.add(s);
    }
 else     if (i != values.length - 1) {
      throw new ParseException("String_Node_Str",-1);
    }
  }
  return valuesList;
}
Program: 15607
Project: 15607
Buggy source:
@Override public Throwable getCause(){
  Throwable cause=super.getCause();
  return cause == null ? getException() : cause;
}

Fixed version (ground truth):
public Throwable getCause(){
  Throwable superCause=super.getCause();
  return superCause == null ? this.cause : superCause;
}
Program: 15608
Project: 15608
Buggy source:
public void characters(char[] chars,int off,int len){
  if (buf != null) {
    buf.append(chars,off,len);
  }
}

Fixed version (ground truth):
public void characters(char[] chars,int off,int len){
  if (cDataCollector != null) {
    cDataCollector.append(chars,off,len);
  }
}
Program: 15610
Project: 15610
Buggy source:
public void startElement(String nsuri,String localName,String qName,Attributes atts){
  stack.push(qName);
  if (stack.size() == 3) {
    if ("String_Node_Str".equals(qName) || "String_Node_Str".equals(qName) || "String_Node_Str".equals(qName)|| "String_Node_Str".equals(qName)|| "String_Node_Str".equals(qName)|| "String_Node_Str".equals(qName)) {
      buf=new StringBuffer();
    }
  }
}

Fixed version (ground truth):
public void startElement(String nsUri,String localName,String qName,Attributes atts){
  stack.push(qName);
  if (stack.size() == 3) {
    if (NAME.equals(qName) || TAG_CLASS_LEGACY.equals(qName) || TAG_CLASS.equals(qName)|| LISTENER_CLASS.equals(qName)|| FUNCTION_CLASS.equals(qName)|| FUNCTION_SIGNATURE.equals(qName)) {
      cDataCollector=new StringBuffer();
    }
  }
}
Program: 15611
Project: 15611
Buggy source:
TLDParsingException(String message,Locator locator,Exception e){
  super(message,locator,e);
}

Fixed version (ground truth):
TLDParsingException(String message,Locator locator,Throwable e){
  super(message,locator,e instanceof Exception ? (Exception)e : new Exception("String_Node_Str",e));
  cause=e;
}
Program: 15612
Project: 15612
Buggy source:
@Override public String toString(){
  StringBuffer sb=new StringBuffer(getClass().getName());
  sb.append("String_Node_Str");
  int startLn=sb.length();
  String systemId=getSystemId();
  String publicId=getPublicId();
  if (systemId != null || publicId != null) {
    sb.append("String_Node_Str");
    if (systemId != null) {
      sb.append(systemId);
    }
    if (publicId != null) {
      if (systemId != null) {
        sb.append("String_Node_Str");
      }
      sb.append(publicId);
      if (systemId != null) {
        sb.append(')');
      }
    }
  }
  int line=getLineNumber();
  if (line != -1) {
    sb.append(sb.length() != startLn ? "String_Node_Str" : "String_Node_Str");
    sb.append("String_Node_Str");
    sb.append(line);
    int col=getColumnNumber();
    if (col != -1) {
      sb.append("String_Node_Str");
      sb.append(col);
    }
  }
  String message=getLocalizedMessage();
  if (message != null) {
    if (sb.length() != startLn) {
      sb.append("String_Node_Str");
    }
    sb.append(message);
  }
  return sb.toString();
}

Fixed version (ground truth):
public String toString(){
  StringBuffer sb=new StringBuffer(getClass().getName());
  sb.append("String_Node_Str");
  int startLn=sb.length();
  String systemId=getSystemId();
  String publicId=getPublicId();
  if (systemId != null || publicId != null) {
    sb.append("String_Node_Str");
    if (systemId != null) {
      sb.append(systemId);
    }
    if (publicId != null) {
      if (systemId != null) {
        sb.append("String_Node_Str");
      }
      sb.append(publicId);
      if (systemId != null) {
        sb.append(')');
      }
    }
  }
  int line=getLineNumber();
  if (line != -1) {
    sb.append(sb.length() != startLn ? "String_Node_Str" : "String_Node_Str");
    sb.append("String_Node_Str");
    sb.append(line);
    int col=getColumnNumber();
    if (col != -1) {
      sb.append("String_Node_Str");
      sb.append(col);
    }
  }
  String message=getLocalizedMessage();
  if (message != null) {
    if (sb.length() != startLn) {
      sb.append("String_Node_Str");
    }
    sb.append(message);
  }
  return sb.toString();
}
Program: 15614
Project: 15614
Buggy source:
@Before public void before() throws Exception {
  BeansWrapperBuilder builder=new BeansWrapperBuilder(new Version("String_Node_Str"));
  wrapper=builder.getResult();
}

Fixed version (ground truth):
@Before public void before() throws Exception {
  BeansWrapperBuilder builder=new BeansWrapperBuilder(new Version("String_Node_Str"));
  wrapper=builder.build();
}
Program: 15615
Project: 15615
Buggy source:
@Test public void test2() throws Exception {
  assertOutputsEqual("String_Node_Str","String_Node_Str","String_Node_Str");
}

Fixed version (ground truth):
@Ignore @Test public void test2() throws Exception {
  assertOutputsEqual("String_Node_Str","String_Node_Str","String_Node_Str");
}
Program: 15616
Project: 15616
Buggy source:
private void assertOutput(final String ftl,String expectedOutStripped,String expectedOutNonStripped) throws IOException, TemplateException {
  for (int i=0; i < 4; i++) {
    String ftlPermutation=ftl;
    if ((i & 1) == 1) {
      ftlPermutation=ftlPermutation.replace("String_Node_Str","String_Node_Str");
    }
    if ((i & 2) == 2) {
      ftlPermutation=ftlPermutation.replace('<','[').replace('>',']');
    }
    assertOutput(ftlPermutation,expectedOutStripped,cfgStripWS);
    assertOutput(ftlPermutation,expectedOutNonStripped,cfgNoStripWS);
  }
}

Fixed version (ground truth):
private void assertOutput(final String ftl,String expectedOutStripped,String expectedOutNonStripped) throws IOException, TemplateException {
  for (int i=0; i < 4; i++) {
    String ftlPermutation=ftl;
    if ((i & 1) == 1) {
      ftlPermutation=ftlPermutation.replace("String_Node_Str","String_Node_Str");
    }
    if ((i & 2) == 2) {
      ftlPermutation=ftlPermutation.replace('<','[').replace('>',']');
    }
    setConfiguration(cfgStripWS);
    assertOutput(ftlPermutation,expectedOutStripped);
    setConfiguration(cfgNoStripWS);
    assertOutput(ftlPermutation,expectedOutNonStripped);
  }
}