Program: 68292
Project: 68292
Buggy source:
/** 
 * Generate share bindings with table into query.
 * @param headers
 * @param queryDefn
 * @param session
 * @param bindingExprsMap
 * @return
 * @throws AdapterException
 * @throws DataException
 */
private List<String> generateShareBindingsWithTable(ColumnBindingInfo[] headers,QueryDefinition queryDefn,DataRequestSession session,Map<String,String> bindingExprsMap) throws AdapterException, DataException {
  List<String> columns=new ArrayList<String>();
  ReportItemHandle reportItemHandle=getReportItemHandle();
  if (isInheritColumnsGroups()) {
    reportItemHandle=findListingInheritance();
  }
  queryDefn.setDataSetName(reportItemHandle.getDataSet().getQualifiedName());
  IModelAdapter modelAdapter=session.getModelAdaptor();
  for (int i=0; i < headers.length; i++) {
    ColumnBindingInfo chi=headers[i];
    int type=chi.getColumnType();
switch (type) {
case ColumnBindingInfo.COMMON_COLUMN:
case ColumnBindingInfo.AGGREGATE_COLUMN:
      IBinding binding=modelAdapter.adaptBinding((ComputedColumnHandle)chi.getObjectHandle());
    queryDefn.addBinding(binding);
  columns.add(binding.getBindingName());
bindingExprsMap.put(chi.getExpression(),binding.getBindingName());
break;
case ColumnBindingInfo.GROUP_COLUMN:
GroupDefinition gd=modelAdapter.adaptGroup((GroupHandle)chi.getObjectHandle());
queryDefn.addGroup(gd);
String name=StructureFactory.newComputedColumn(reportItemHandle,gd.getName()).getName();
binding=new Binding(name);
binding.setExpression(modelAdapter.adaptExpression(ChartReportItemUtil.getExpression((GroupHandle)chi.getObjectHandle())));
queryDefn.addBinding(binding);
columns.add(name);
bindingExprsMap.put(((ScriptExpression)binding.getExpression()).getText(),binding.getBindingName());
break;
}
}
if (reportItemHandle instanceof ListingHandle) {
queryDefn.getSorts().addAll(ChartBaseQueryHelper.createSorts(((ListingHandle)reportItemHandle).sortsIterator(),modelAdapter));
}
return columns;
}

Fixed version (ground truth):
/** 
 * Generate share bindings with table into query.
 * @param headers
 * @param queryDefn
 * @param session
 * @param bindingExprsMap
 * @return
 * @throws AdapterException
 * @throws DataException
 */
private List<String> generateShareBindingsWithTable(ColumnBindingInfo[] headers,QueryDefinition queryDefn,DataRequestSession session,Map<String,String> bindingExprsMap) throws AdapterException, DataException {
  List<String> columns=new ArrayList<String>();
  ReportItemHandle reportItemHandle=getReportItemHandle();
  if (isInheritColumnsGroups()) {
    reportItemHandle=findListingInheritance();
  }
  queryDefn.setDataSetName(reportItemHandle.getDataSet().getQualifiedName());
  IModelAdapter modelAdapter=session.getModelAdaptor();
  for (int i=0; i < headers.length; i++) {
    ColumnBindingInfo chi=headers[i];
    int type=chi.getColumnType();
switch (type) {
case ColumnBindingInfo.COMMON_COLUMN:
case ColumnBindingInfo.AGGREGATE_COLUMN:
      IBinding binding=modelAdapter.adaptBinding((ComputedColumnHandle)chi.getObjectHandle());
    queryDefn.addBinding(binding);
  columns.add(binding.getBindingName());
bindingExprsMap.put(chi.getExpression(),binding.getBindingName());
break;
case ColumnBindingInfo.GROUP_COLUMN:
GroupDefinition gd=modelAdapter.adaptGroup((GroupHandle)chi.getObjectHandle());
queryDefn.addGroup(gd);
String name=StructureFactory.newComputedColumn(reportItemHandle,gd.getName()).getName();
binding=new Binding(name);
binding.setExpression(modelAdapter.adaptExpression(ChartReportItemUtil.getExpression((GroupHandle)chi.getObjectHandle())));
queryDefn.addBinding(binding);
columns.add(name);
bindingExprsMap.put(((ScriptExpression)binding.getExpression()).getText(),binding.getBindingName());
break;
}
}
if (reportItemHandle instanceof ListingHandle) {
queryDefn.getSorts().addAll(ChartBaseQueryHelper.createSorts(((ListingHandle)reportItemHandle).sortsIterator()));
}
return columns;
}