Program: 74225
Project: 74225
Buggy source:
protected void generateContent(ExtendedItemDesign item,IForeignContent content){
  ExtendedItemHandle handle=(ExtendedItemHandle)item.getHandle();
  String name=item.getName();
  byte[] generationStatus=null;
  if (itemGeneration != null) {
    itemGeneration.setModelObject(handle);
    itemGeneration.setApplicationClassLoader(context.getApplicationClassLoader());
    itemGeneration.setScriptContext(context.getReportContext());
    IBaseQueryDefinition[] queries=(IBaseQueryDefinition[])((ExtendedItemDesign)item).getQueries();
    itemGeneration.setReportQueries(queries);
    itemGeneration.setExtendedItemContent(content);
    try {
      IBaseResultSet[] resultSets=rsets;
      if (resultSets == null) {
        IBaseResultSet prset=getParentResultSet();
        if (prset != null) {
          int rsetType=prset.getType();
          if (rsetType == IBaseResultSet.QUERY_RESULTSET) {
            resultSets=new IBaseResultSet[1];
            resultSets[0]=new SingleQueryResultSet((IQueryResultSet)prset);
          }
 else           if (rsetType == IBaseResultSet.CUBE_RESULTSET) {
            resultSets=new IBaseResultSet[1];
            resultSets[0]=new SingleCubeResultSet((ICubeResultSet)prset);
          }
        }
      }
      itemGeneration.onRowSets(resultSets);
      if (itemGeneration.needSerialization()) {
        ByteArrayOutputStream out=new ByteArrayOutputStream();
        itemGeneration.serialize(out);
        generationStatus=out.toByteArray();
      }
      itemGeneration.finish();
    }
 catch (    BirtException ex) {
      logger.log(Level.SEVERE,ex.getMessage(),ex);
      context.addException(new EngineException(MessageConstants.EXTENDED_ITEM_GENERATION_ERROR,handle.getExtensionName() + (name != null ? "String_Node_Str" + name : "String_Node_Str"),ex));
    }
  }
 else {
  }
  content.setRawType(IForeignContent.EXTERNAL_TYPE);
  content.setRawValue(generationStatus);
}

Fixed version (ground truth):
protected void generateContent(ExtendedItemDesign item,IForeignContent content){
  ExtendedItemHandle handle=(ExtendedItemHandle)item.getHandle();
  String name=item.getName();
  byte[] generationStatus=null;
  if (itemGeneration != null) {
    IBaseQueryDefinition[] queries=(IBaseQueryDefinition[])((ExtendedItemDesign)item).getQueries();
    ReportItemGenerationInfo info=new ReportItemGenerationInfo();
    info.setModelObject(handle);
    info.setReportContext(context.getReportContext());
    info.setReportQueries(queries);
    info.setExtendedItemContent(content);
    itemGeneration.init(info);
    try {
      IBaseResultSet[] resultSets=rsets;
      if (resultSets == null) {
        IBaseResultSet prset=getParentResultSet();
        if (prset != null) {
          int rsetType=prset.getType();
          if (rsetType == IBaseResultSet.QUERY_RESULTSET) {
            resultSets=new IBaseResultSet[1];
            resultSets[0]=new SingleQueryResultSet((IQueryResultSet)prset);
          }
 else           if (rsetType == IBaseResultSet.CUBE_RESULTSET) {
            resultSets=new IBaseResultSet[1];
            resultSets[0]=new SingleCubeResultSet((ICubeResultSet)prset);
          }
        }
      }
      itemGeneration.onRowSets(resultSets);
      if (itemGeneration.needSerialization()) {
        ByteArrayOutputStream out=new ByteArrayOutputStream();
        itemGeneration.serialize(out);
        generationStatus=out.toByteArray();
      }
      itemGeneration.finish();
    }
 catch (    BirtException ex) {
      logger.log(Level.SEVERE,ex.getMessage(),ex);
      context.addException(new EngineException(MessageConstants.EXTENDED_ITEM_GENERATION_ERROR,handle.getExtensionName() + (name != null ? "String_Node_Str" + name : "String_Node_Str"),ex));
    }
  }
 else {
  }
  content.setRawType(IForeignContent.EXTERNAL_TYPE);
  content.setRawValue(generationStatus);
}