Program: 59399
Project: 59399
Buggy source:
/** 
 * Populate a   {@link DataSet} from given entity list.<p/> Field values will be converted to String using given {@link ConversionService} and Date fields will be converted to Date using{@link DateFormat} with given date patterns.
 * @param entities List of T entities to convert to Datatables data
 * @param pkFieldName The T entity field that contains the PK
 * @param totalRecords Total amount of records
 * @param totalDisplayRecords Amount of records found
 * @param columns {@link ColumnDef} list
 * @param datePatterns Patterns to convert Date fields to String. The Mapcontains one pattern for each entity Date field keyed by field name. For Roo compatibility the key could follow the pattern {@code lower_case( ENTITY ) + "_" + lower_case( FIELD ) + "_date_format"}too
 * @param conversionService
 * @return
 */
public static <T>DataSet<Map<String,String>> populateDataSet(List<T> entities,String pkFieldName,long totalRecords,long totalDisplayRecords,List<ColumnDef> columns,Map<String,Object> datePatterns,ConversionService conversionService){
  Assert.notNull(pkFieldName);
  Assert.notNull(columns);
  Assert.notNull(conversionService);
  List<Map<String,String>> rows=new ArrayList<Map<String,String>>(entities.size());
  if (CollectionUtils.isEmpty(entities)) {
    return new DataSet<Map<String,String>>(rows,0l,0l);
  }
  if (CollectionUtils.isEmpty(datePatterns)) {
    datePatterns=new HashMap<String,Object>();
  }
  Set<String> fields=new HashSet<String>();
  fields.add(pkFieldName);
  for (  ColumnDef colum : columns) {
    fields.add(colum.getName());
  }
  DateFormat defaultFormat=SimpleDateFormat.getDateInstance();
  for (  Object entity : entities) {
    Map<String,String> row=new HashMap<String,String>(fields.size());
    BeanWrapper entityBean=new BeanWrapperImpl(entity);
    for (    String fieldName : fields) {
      if (!entityBean.isReadableProperty(fieldName)) {
        logger.debug("String_Node_Str".concat(fieldName).concat("String_Node_Str").concat(entity.toString()).concat("String_Node_Str"));
        continue;
      }
      Object value=null;
      String valueStr=null;
      try {
        value=entityBean.getPropertyValue(fieldName);
        if (value != null) {
          if (Calendar.class.isAssignableFrom(value.getClass())) {
            value=((Calendar)value).getTime();
          }
          if (Date.class.isAssignableFrom(value.getClass())) {
            String pattern=getPattern(datePatterns,entityBean.getWrappedClass(),fieldName);
            DateFormat format=StringUtils.isEmpty(pattern) ? defaultFormat : new SimpleDateFormat(pattern);
            valueStr=format.format(value);
          }
 else           if (conversionService.canConvert(value.getClass(),String.class)) {
            valueStr=conversionService.convert(value,String.class);
          }
 else {
            valueStr=ObjectUtils.getDisplayString(value);
          }
        }
 else {
          valueStr="String_Node_Str";
        }
      }
 catch (      Exception ex) {
        logger.error("String_Node_Str".concat(fieldName).concat("String_Node_Str").concat("String_Node_Str").concat(entity.toString()).concat("String_Node_Str"),ex);
      }
      row.put(fieldName,valueStr);
      if (pkFieldName.equalsIgnoreCase(fieldName)) {
        row.put("String_Node_Str",valueStr);
      }
    }
    rows.add(row);
  }
  DataSet<Map<String,String>> dataSet=new DataSet<Map<String,String>>(rows,totalRecords,totalDisplayRecords);
  return dataSet;
}

Fixed version (ground truth):
/** 
 * Populate a   {@link DataSet} from given entity list.<p/> Field values will be converted to String using given {@link ConversionService} and Date fields will be converted to Date using{@link DateFormat} with given date patterns.
 * @param entities List of T entities to convert to Datatables data
 * @param pkFieldName The T entity field that contains the PK
 * @param totalRecords Total amount of records
 * @param totalDisplayRecords Amount of records found
 * @param columns {@link ColumnDef} list
 * @param datePatterns Patterns to convert Date fields to String. The Mapcontains one pattern for each entity Date field keyed by field name. For Roo compatibility the key could follow the pattern {@code ENTITY + "_" + lower_case( FIELD ) + "_date_format"} too
 * @param conversionService
 * @return
 */
public static <T>DataSet<Map<String,String>> populateDataSet(List<T> entities,String pkFieldName,long totalRecords,long totalDisplayRecords,List<ColumnDef> columns,Map<String,Object> datePatterns,ConversionService conversionService){
  Assert.notNull(pkFieldName);
  Assert.notNull(columns);
  Assert.notNull(conversionService);
  List<Map<String,String>> rows=new ArrayList<Map<String,String>>(entities.size());
  if (CollectionUtils.isEmpty(entities)) {
    return new DataSet<Map<String,String>>(rows,0l,0l);
  }
  if (CollectionUtils.isEmpty(datePatterns)) {
    datePatterns=new HashMap<String,Object>();
  }
  Set<String> fields=new HashSet<String>();
  fields.add(pkFieldName);
  for (  ColumnDef colum : columns) {
    fields.add(colum.getName());
  }
  DateFormat defaultFormat=SimpleDateFormat.getDateInstance();
  for (  Object entity : entities) {
    Map<String,String> row=new HashMap<String,String>(fields.size());
    BeanWrapper entityBean=new BeanWrapperImpl(entity);
    for (    String fieldName : fields) {
      if (!entityBean.isReadableProperty(fieldName)) {
        logger.debug("String_Node_Str".concat(fieldName).concat("String_Node_Str").concat(entity.toString()).concat("String_Node_Str"));
        continue;
      }
      Object value=null;
      String valueStr=null;
      try {
        value=entityBean.getPropertyValue(fieldName);
        if (value != null) {
          if (Calendar.class.isAssignableFrom(value.getClass())) {
            value=((Calendar)value).getTime();
          }
          if (Date.class.isAssignableFrom(value.getClass())) {
            String pattern=getPattern(datePatterns,entityBean.getWrappedClass(),fieldName);
            DateFormat format=StringUtils.isEmpty(pattern) ? defaultFormat : new SimpleDateFormat(pattern);
            valueStr=format.format(value);
          }
 else           if (conversionService.canConvert(value.getClass(),String.class)) {
            valueStr=conversionService.convert(value,String.class);
          }
 else {
            valueStr=ObjectUtils.getDisplayString(value);
          }
        }
 else {
          valueStr="String_Node_Str";
        }
      }
 catch (      Exception ex) {
        logger.error("String_Node_Str".concat(fieldName).concat("String_Node_Str").concat("String_Node_Str").concat(entity.toString()).concat("String_Node_Str"),ex);
      }
      row.put(fieldName,valueStr);
      if (pkFieldName.equalsIgnoreCase(fieldName)) {
        row.put("String_Node_Str",valueStr);
      }
    }
    rows.add(row);
  }
  DataSet<Map<String,String>> dataSet=new DataSet<Map<String,String>>(rows,totalRecords,totalDisplayRecords);
  return dataSet;
}