nus-yam/ex-repair huggingface dataset:
Program: 39087
Project: 39087
Buggy source:
public static String durationToString(final Integer duration){
  if (duration == null) {
    return ERROR_STRING_VALUE;
  }
  long longValueFromDuration=duration.longValue();
  long hours=longValueFromDuration / 3600;
  long minutes=longValueFromDuration % 3600 / 60;
  long seconds=longValueFromDuration % 3600 % 60;
  Boolean minus=false;
  if (hours < 0) {
    minus=true;
    hours=-hours;
  }
  if (minutes < 0) {
    minus=true;
    minutes=-minutes;
  }
  if (seconds < 0) {
    minus=true;
    seconds=-seconds;
  }
  return (minus ? "String_Node_Str" : "String_Node_Str") + (hours < 10 ? "String_Node_Str" : "String_Node_Str") + hours+ "String_Node_Str"+ (minutes < 10 ? "String_Node_Str" : "String_Node_Str")+ minutes+ "String_Node_Str"+ (seconds < 10 ? "String_Node_Str" : "String_Node_Str")+ seconds;
}

Fixed version (ground truth):
public static String durationToString(final Integer duration){
  if (duration == null) {
    return ERROR_STRING_VALUE;
  }
  boolean minus=false;
  long longValueFromDuration=duration.longValue();
  if (longValueFromDuration < 0) {
    minus=true;
    longValueFromDuration=-longValueFromDuration;
  }
  long hours=longValueFromDuration / 3600;
  long minutes=longValueFromDuration % 3600 / 60;
  long seconds=longValueFromDuration % 3600 % 60;
  return (minus ? "String_Node_Str" : "String_Node_Str") + ((hours < 10) ? "String_Node_Str" : "String_Node_Str") + hours+ "String_Node_Str"+ ((minutes < 10) ? "String_Node_Str" : "String_Node_Str")+ minutes+ "String_Node_Str"+ ((seconds < 10) ? "String_Node_Str" : "String_Node_Str")+ seconds;
}
Program: 39088
Project: 39088
Buggy source:
private List<String> getColumnNames(final GridComponent grid,final List<String> columns){
  List<String> columnNames=Lists.newLinkedList();
  columns.forEach(column -> {
    String columnName=grid.getColumnNames().get(column);
    columnNames.add(columnName);
  }
);
  return columnNames;
}

Fixed version (ground truth):
private List<String> getColumnNames(final GridComponent grid,final List<String> columns){
  List<String> columnNames=Lists.newLinkedList();
  columns.forEach(column -> {
    String columnName=grid.getColumnNames().get(column);
    if (!Strings.isNullOrEmpty(columnName)) {
      columnNames.add(columnName);
    }
  }
);
  return columnNames;
}
Program: 39089
Project: 39089
Buggy source:
private List<String> getColumns(final GridComponent grid,final String viewName){
  List<String> columns=Lists.newLinkedList();
  grid.getColumns().entrySet().stream().forEach(entry -> {
    String columnAuthorizationRole=entry.getValue().getAuthorizationRole();
    if (Strings.isNullOrEmpty(columnAuthorizationRole) || securityRolesService.canAccess(columnAuthorizationRole)) {
      columns.add(entry.getKey());
    }
  }
);
  return columns;
}

Fixed version (ground truth):
private List<String> getColumns(final GridComponent grid,final String viewName){
  List<String> columns=Lists.newLinkedList();
  grid.getColumns().entrySet().stream().forEach(entry -> {
    String columnAuthorizationRole=entry.getValue().getAuthorizationRole();
    if ((Strings.isNullOrEmpty(columnAuthorizationRole) || securityRolesService.canAccess(columnAuthorizationRole)) && !entry.getValue().isHidden()) {
      columns.add(entry.getKey());
    }
  }
);
  return columns;
}
Program: 39090
Project: 39090
Buggy source:
public void translateItemForm(final ViewDefinitionState viewDefinitionState){
  FormComponent itemForm=(FormComponent)viewDefinitionState.getComponentByReference(L_FORM);
  Long itemId=itemForm.getEntityId();
  if (itemId != null) {
    Entity item=dataDefinitionService.get(QcadooViewConstants.PLUGIN_IDENTIFIER,QcadooViewConstants.MODEL_ITEM).get(itemId);
    if ((item != null) && (item.getStringField(MenuItemFields.PLUGIN_IDENTIFIER) != null)) {
      FieldComponent itemNameField=(FieldComponent)viewDefinitionState.getComponentByReference("String_Node_Str");
      FieldComponent itemViewField=(FieldComponent)viewDefinitionState.getComponentByReference("String_Node_Str");
      itemNameField.setEnabled(false);
      itemNameField.setFieldValue(translationUtilsService.getItemTranslation(item,viewDefinitionState.getLocale()));
      itemViewField.setEnabled(false);
    }
  }
}

Fixed version (ground truth):
public void translateItemForm(final ViewDefinitionState viewDefinitionState){
  FormComponent itemForm=(FormComponent)viewDefinitionState.getComponentByReference(L_FORM);
  Long itemId=itemForm.getEntityId();
  if (itemId != null) {
    Entity item=dataDefinitionService.get(QcadooViewConstants.PLUGIN_IDENTIFIER,QcadooViewConstants.MODEL_ITEM).get(itemId);
    if ((item != null) && (item.getStringField(MenuItemFields.PLUGIN_IDENTIFIER) != null)) {
      FieldComponent itemNameField=(FieldComponent)viewDefinitionState.getComponentByReference("String_Node_Str");
      FieldComponent itemViewField=(FieldComponent)viewDefinitionState.getComponentByReference("String_Node_Str");
      itemNameField.setEnabled(false);
      itemViewField.setEnabled(false);
    }
  }
}
Program: 39091
Project: 39091
Buggy source:
private Map<String,String> convertEntityToMap(final Entity entity){
  Map<String,String> values=new LinkedHashMap<String,String>();
  for (  GridComponentColumn column : columns.values()) {
    if (column.isHidden()) {
      continue;
    }
    if (column.getFields().get(0).getType() instanceof EnumeratedType) {
      String fieldValue=column.getValue(entity,getLocale());
      StringBuffer localeString=new StringBuffer();
      localeString.append(getDataDefinition().getPluginIdentifier());
      localeString.append('.');
      localeString.append(getDataDefinition().getName());
      localeString.append('.');
      localeString.append(column.getName());
      localeString.append("String_Node_Str");
      localeString.append(fieldValue);
      values.put(column.getName(),getTranslationService().translate(localeString.toString(),getLocale()));
    }
 else     if (column.getFields().get(0).getType().getType().equals(Boolean.class)) {
      String fieldValue=column.getValue(entity,getLocale());
      if (fieldValue != null) {
        if (fieldValue.equals("String_Node_Str")) {
          values.put(column.getName(),getTranslationService().translate("String_Node_Str",getLocale()));
        }
 else {
          values.put(column.getName(),getTranslationService().translate("String_Node_Str",getLocale()));
        }
      }
 else {
        values.put(column.getName(),"String_Node_Str");
      }
    }
 else {
      values.put(column.getName(),column.getValue(entity,getLocale()));
    }
  }
  return values;
}

Fixed version (ground truth):
private Map<String,String> convertEntityToMap(final Entity entity){
  Map<String,String> values=new LinkedHashMap<String,String>();
  for (  GridComponentColumn column : columns.values()) {
    if (column.isHidden()) {
      continue;
    }
    if (column.getFields().get(0).getType() instanceof EnumType) {
      String fieldValue=column.getValue(entity,getLocale());
      StringBuffer localeString=new StringBuffer();
      localeString.append(getDataDefinition().getPluginIdentifier());
      localeString.append('.');
      localeString.append(getDataDefinition().getName());
      localeString.append('.');
      localeString.append(column.getName());
      localeString.append("String_Node_Str");
      localeString.append(fieldValue);
      values.put(column.getName(),getTranslationService().translate(localeString.toString(),getLocale()));
    }
 else     if (column.getFields().get(0).getType().getType().equals(Boolean.class)) {
      String fieldValue=column.getValue(entity,getLocale());
      if (fieldValue != null) {
        if (fieldValue.equals("String_Node_Str")) {
          values.put(column.getName(),getTranslationService().translate("String_Node_Str",getLocale()));
        }
 else {
          values.put(column.getName(),getTranslationService().translate("String_Node_Str",getLocale()));
        }
      }
 else {
        values.put(column.getName(),"String_Node_Str");
      }
    }
 else {
      values.put(column.getName(),column.getValue(entity,getLocale()));
    }
  }
  return values;
}
Program: 39092
Project: 39092
Buggy source:
public void addRestrictionToCategoriesGrid(final ViewDefinitionState viewDefinitionState){
  GridComponent categoriesGrid=(GridComponent)viewDefinitionState.getComponentByReference("String_Node_Str");
  categoriesGrid.setCustomRestriction(new CustomRestriction(){
    @Override public void addRestriction(    final SearchCriteriaBuilder searchCriteriaBuilder){
      SearchDisjunction disjunction=SearchRestrictions.disjunction();
      for (      String[] category : HIDDEN_CATEGORIES) {
        disjunction.add(SearchRestrictions.and(SearchRestrictions.eq(L_PLUGIN_IDENTIFIER,category[0]),SearchRestrictions.eq("String_Node_Str",category[1])));
      }
      searchCriteriaBuilder.add(SearchRestrictions.not(disjunction));
    }
  }
);
}

Fixed version (ground truth):
public void addRestrictionToCategoriesGrid(final ViewDefinitionState viewDefinitionState){
  GridComponent categoriesGrid=(GridComponent)viewDefinitionState.getComponentByReference(L_GRID);
  categoriesGrid.setCustomRestriction(new CustomRestriction(){
    @Override public void addRestriction(    final SearchCriteriaBuilder searchCriteriaBuilder){
      SearchDisjunction disjunction=SearchRestrictions.disjunction();
      for (      String[] category : HIDDEN_CATEGORIES) {
        disjunction.add(SearchRestrictions.and(SearchRestrictions.eq(MenuCategoryFields.PLUGIN_IDENTIFIER,category[0]),SearchRestrictions.eq(MenuCategoryFields.NAME,category[1])));
      }
      searchCriteriaBuilder.add(SearchRestrictions.not(disjunction));
    }
  }
);
}
Program: 39093
Project: 39093
Buggy source:
@Override public void addRestriction(final SearchCriteriaBuilder searchCriteriaBuilder){
  SearchDisjunction disjunction=SearchRestrictions.disjunction();
  for (  String[] category : HIDDEN_CATEGORIES) {
    disjunction.add(SearchRestrictions.and(SearchRestrictions.eq(L_PLUGIN_IDENTIFIER,category[0]),SearchRestrictions.eq("String_Node_Str",category[1])));
  }
  searchCriteriaBuilder.add(SearchRestrictions.not(disjunction));
}

Fixed version (ground truth):
@Override public void addRestriction(final SearchCriteriaBuilder searchCriteriaBuilder){
  SearchDisjunction disjunction=SearchRestrictions.disjunction();
  for (  String[] category : HIDDEN_CATEGORIES) {
    disjunction.add(SearchRestrictions.and(SearchRestrictions.eq(MenuCategoryFields.PLUGIN_IDENTIFIER,category[0]),SearchRestrictions.eq(MenuCategoryFields.NAME,category[1])));
  }
  searchCriteriaBuilder.add(SearchRestrictions.not(disjunction));
}
Program: 39094
Project: 39094
Buggy source:
public void translateCategoryForm(final ViewDefinitionState viewDefinitionState){
  FormComponent categoryForm=(FormComponent)viewDefinitionState.getComponentByReference("String_Node_Str");
  Entity categoryFormEntity=categoryForm.getEntity();
  Entity categoryDbEntity=null;
  if (categoryFormEntity != null && categoryFormEntity.getId() != null) {
    categoryDbEntity=dataDefinitionService.get(QcadooViewConstants.PLUGIN_IDENTIFIER,QcadooViewConstants.MODEL_CATEGORY).get(categoryFormEntity.getId());
  }
  if (categoryDbEntity != null && categoryDbEntity.getStringField(L_PLUGIN_IDENTIFIER) != null) {
    ComponentState categoryNameField=viewDefinitionState.getComponentByReference("String_Node_Str");
    categoryNameField.setEnabled(false);
    categoryNameField.setFieldValue(translationUtilsService.getCategoryTranslation(categoryDbEntity,viewDefinitionState.getLocale()));
  }
  GridComponent categoryItemsGrid=(GridComponent)viewDefinitionState.getComponentByReference("String_Node_Str");
  for (  Entity itemEntity : categoryItemsGrid.getEntities()) {
    if (itemEntity.getStringField(L_PLUGIN_IDENTIFIER) != null) {
      itemEntity.setField("String_Node_Str",translationUtilsService.getItemTranslation(itemEntity,viewDefinitionState.getLocale()));
    }
  }
}

Fixed version (ground truth):
public void translateCategoryForm(final ViewDefinitionState viewDefinitionState){
  FormComponent categoryForm=(FormComponent)viewDefinitionState.getComponentByReference(L_FORM);
  Long categoryId=categoryForm.getEntityId();
  if (categoryId != null) {
    Entity category=dataDefinitionService.get(QcadooViewConstants.PLUGIN_IDENTIFIER,QcadooViewConstants.MODEL_CATEGORY).get(categoryId);
    if ((category != null) && (category.getStringField(MenuCategoryFields.PLUGIN_IDENTIFIER) != null)) {
      FieldComponent categoryNameField=(FieldComponent)viewDefinitionState.getComponentByReference("String_Node_Str");
      categoryNameField.setEnabled(false);
      categoryNameField.setFieldValue(translationUtilsService.getCategoryTranslation(category,viewDefinitionState.getLocale()));
    }
    GridComponent categoryItemsGrid=(GridComponent)viewDefinitionState.getComponentByReference("String_Node_Str");
    for (    Entity item : categoryItemsGrid.getEntities()) {
      if (item.getStringField(MenuItemFields.PLUGIN_IDENTIFIER) != null) {
        item.setField(MenuItemFields.NAME,translationUtilsService.getItemTranslation(item,viewDefinitionState.getLocale()));
      }
    }
  }
}
Program: 39095
Project: 39095
Buggy source:
public void translateItemForm(final ViewDefinitionState viewDefinitionState){
  FormComponent itemForm=(FormComponent)viewDefinitionState.getComponentByReference("String_Node_Str");
  Entity itemEntity=null;
  if (itemForm.getEntity() != null) {
    itemEntity=dataDefinitionService.get(QcadooViewConstants.PLUGIN_IDENTIFIER,QcadooViewConstants.MODEL_ITEM).get(itemForm.getEntity().getId());
  }
  if (itemEntity != null && itemEntity.getStringField(L_PLUGIN_IDENTIFIER) != null) {
    ComponentState itemNameField=viewDefinitionState.getComponentByReference("String_Node_Str");
    itemNameField.setEnabled(false);
    viewDefinitionState.getComponentByReference("String_Node_Str").setEnabled(false);
  }
}

Fixed version (ground truth):
public void translateItemForm(final ViewDefinitionState viewDefinitionState){
  FormComponent itemForm=(FormComponent)viewDefinitionState.getComponentByReference(L_FORM);
  Long itemId=itemForm.getEntityId();
  if (itemId != null) {
    Entity item=dataDefinitionService.get(QcadooViewConstants.PLUGIN_IDENTIFIER,QcadooViewConstants.MODEL_ITEM).get(itemId);
    if ((item != null) && (item.getStringField(MenuItemFields.PLUGIN_IDENTIFIER) != null)) {
      FieldComponent itemNameField=(FieldComponent)viewDefinitionState.getComponentByReference("String_Node_Str");
      FieldComponent itemViewField=(FieldComponent)viewDefinitionState.getComponentByReference("String_Node_Str");
      itemNameField.setEnabled(false);
      itemNameField.setFieldValue(translationUtilsService.getItemTranslation(item,viewDefinitionState.getLocale()));
      itemViewField.setEnabled(false);
    }
  }
}
Program: 39096
Project: 39096
Buggy source:
public void translateCategoriesGrid(final ViewDefinitionState viewDefinitionState){
  GridComponent categoriesGrid=(GridComponent)viewDefinitionState.getComponentByReference("String_Node_Str");
  for (  Entity categoryEntity : categoriesGrid.getEntities()) {
    if (categoryEntity.getStringField(L_PLUGIN_IDENTIFIER) != null) {
      categoryEntity.setField("String_Node_Str",translationUtilsService.getCategoryTranslation(categoryEntity,viewDefinitionState.getLocale()));
    }
  }
}

Fixed version (ground truth):
public void translateCategoriesGrid(final ViewDefinitionState viewDefinitionState){
  GridComponent categoriesGrid=(GridComponent)viewDefinitionState.getComponentByReference(L_GRID);
  for (  Entity category : categoriesGrid.getEntities()) {
    if (category.getStringField(MenuCategoryFields.PLUGIN_IDENTIFIER) != null) {
      category.setField(MenuCategoryFields.NAME,translationUtilsService.getCategoryTranslation(category,viewDefinitionState.getLocale()));
    }
  }
}
Program: 39097
Project: 39097
Buggy source:
@Override public void onApplicationEvent(final AbstractAuthenticationEvent event){
  UserDetails userDetails=(UserDetails)event.getAuthentication().getPrincipal();
  Entity entity=dataDefinitionService.get(PLUGIN_IDENTIFIER,MODEL_USER).find().add(SearchRestrictions.eq(L_USER_NAME,userDetails.getUsername())).uniqueResult();
  Calendar now=Calendar.getInstance();
  now.add(Calendar.DAY_OF_YEAR,-1);
  if (entity.getField("String_Node_Str") == null || now.getTime().after((Date)entity.getField("String_Node_Str"))) {
    entity.setField("String_Node_Str",new Date());
    dataDefinitionService.get(PLUGIN_IDENTIFIER,MODEL_USER).save(entity);
  }
}

Fixed version (ground truth):
@Override public void onApplicationEvent(final AbstractAuthenticationEvent event){
  if (!(event instanceof AbstractAuthenticationFailureEvent)) {
    UserDetails userDetails=(UserDetails)event.getAuthentication().getPrincipal();
    Entity entity=dataDefinitionService.get(PLUGIN_IDENTIFIER,MODEL_USER).find().add(SearchRestrictions.eq(L_USER_NAME,userDetails.getUsername())).uniqueResult();
    Calendar now=Calendar.getInstance();
    now.add(Calendar.DAY_OF_YEAR,-1);
    if (entity.getField("String_Node_Str") == null || now.getTime().after((Date)entity.getField("String_Node_Str"))) {
      entity.setField("String_Node_Str",new Date());
      dataDefinitionService.get(PLUGIN_IDENTIFIER,MODEL_USER).save(entity);
    }
  }
}
Program: 39098
Project: 39098
Buggy source:
private SearchCriterion uniqueCriterionFor(final Entity entity){
  if (Objects.equals(String.class,fieldDefinition.getType().getType())) {
    return SearchRestrictions.iEq(fieldDefinition.getName(),entity.getField(fieldDefinition.getName()));
  }
  return SearchRestrictions.eq(fieldDefinition.getName(),entity.getField(fieldDefinition.getName()));
}

Fixed version (ground truth):
private SearchCriterion uniqueCriterionFor(final Entity entity){
  if (Objects.equals(String.class,fieldDefinition.getType().getType())) {
    return SearchRestrictions.iEq(fieldDefinition.getName(),entity.getStringField(fieldDefinition.getName()).trim());
  }
  return SearchRestrictions.eq(fieldDefinition.getName(),entity.getField(fieldDefinition.getName()));
}
Program: 39099
Project: 39099
Buggy source:
@Override public void changeStateTo(final PluginState targetState){
  if (!isTransitionPossible(getState(),targetState)) {
    throw new IllegalStateException("String_Node_Str" + this + "String_Node_Str"+ getState()+ "String_Node_Str"+ targetState);
  }
  if (hasState(UNKNOWN)) {
    state=targetState;
    return;
  }
  Plugin thisPlugin=this;
  if (ENABLED.equals(targetState)) {
    for (    final ModuleFactory<?> factory : factories) {
      List<Module> modules=modulesByFactories.get(factory);
      for (      final Module module : modules) {
        module.enable();
        MultiTenantUtil.doInMultiTenantContext(() -> {
          if (PluginUtils.isEnabled(thisPlugin)) {
            module.multiTenantEnable();
          }
        }
);
      }
    }
    state=targetState;
  }
 else   if (DISABLED.equals(targetState)) {
    for (    final ModuleFactory<?> factory : reversedFactories) {
      List<Module> modules=modulesByFactories.get(factory);
      Collections.reverse(modules);
      for (      final Module module : modules) {
        module.disable();
        MultiTenantUtil.doInMultiTenantContext(() -> {
          if (PluginUtils.isEnabled(thisPlugin)) {
            module.multiTenantDisable();
          }
        }
);
      }
    }
    state=targetState;
  }
 else {
    state=targetState;
  }
}

Fixed version (ground truth):
@Override public void changeStateTo(final PluginState targetState){
  if (!isTransitionPossible(getState(),targetState)) {
    throw new IllegalStateException("String_Node_Str" + this + "String_Node_Str"+ getState()+ "String_Node_Str"+ targetState);
  }
  if (hasState(UNKNOWN)) {
    state=targetState;
    return;
  }
  Plugin thisPlugin=this;
  if (ENABLED.equals(targetState)) {
    state=targetState;
    for (    final ModuleFactory<?> factory : factories) {
      List<Module> modules=modulesByFactories.get(factory);
      for (      final Module module : modules) {
        module.enable();
        MultiTenantUtil.doInMultiTenantContext(() -> {
          if (PluginUtils.isEnabled(thisPlugin)) {
            module.multiTenantEnable();
          }
        }
);
      }
    }
  }
 else   if (DISABLED.equals(targetState)) {
    for (    final ModuleFactory<?> factory : reversedFactories) {
      List<Module> modules=modulesByFactories.get(factory);
      Collections.reverse(modules);
      for (      final Module module : modules) {
        module.disable();
        MultiTenantUtil.doInMultiTenantContext(() -> {
          if (PluginUtils.isEnabled(thisPlugin)) {
            module.multiTenantDisable();
          }
        }
);
      }
    }
    state=targetState;
  }
 else {
    state=targetState;
  }
}
Program: 39100
Project: 39100
Buggy source:
@Override public void doFilter(final ServletRequest request,final ServletResponse response,final FilterChain chain) throws IOException, ServletException {
  HttpServletRequest httpRequest=(HttpServletRequest)request;
  String uri=httpRequest.getRequestURI();
  if (uri.charAt(0) == '/') {
    uri=uri.substring(1);
  }
  String[] uriParts=uri.split("String_Node_Str");
  if ("String_Node_Str".equals(uriParts[0])) {
    chain.doFilter(request,response);
    return;
  }
  String[] arr=uri.split("String_Node_Str");
  String ext=arr[arr.length - 1];
  if (!NOT_STATIC_EXTENSIONS.contains(ext) && useJarStaticResources) {
    resourceService.serveResource(httpRequest,(HttpServletResponse)response);
  }
 else {
    chain.doFilter(request,response);
  }
}

Fixed version (ground truth):
@Override public void doFilter(final ServletRequest request,final ServletResponse response,final FilterChain chain) throws IOException, ServletException {
  HttpServletRequest httpRequest=(HttpServletRequest)request;
  String uri=httpRequest.getRequestURI();
  if (uri.charAt(0) == '/') {
    uri=uri.substring(1);
  }
  String[] uriParts=uri.split("String_Node_Str");
  if ("String_Node_Str".equals(uriParts[0]) || "String_Node_Str".equals(uriParts[0])) {
    chain.doFilter(request,response);
    return;
  }
  String[] arr=uri.split("String_Node_Str");
  String ext=arr[arr.length - 1];
  if (!NOT_STATIC_EXTENSIONS.contains(ext) && useJarStaticResources) {
    resourceService.serveResource(httpRequest,(HttpServletResponse)response);
  }
 else {
    chain.doFilter(request,response);
  }
}
Program: 39101
Project: 39101
Buggy source:
/** 
 * Convert integer time value to string in format hh:mm:ss
 * @param duration time value from database
 * @return time value in format hh:mm:ss
 */
public String convertTimeToString(final Integer duration){
  return durationToString(duration);
}

Fixed version (ground truth):
/** 
 * Convert string time value to string in format hh:mm:ss
 * @param duration time value from database
 * @return time value in format hh:mm:ss
 */
public static String convertTimeToString(final Object duration){
  if (duration instanceof Integer) {
    return durationToString((Integer)duration);
  }
 else {
    if (duration == null) {
      return "String_Node_Str";
    }
    String stringDuration=(String)duration;
    int integerDuration=Integer.parseInt(stringDuration.replaceAll("String_Node_Str","String_Node_Str"));
    if (stringDuration.contains("String_Node_Str")) {
      integerDuration=-integerDuration;
    }
    return durationToString(integerDuration);
  }
}
Program: 39102
Project: 39102
Buggy source:
public boolean disallowNameChange(final DataDefinition dataDefinition,final Entity entity){
  if (entity.getId() != null) {
    Entity existingEntity=dataDefinition.get(entity.getId());
    if (!Objects.equals(entity.getStringField(DictionaryItemFields.NAME),existingEntity.getStringField(DictionaryItemFields.NAME))) {
      entity.addError(dataDefinition.getField(DictionaryItemFields.NAME),"String_Node_Str");
      return false;
    }
  }
  return true;
}

Fixed version (ground truth):
private boolean disallowNameChange(final DataDefinition dictionaryItemDD,final Entity dictionaryItem){
  if (dictionaryItem.getId() != null) {
    Entity existingEntity=dictionaryItemDD.get(dictionaryItem.getId());
    if (!Objects.equals(dictionaryItem.getStringField(DictionaryItemFields.NAME),existingEntity.getStringField(DictionaryItemFields.NAME))) {
      dictionaryItem.addError(dictionaryItemDD.getField(DictionaryItemFields.NAME),"String_Node_Str");
      return false;
    }
  }
  return true;
}
Program: 39103
Project: 39103
Buggy source:
/** 
 * Check if this lookup doesn't have selected any entity.
 * @return true if this lookup doesn't have selected any entity.
 */
boolean isEmpty();

Fixed version (ground truth):
/** 
 * Check if this lookup doesn't have selected any entity and its input is empty.
 * @return true if this lookup doesn't have selected any entity and its input is empty.
 * @since 1.2.1
 */
boolean isEmpty();
Program: 39104
Project: 39104
Buggy source:
@Override public boolean isEmpty(){
  return getFieldValue() == null;
}

Fixed version (ground truth):
@Override public boolean isEmpty(){
  return org.apache.commons.lang.StringUtils.isEmpty(autocompleteCode) && !hasSelectedEntity();
}
Program: 39105
Project: 39105
Buggy source:
@Override public void setRequired(final boolean required){
  this.required=required;
  requestRender();
}

Fixed version (ground truth):
@Override public void setRequired(final boolean required){
  this.required=required;
}
Program: 39106
Project: 39106
Buggy source:
@Autowired private static void setStaticDataAccessService(final DataAccessService dataAccessService){
  SearchRestrictions.dataAccessService=dataAccessService;
}

Fixed version (ground truth):
private static void setStaticDataAccessService(final DataAccessService dataAccessService){
  SearchRestrictions.dataAccessService=dataAccessService;
}
Program: 39107
Project: 39107
Buggy source:
/** 
 * Creates criterion which checks if field is equal  (using case-insensitive "eq" operator)  to given value.
 * @param field field
 * @param value value
 * @return criterion
 */
public static SearchCriterion ieq(final String field,final Object value){
  return new SearchCriterionImpl(Restrictions.eq(field,value).ignoreCase());
}

Fixed version (ground truth):
/** 
 * Creates criterion which checks if field is equal (using case-insensitive "eq" operator) to given value.
 * @param field field
 * @param value value
 * @return criterion
 */
public static SearchCriterion ieq(final String field,final Object value){
  return new SearchCriterionImpl(Restrictions.eq(field,value).ignoreCase());
}
Program: 39108
Project: 39108
Buggy source:
@Override public ValueAndError toObject(final FieldDefinition fieldDefinition,final Object value){
  if (value instanceof Date) {
    return ValueAndError.withoutError(value);
  }
  try {
    DateTimeFormatter fmt=DateTimeFormat.forPattern(DateUtils.L_DATE_FORMAT);
    DateTime dt=fmt.parseDateTime(String.valueOf(value));
    int year=dt.getYear();
    if (year < 1500 || year > 2500) {
      return ValueAndError.withoutError("String_Node_Str");
    }
    Date date=dt.toDate();
    if (year < 2000) {
      Calendar c=Calendar.getInstance();
      c.set(Calendar.YEAR,dt.getYear());
      c.set(Calendar.MONTH,dt.getMonthOfYear() - 1);
      c.set(Calendar.DAY_OF_MONTH,dt.getDayOfMonth());
      c.set(Calendar.HOUR_OF_DAY,dt.hourOfDay().get());
      c.set(Calendar.MINUTE,dt.getMinuteOfHour());
      c.set(Calendar.SECOND,dt.getSecondOfMinute());
      c.set(Calendar.MILLISECOND,dt.getMillisOfSecond());
      date=c.getTime();
    }
    return ValueAndError.withoutError(date);
  }
 catch (  IllegalArgumentException e) {
    return ValueAndError.withError("String_Node_Str");
  }
}

Fixed version (ground truth):
@Override public ValueAndError toObject(final FieldDefinition fieldDefinition,final Object value){
  if (value instanceof Date) {
    return ValueAndError.withoutError(value);
  }
  try {
    DateTimeFormatter fmt=DateTimeFormat.forPattern(DateUtils.L_DATE_FORMAT);
    DateTime dt=fmt.parseDateTime(String.valueOf(value));
    int year=dt.getYear();
    if (year < 1500 || year > 2500) {
      return ValueAndError.withError("String_Node_Str");
    }
    Date date=dt.toDate();
    if (year < 2000) {
      Calendar c=Calendar.getInstance();
      c.set(Calendar.YEAR,dt.getYear());
      c.set(Calendar.MONTH,dt.getMonthOfYear() - 1);
      c.set(Calendar.DAY_OF_MONTH,dt.getDayOfMonth());
      c.set(Calendar.HOUR_OF_DAY,dt.hourOfDay().get());
      c.set(Calendar.MINUTE,dt.getMinuteOfHour());
      c.set(Calendar.SECOND,dt.getSecondOfMinute());
      c.set(Calendar.MILLISECOND,dt.getMillisOfSecond());
      date=c.getTime();
    }
    return ValueAndError.withoutError(date);
  }
 catch (  IllegalArgumentException e) {
    return ValueAndError.withError("String_Node_Str");
  }
}
Program: 39109
Project: 39109
Buggy source:
private final void performWildcardTest(final String input,final String expectedOutput){
  SearchCriterion res=SearchRestrictions.like(FIELD_NAME,input);
  String actual=res.getHibernateCriterion().toString();
  String expected=FIELD_NAME + "String_Node_Str" + expectedOutput;
  assertEquals(expected,actual);
}

Fixed version (ground truth):
private void performWildcardTest(final String input,final String expectedOutput){
  SearchCriterion res=SearchRestrictions.like(FIELD_NAME,input);
  String actual=res.getHibernateCriterion().toString();
  String expected=FIELD_NAME + "String_Node_Str" + expectedOutput;
  assertEquals(expected,actual);
}
Program: 39111
Project: 39111
Buggy source:
@Override public String getPathFromUrl(final String url){
  String denormalizedUrl=denormalizeSeparators(url);
  return uploadDirectory.getAbsolutePath() + File.separator + denormalizedUrl.substring(denormalizedUrl.indexOf(File.separatorChar) + fileUrlPrefix.length() - 1);
}

Fixed version (ground truth):
@Override public String getPathFromUrl(final String url){
  String denormalizedUrl=denormalizeSeparators(url);
  return uploadDirectory.getAbsolutePath() + File.separator + denormalizedUrl.substring(denormalizedUrl.indexOf(File.separatorChar) + L_FILE_URL_PREFIX.length() - 1);
}
Program: 39112
Project: 39112
Buggy source:
@Override public String getUrl(final String path){
  if (!StringUtils.hasText(path)) {
    return null;
  }
  return fileUrlPrefix + normalizeSeparators(path.substring(uploadDirectory.getAbsolutePath().length() + 1));
}

Fixed version (ground truth):
@Override public String getUrl(final String path){
  if (!StringUtils.hasText(path)) {
    return null;
  }
  return L_FILE_URL_PREFIX + normalizeSeparators(path.substring(uploadDirectory.getAbsolutePath().length() + 1));
}
Program: 39113
Project: 39113
Buggy source:
private double getPosition(final Date dateFrom,final Date dateTo,final Date date){
  long tmFrom=dateFrom.getTime();
  long tmItem=date.getTime();
  long tmTo=dateTo.getTime();
  long dateFromOffset=getTimezoneOffset(dateFrom);
  long dateOffset=getTimezoneOffset(date);
  long dateToOffset=getTimezoneOffset(dateTo);
  if (dateFromOffset != dateToOffset) {
    tmTo+=(dateToOffset - dateFromOffset);
  }
  if (dateFromOffset != dateOffset) {
    tmItem+=(dateOffset - dateFromOffset);
  }
  int tmInterval=1000 * 60 * 60* interval;
  if (tmItem <= tmFrom) {
    return 0;
  }
  if (tmItem >= tmTo + 86400000L) {
    return (double)(tmTo - tmFrom) / tmInterval;
  }
  int region=(int)(tmItem - tmFrom) / tmInterval;
  long tmRegion=tmFrom + (tmInterval * region);
  return ((int)((region + ((double)(tmItem - tmRegion)) / tmInterval) * precision)) / (double)precision;
}

Fixed version (ground truth):
private double getPosition(final Date dateFrom,final Date dateTo,final Date date){
  long tmFrom=dateFrom.getTime();
  long tmItem=date.getTime();
  long tmTo=dateTo.getTime();
  long dateFromOffset=getTimezoneOffset(dateFrom);
  long dateOffset=getTimezoneOffset(date);
  long dateToOffset=getTimezoneOffset(dateTo);
  if (dateFromOffset != dateToOffset) {
    tmTo+=(dateToOffset - dateFromOffset);
  }
  if (dateFromOffset != dateOffset) {
    tmItem+=(dateOffset - dateFromOffset);
  }
  int tmInterval=1000 * 60 * 60* interval;
  if (tmItem <= tmFrom) {
    return 0;
  }
  if (tmItem >= tmTo + 86400000L) {
    return (double)(tmTo - tmFrom) / tmInterval;
  }
  int region=(int)(tmItem - tmFrom) / tmInterval;
  long tmRegion=tmFrom + (tmInterval * region);
  return ((int)((region + ((double)(tmItem - tmRegion)) / tmInterval) * PRECISION)) / (double)PRECISION;
}
Program: 39114
Project: 39114
Buggy source:
private void incrementLastChainCharacter(final Deque<String> chain,final int charNumber){
  chain.addLast(String.valueOf((char)(65 + charNumber)));
  chain.addLast("String_Node_Str");
}

Fixed version (ground truth):
public static void incrementLastChainCharacter(final Deque<String> chain,final int charNumber){
  int quotient=charNumber / 26;
  int modulo=charNumber % 26;
  if (quotient <= 0) {
    chain.addLast(String.valueOf((char)(65 + charNumber)));
  }
 else {
    chain.addLast(String.valueOf((char)(65 + (quotient - 1))).concat(String.valueOf((char)(65 + modulo))));
  }
  chain.addLast("String_Node_Str");
}
Program: 39115
Project: 39115
Buggy source:
private String convertCollectionToString(final Collection<String> collection){
  return StringUtils.join(collection,'.') + '.';
}

Fixed version (ground truth):
public static String convertCollectionToString(final Collection<String> collection){
  return StringUtils.join(collection,'.') + '.';
}
Program: 39116
Project: 39116
Buggy source:
private void incrementLastChainNumber(final Deque<String> chain){
  Integer nextNumber=Integer.valueOf(chain.pollLast()) + 1;
  chain.addLast(nextNumber.toString());
}

Fixed version (ground truth):
public static void incrementLastChainNumber(final Deque<String> chain){
  Integer nextNumber=Integer.valueOf(chain.pollLast()) + 1;
  chain.addLast(nextNumber.toString());
}
Program: 39118
Project: 39118
Buggy source:
private TreeNode createNode(final EntityTreeNode entityTreeNode,final Deque<String> nodeNumberChain){
  entityTreeNode.setField(NODE_NUMBER_FIELD,collectionToString(nodeNumberChain));
  List<EntityTreeNode> childs=entityTreeNode.getChildren();
  TreeDataType entityType=dataTypes.get(entityTreeNode.getEntityNoteType());
  String nodeLabel=ExpressionUtils.getValue(entityTreeNode,entityType.getNodeLabelExpression(),getLocale());
  TreeNode node=new TreeNode(entityTreeNode.getId(),nodeLabel,entityType);
  int charNumber=0;
  for (  EntityTreeNode childEntityTreeNode : childs) {
    Deque<String> newNodeNumberBranch=Lists.newLinkedList(nodeNumberChain);
    if (childs.size() == 1) {
      incrementLastChainNumber(newNodeNumberBranch);
    }
 else {
      incrementLastChainCharacter(newNodeNumberBranch,charNumber++);
    }
    node.addChild(createNode(childEntityTreeNode,newNodeNumberBranch));
  }
  return node;
}

Fixed version (ground truth):
private TreeNode createNode(final EntityTreeNode entityTreeNode,final Deque<String> nodeNumberChain){
  entityTreeNode.setField(NODE_NUMBER_FIELD,TreeNumberingServiceImpl.convertCollectionToString(nodeNumberChain));
  List<EntityTreeNode> childs=entityTreeNode.getChildren();
  TreeDataType entityType=dataTypes.get(entityTreeNode.getEntityNoteType());
  String nodeLabel=ExpressionUtils.getValue(entityTreeNode,entityType.getNodeLabelExpression(),getLocale());
  TreeNode node=new TreeNode(entityTreeNode.getId(),nodeLabel,entityType);
  int charNumber=0;
  for (  EntityTreeNode childEntityTreeNode : childs) {
    Deque<String> newNodeNumberBranch=Lists.newLinkedList(nodeNumberChain);
    if (childs.size() == 1) {
      TreeNumberingServiceImpl.incrementLastChainNumber(newNodeNumberBranch);
    }
 else {
      TreeNumberingServiceImpl.incrementLastChainCharacter(newNodeNumberBranch,charNumber++);
    }
    node.addChild(createNode(childEntityTreeNode,newNodeNumberBranch));
  }
  return node;
}
Program: 39119
Project: 39119
Buggy source:
@SuppressWarnings("String_Node_Str") private void reorganize(final Entity parent,final JSONArray childrens,final Deque<String> nodeNumberChain) throws JSONException {
  parent.setField(TreeType.NODE_NUMBER_FIELD,collectionToString(nodeNumberChain));
  int charNumber=0;
  for (int i=0; i < childrens.length(); i++) {
    Deque<String> newNodeNumberBranch=Lists.newLinkedList(nodeNumberChain);
    if (childrens.length() == 1) {
      incrementLastChainNumber(newNodeNumberBranch);
    }
 else {
      incrementLastChainCharacter(newNodeNumberBranch,charNumber++);
    }
    Entity nodeEntity=nodes.get(childrens.getJSONObject(i).getLong("String_Node_Str"));
    ((List<Entity>)parent.getField(CHILDREN)).add(nodeEntity);
    if (childrens.getJSONObject(i).has(CHILDREN)) {
      reorganize(nodeEntity,childrens.getJSONObject(i).getJSONArray(CHILDREN),newNodeNumberBranch);
    }
  }
}

Fixed version (ground truth):
@SuppressWarnings("String_Node_Str") private void reorganize(final Entity parent,final JSONArray childrens,final Deque<String> nodeNumberChain) throws JSONException {
  parent.setField(TreeType.NODE_NUMBER_FIELD,TreeNumberingServiceImpl.convertCollectionToString(nodeNumberChain));
  int charNumber=0;
  for (int i=0; i < childrens.length(); i++) {
    Deque<String> newNodeNumberBranch=Lists.newLinkedList(nodeNumberChain);
    if (childrens.length() == 1) {
      TreeNumberingServiceImpl.incrementLastChainNumber(newNodeNumberBranch);
    }
 else {
      TreeNumberingServiceImpl.incrementLastChainCharacter(newNodeNumberBranch,charNumber++);
    }
    Entity nodeEntity=nodes.get(childrens.getJSONObject(i).getLong("String_Node_Str"));
    ((List<Entity>)parent.getField(CHILDREN)).add(nodeEntity);
    if (childrens.getJSONObject(i).has(CHILDREN)) {
      reorganize(nodeEntity,childrens.getJSONObject(i).getJSONArray(CHILDREN),newNodeNumberBranch);
    }
  }
}
Program: 39120
Project: 39120
Buggy source:
private void clearHolder(){
  Iterator<?> iterator=filterValue.keys();
  while (iterator.hasNext()) {
    String key=iterator.next().toString();
    filterValue.remove(key);
  }
  empty=true;
}

Fixed version (ground truth):
private void clearHolder(){
  Iterator<?> iterator=filterValue.keys();
  List<String> entrysToRemove=Lists.newArrayList();
  while (iterator.hasNext()) {
    entrysToRemove.add(iterator.next().toString());
  }
  for (  String key : entrysToRemove) {
    filterValue.remove(key);
  }
  empty=true;
}
Program: 39121
Project: 39121
Buggy source:
public Object getValue(){
  return value;
}

Fixed version (ground truth):
/** 
 * Returns parsed value
 * @return parsed value
 */
public Object getValue(){
  return value;
}
Program: 39122
Project: 39122
Buggy source:
public static ValueAndError withoutError(final Object value){
  return new ValueAndError(value,null);
}

Fixed version (ground truth):
/** 
 * Build and returns new instance of   {@link ValueAndError} with given
 * @param value
 * @return new instance of {@link ValueAndError}
 */
public static ValueAndError withoutError(final Object value){
  return new ValueAndError(value,null);
}
Program: 39123
Project: 39123
Buggy source:
public static ValueAndError withError(final String message,final String... args){
  return new ValueAndError(null,message,args);
}

Fixed version (ground truth):
/** 
 * Build and returns new instance of   {@link ValueAndError} with given message and args
 * @param message error message
 * @param args error message arguments (values which will replace message's place holders)
 * @return new instance of {@link ValueAndError}
 */
public static ValueAndError withError(final String message,final String... args){
  return new ValueAndError(null,message,args);
}
Program: 39124
Project: 39124
Buggy source:
public boolean isValid(){
  return message == null;
}

Fixed version (ground truth):
/** 
 * Checks if value is valid.
 * @return true if field value is valid. Otherwise false.
 */
public boolean isValid(){
  return message == null;
}
Program: 39125
Project: 39125
Buggy source:
public String getMessage(){
  return message;
}

Fixed version (ground truth):
/** 
 * Returns error message
 * @return error message
 */
public String getMessage(){
  return message;
}
Program: 39126
Project: 39126
Buggy source:
public String[] getArgs(){
  return Arrays.copyOf(args,args.length);
}

Fixed version (ground truth):
/** 
 * Returns error message arguments (values which will replace message's place holders)
 * @return error message arguments (values which will replace message's place holders)
 */
public String[] getArgs(){
  return Arrays.copyOf(args,args.length);
}
Program: 39127
Project: 39127
Buggy source:
public static ValueAndError empty(){
  return new ValueAndError(null,null);
}

Fixed version (ground truth):
/** 
 * Returns empty   {@link ValueAndError} object
 * @return empty {@link ValueAndError} object
 */
public static ValueAndError empty(){
  return EMPTY_VALUE_AND_ERROR;
}
Program: 39128
Project: 39128
Buggy source:
@Override public boolean call(final Entity entity,final Object oldValue,final Object newValue){
  boolean result=fieldHook.call(entity,oldValue,newValue);
  if (result) {
    return true;
  }
  entity.addError(fieldDefinition,errorMessage);
  return false;
}

Fixed version (ground truth):
@Override public boolean call(final Entity entity,final Object oldValue,final Object newValue){
  if (fieldHook.call(entity,oldValue,newValue)) {
    return true;
  }
  if (entity.getError(fieldDefinition.getName()) == null) {
    entity.addError(fieldDefinition,errorMessage);
  }
  return false;
}
Program: 39129
Project: 39129
Buggy source:
private Object parseAndValidateField(final InternalFieldDefinition fieldDefinition,final Object value,final Entity validatedEntity){
  FieldType fieldType=fieldDefinition.getType();
  if (fieldType instanceof HasManyType || fieldType instanceof TreeType || fieldType instanceof ManyToManyType) {
    return value;
  }
 else {
    return parseAndValidateValue(fieldDefinition,trimAndNullIfEmpty(value),validatedEntity);
  }
}

Fixed version (ground truth):
private Object parseAndValidateField(final InternalFieldDefinition fieldDefinition,final Object newValue,final Entity validatedEntity,final Object oldValue){
  FieldType fieldType=fieldDefinition.getType();
  Object parsedValue;
  if (fieldType instanceof HasManyType || fieldType instanceof TreeType || fieldType instanceof ManyToManyType) {
    parsedValue=newValue;
  }
 else {
    parsedValue=parseValue(fieldDefinition,trimAndNullIfEmpty(newValue),validatedEntity,oldValue);
  }
  if (validatedEntity.isFieldValid(fieldDefinition.getName()) && fieldDefinition.callValidators(validatedEntity,oldValue,parsedValue)) {
    return parsedValue;
  }
 else {
    return null;
  }
}
Program: 39130
Project: 39130
Buggy source:
private void parseAndValidateEntity(final InternalDataDefinition dataDefinition,final Entity genericEntity){
  for (  Entry<String,FieldDefinition> fieldDefinitionEntry : dataDefinition.getFields().entrySet()) {
    Object validateFieldValue=parseAndValidateField((InternalFieldDefinition)fieldDefinitionEntry.getValue(),genericEntity.getField(fieldDefinitionEntry.getKey()),genericEntity);
    genericEntity.setField(fieldDefinitionEntry.getKey(),validateFieldValue);
  }
  for (  Entry<String,FieldDefinition> fieldDefinitionEntry : dataDefinition.getFields().entrySet()) {
    if (!genericEntity.isFieldValid(fieldDefinitionEntry.getKey())) {
      continue;
    }
    ((InternalFieldDefinition)fieldDefinitionEntry.getValue()).callValidators(genericEntity,null,genericEntity.getField(fieldDefinitionEntry.getKey()));
  }
  if (genericEntity.isValid()) {
    dataDefinition.callValidators(genericEntity);
  }
}

Fixed version (ground truth):
private void parseAndValidateEntity(final InternalDataDefinition dataDefinition,final Entity genericEntity,final Entity existingGenericEntity){
  for (  Entry<String,FieldDefinition> fieldDefinitionEntry : dataDefinition.getFields().entrySet()) {
    final String fieldName=fieldDefinitionEntry.getKey();
    final Object newValue=genericEntity.getField(fieldName);
    final Object oldValue=getOldFieldValue(existingGenericEntity,fieldName);
    final InternalFieldDefinition fieldDefinition=(InternalFieldDefinition)fieldDefinitionEntry.getValue();
    final Object validatedFieldValue=parseAndValidateField(fieldDefinition,newValue,genericEntity,oldValue);
    genericEntity.setField(fieldName,validatedFieldValue);
  }
  if (genericEntity.isValid()) {
    dataDefinition.callValidators(genericEntity);
  }
}
Program: 39131
Project: 39131
Buggy source:
@Override public void validateGenericEntity(final InternalDataDefinition dataDefinition,final Entity genericEntity,final Entity existingGenericEntity){
  copyReadOnlyAndMissingFields(dataDefinition,genericEntity,existingGenericEntity);
  parseFields(dataDefinition,genericEntity);
  if (genericEntity.getId() == null) {
    dataDefinition.callCreateHook(genericEntity);
    parseAndValidateEntity(dataDefinition,genericEntity);
  }
 else {
    parseAndValidateEntity(dataDefinition,genericEntity);
    dataDefinition.callUpdateHook(genericEntity);
  }
  dataDefinition.callSaveHook(genericEntity);
}

Fixed version (ground truth):
@Override public void validateGenericEntity(final InternalDataDefinition dataDefinition,final Entity genericEntity,final Entity existingGenericEntity){
  copyReadOnlyAndMissingFields(dataDefinition,genericEntity,existingGenericEntity);
  parseFields(dataDefinition,genericEntity);
  if (genericEntity.getId() == null) {
    dataDefinition.callCreateHook(genericEntity);
    parseAndValidateEntity(dataDefinition,genericEntity,existingGenericEntity);
  }
 else {
    parseAndValidateEntity(dataDefinition,genericEntity,existingGenericEntity);
    dataDefinition.callUpdateHook(genericEntity);
  }
  dataDefinition.callSaveHook(genericEntity);
}
Program: 39132
Project: 39132
Buggy source:
/** 
 * Set scale 5 to   {@link BigDecimal} with RoundingMode HALF_EVEN.
 * @param decimal
 * @return BigDecimal with scale 5.
 */
BigDecimal setScale(BigDecimal decimal);

Fixed version (ground truth):
/** 
 * Set scale 5 to   {@link BigDecimal} with RoundingMode HALF_EVEN.
 * @param decimal
 * @return BigDecimal with scale 5.
 */
BigDecimal setScale(final BigDecimal decimal);
Program: 39133
Project: 39133
Buggy source:
/** 
 * Formats an object with DecimalFormat to produce a String.
 * @param obj
 * @return Formatted string.
 */
String format(Object obj);

Fixed version (ground truth):
/** 
 * Formats an object with DecimalFormat to produce a String.
 * @param obj
 * @return Formatted string.
 */
String format(final Object obj);
Program: 39134
Project: 39134
Buggy source:
@Override public String toString(final Object value,final Locale locale){
  NumberFormat format=null;
  if (locale == null) {
    format=NumberFormat.getNumberInstance();
  }
 else {
    format=NumberFormat.getNumberInstance(locale);
  }
  format.setMaximumFractionDigits(5);
  return format.format(value);
}

Fixed version (ground truth):
@Override public String toString(final Object value,final Locale locale){
  if (value == null) {
    return "String_Node_Str";
  }
  NumberFormat format=null;
  if (locale == null) {
    format=NumberFormat.getNumberInstance();
  }
 else {
    format=NumberFormat.getNumberInstance(locale);
  }
  format.setMaximumFractionDigits(getMaxFractionDigits(value));
  return format.format(value);
}
Program: 39135
Project: 39135
Buggy source:
@Override public ValueAndError toObject(final FieldDefinition fieldDefinition,final Object value){
  BigDecimal decimal=null;
  if (value instanceof BigDecimal) {
    decimal=(BigDecimal)value;
  }
 else {
    try {
      decimal=new BigDecimal(String.valueOf(value));
    }
 catch (    NumberFormatException e) {
      return ValueAndError.withError("String_Node_Str");
    }
  }
  return ValueAndError.withoutError(decimal);
}

Fixed version (ground truth):
@Override public ValueAndError toObject(final FieldDefinition fieldDefinition,final Object value){
  BigDecimal decimal=null;
  if (value instanceof BigDecimal) {
    decimal=((BigDecimal)value).stripTrailingZeros();
  }
 else {
    try {
      decimal=new BigDecimal(String.valueOf(value)).stripTrailingZeros();
    }
 catch (    NumberFormatException e) {
      return ValueAndError.withError("String_Node_Str");
    }
  }
  return ValueAndError.withoutError(decimal);
}