Program: 26451
Project: 26451
Buggy source:
/** 
 * <p> Get the a custom report for the given key and data. Rather than creating a single chart with a line/bar for each type, this function creates a chart for <em>each</em> type that matches the given definition. </p> <p> This function uses all charts in the given report so it is possible for this function to create a large number of charts, especially if multiple DataTypes and/or fields are matched. </p>
 * @param filterByData should the initial reports list be filtered by the given data? See {@link #getReport(String,Iterable)}.
 */
public List<BaseChartDefinition> multiplexChartsAcrossTypes(String key,DataSet data,boolean filterByData){
  List<BaseChartDefinition> chartDefinitions=null;
  if (filterByData) {
    chartDefinitions=getReport(key,java.util.Collections.singletonList(data));
  }
 else {
    chartDefinitions=getReport(key);
  }
  LOGGER.debug("String_Node_Str",chartDefinitions,data.getHostname());
  List<BaseChartDefinition> multiplexedChartDefinitions=new java.util.ArrayList<BaseChartDefinition>(10 * chartDefinitions.size());
  for (  BaseChartDefinition chartDefinition : chartDefinitions) {
    for (    DataDefinition dataDefinition : chartDefinition.getData()) {
      if (dataDefinition.matchesHost(data)) {
        for (        DataType type : dataDefinition.getMatchingTypes(data)) {
          BaseChartDefinition newChartDefinition=copyChart(chartDefinition);
          newChartDefinition.setShortName(chartDefinition.getShortName() + "String_Node_Str" + dataDefinition.renameType(type));
          newChartDefinition.setTitle(chartDefinition.getTitle());
          newChartDefinition.setSubtitleNamingMode(NamingMode.TYPE);
          DataDefinition newData=null;
          if (dataDefinition instanceof DefaultDataDefinition) {
            DefaultDataDefinition old=(DefaultDataDefinition)dataDefinition;
            newData=old.withNewTypes(new ExactTypeMatcher(type.toString()));
          }
 else {
            newData=new ExactDataDefinition(data,type,dataDefinition.getMatchingFields(type),dataDefinition.getStatistic(),dataDefinition.usesSecondaryYAxis());
          }
          newChartDefinition.addData(newData);
          multiplexedChartDefinitions.add(newChartDefinition);
        }
      }
    }
  }
  if (LOGGER.isDebugEnabled()) {
    LOGGER.debug("String_Node_Str",new Object[]{chartDefinitions,data.getHostname(),multiplexedChartDefinitions});
  }
  return multiplexedChartDefinitions;
}

Fixed version (ground truth):
/** 
 * <p> Get the a custom report for the given key and data. Rather than creating a single chart with a line/bar for each type, this function creates a chart for <em>each</em> type that matches the given definition. </p> <p> This function uses all charts in the given report so it is possible for this function to create a large number of charts, especially if multiple DataTypes and/or fields are matched. </p>
 * @param filterByData should the initial reports list be filtered by the given data? See{@link #getReport(String,Iterable)}.
 */
public List<BaseChartDefinition> multiplexChartsAcrossTypes(String key,DataSet data,boolean filterByData){
  List<BaseChartDefinition> chartDefinitions=null;
  if (filterByData) {
    chartDefinitions=getReport(key,java.util.Collections.singletonList(data));
  }
 else {
    chartDefinitions=getReport(key);
  }
  LOGGER.debug("String_Node_Str",chartDefinitions,data.getHostname());
  List<BaseChartDefinition> multiplexedChartDefinitions=new java.util.ArrayList<BaseChartDefinition>(10 * chartDefinitions.size());
  for (  BaseChartDefinition chartDefinition : chartDefinitions) {
    for (    DataDefinition dataDefinition : chartDefinition.getData()) {
      if (dataDefinition.matchesHost(data)) {
        for (        DataType type : dataDefinition.getMatchingTypes(data)) {
          BaseChartDefinition newChartDefinition=copyChart(chartDefinition);
          newChartDefinition.setShortName(chartDefinition.getShortName() + "String_Node_Str" + dataDefinition.renameType(type));
          newChartDefinition.setTitle(chartDefinition.getTitle());
          newChartDefinition.setSubtitleNamingMode(NamingMode.TYPE);
          DataDefinition newData=null;
          if (dataDefinition instanceof DefaultDataDefinition) {
            DefaultDataDefinition old=(DefaultDataDefinition)dataDefinition;
            newData=old.withNewTypes(new ExactTypeMatcher(type.toString()));
          }
 else {
            newData=new ExactDataDefinition(data,type,dataDefinition.getMatchingFields(type),dataDefinition.getStatistic(),dataDefinition.usesSecondaryYAxis());
          }
          newChartDefinition.addData(newData);
          multiplexedChartDefinitions.add(newChartDefinition);
        }
      }
    }
  }
  if (LOGGER.isDebugEnabled()) {
    LOGGER.debug("String_Node_Str",new Object[]{chartDefinitions,data.getHostname(),multiplexedChartDefinitions});
  }
  return multiplexedChartDefinitions;
}