nus-yam/ex-repair huggingface dataset:
Program: 69545
Project: 69545
Buggy source:
public IPageHint readFixedLayoutPageHint(DataInputStream in) throws IOException {
  long pageNumber=IOUtil.readLong(in);
  String masterPage=IOUtil.readString(in);
  PageHint hint=new PageHint(pageNumber,masterPage);
  hint.setOffset(pageIndexReader.getPageOffset(masterPage));
  int sectionCount=IOUtil.readInt(in);
  for (int i=0; i < sectionCount; i++) {
    PageSection section=null;
    int sectionType=IOUtil.readInt(in);
    if (sectionType == PageSection.TYPE_FIXED_LAYOUT_PAGE_SECTION) {
      section=new SizeBasedPageSection();
    }
 else {
      section=new PageSection();
    }
    section.read(in);
    hint.addSection(section);
  }
  int hintSize=IOUtil.readInt(in);
  for (int i=0; i < hintSize; i++) {
    UnresolvedRowHint rowHint=new UnresolvedRowHint();
    rowHint.readObject(new DataInputStream(in));
    hint.addUnresolvedRowHint(rowHint);
  }
  int columnHintSize=IOUtil.readInt(in);
  for (int i=0; i < columnHintSize; i++) {
    String tableId=IOUtil.readString(in);
    int start=IOUtil.readInt(in);
    int columnCount=IOUtil.readInt(in);
    hint.addTableColumnHint(new TableColumnHint(tableId,start,columnCount));
  }
  return hint;
}

Fixed version (ground truth):
public IPageHint readFixedLayoutPageHint(DataInputStream in) throws IOException {
  long pageNumber=IOUtil.readLong(in);
  String masterPage=IOUtil.readString(in);
  PageHint hint=new PageHint(pageNumber,masterPage);
  hint.setOffset(pageIndexReader.getPageOffset(masterPage));
  int sectionCount=IOUtil.readInt(in);
  for (int i=0; i < sectionCount; i++) {
    PageSection section=null;
    int sectionType=IOUtil.readInt(in);
    if (sectionType == PageSection.TYPE_FIXED_LAYOUT_PAGE_SECTION) {
      section=new SizeBasedPageSection();
    }
 else {
      section=new PageSection();
    }
    section.read(in);
    hint.addSection(section);
  }
  int hintSize=IOUtil.readInt(in);
  for (int i=0; i < hintSize; i++) {
    UnresolvedRowHint rowHint=new UnresolvedRowHint();
    rowHint.readObject(new DataInputStream(in));
    hint.addUnresolvedRowHint(rowHint);
  }
  int columnHintSize=IOUtil.readInt(in);
  for (int i=0; i < columnHintSize; i++) {
    String tableId=IOUtil.readString(in);
    int start=IOUtil.readInt(in);
    int columnCount=IOUtil.readInt(in);
    hint.addTableColumnHint(new TableColumnHint(tableId,start,columnCount));
  }
  Collection<PageVariable> variables=hint.getPageVariables();
  readPageVariables(in,variables);
  return hint;
}
Program: 69546
Project: 69546
Buggy source:
protected void writePageHint(DataOutputStream out,IPageHint hint) throws IOException {
  IOUtil.writeLong(out,hint.getPageNumber());
  IOUtil.writeString(out,hint.getMasterPage());
  int sectionCount=hint.getSectionCount();
  IOUtil.writeInt(out,sectionCount);
  for (int i=0; i < sectionCount; i++) {
    PageSection section=hint.getSection(i);
    section.write(out);
  }
  int hintSize=hint.getUnresolvedRowCount();
  IOUtil.writeInt(out,hintSize);
  ;
  for (int i=0; i < hintSize; i++) {
    UnresolvedRowHint rowHint=hint.getUnresolvedRowHint(i);
    rowHint.writeObject(out);
  }
  int columnHintSize=hint.getTableColumnHintCount();
  IOUtil.writeInt(out,columnHintSize);
  for (int i=0; i < columnHintSize; i++) {
    TableColumnHint columnHint=hint.getTableColumnHint(i);
    IOUtil.writeString(out,columnHint.getTableId());
    IOUtil.writeInt(out,columnHint.getStart());
    IOUtil.writeInt(out,columnHint.getColumnCount());
  }
}

Fixed version (ground truth):
protected void writePageHint(DataOutputStream out,IPageHint hint) throws IOException {
  IOUtil.writeLong(out,hint.getPageNumber());
  IOUtil.writeString(out,hint.getMasterPage());
  int sectionCount=hint.getSectionCount();
  IOUtil.writeInt(out,sectionCount);
  for (int i=0; i < sectionCount; i++) {
    PageSection section=hint.getSection(i);
    section.write(out);
  }
  int hintSize=hint.getUnresolvedRowCount();
  IOUtil.writeInt(out,hintSize);
  ;
  for (int i=0; i < hintSize; i++) {
    UnresolvedRowHint rowHint=hint.getUnresolvedRowHint(i);
    rowHint.writeObject(out);
  }
  int columnHintSize=hint.getTableColumnHintCount();
  IOUtil.writeInt(out,columnHintSize);
  for (int i=0; i < columnHintSize; i++) {
    TableColumnHint columnHint=hint.getTableColumnHint(i);
    IOUtil.writeString(out,columnHint.getTableId());
    IOUtil.writeInt(out,columnHint.getStart());
    IOUtil.writeInt(out,columnHint.getColumnCount());
  }
  Collection<PageVariable> variables=hint.getPageVariables();
  writePageVariables(out,variables);
}
Program: 69547
Project: 69547
Buggy source:
public abstract void buildCellStyle(ICellContent cell,StringBuffer styleBuffer,boolean isHead);

Fixed version (ground truth):
public abstract void buildCellStyle(ICellContent cell,StringBuffer styleBuffer,boolean isHead,boolean fixedCellHeight);
Program: 69548
Project: 69548
Buggy source:
public HTMLEmitter(HTMLReportEmitter reportEmitter,HTMLWriter writer,String layoutPreference,boolean enableInlineStyle,int browserVersion){
  this.reportEmitter=reportEmitter;
  this.writer=writer;
  this.layoutPreference=layoutPreference;
  this.enableInlineStyle=enableInlineStyle;
  this.browserVersion=browserVersion;
}

Fixed version (ground truth):
public HTMLEmitter(HTMLReportEmitter reportEmitter,HTMLWriter writer,boolean fixedReport,boolean enableInlineStyle,int browserVersion){
  this.reportEmitter=reportEmitter;
  this.writer=writer;
  this.fixedReport=fixedReport;
  this.enableInlineStyle=enableInlineStyle;
  this.browserVersion=browserVersion;
}
Program: 69549
Project: 69549
Buggy source:
public abstract void handleCellAlign(ICellContent cell);

Fixed version (ground truth):
/** 
 * Handles the text align property of the element content.
 */
public void handleCellAlign(ICellContent cell){
  IStyle style=cell.getStyle();
  CSSValue hAlign=style.getProperty(IStyle.STYLE_TEXT_ALIGN);
  if (null != hAlign) {
    writer.attribute(HTMLTags.ATTR_ALIGN,hAlign.getCssText());
  }
}
Program: 69550
Project: 69550
Buggy source:
public HTMLPerformanceOptimize(HTMLReportEmitter reportEmitter,HTMLWriter writer,String layoutPreference,boolean enableInlineStyle,int browserVersion){
  super(reportEmitter,writer,layoutPreference,enableInlineStyle,browserVersion);
}

Fixed version (ground truth):
public HTMLPerformanceOptimize(HTMLReportEmitter reportEmitter,HTMLWriter writer,boolean fixedReport,boolean enableInlineStyle,int browserVersion){
  super(reportEmitter,writer,fixedReport,enableInlineStyle,browserVersion);
}
Program: 69551
Project: 69551
Buggy source:
/** 
 * Build the style of cell content.
 */
public void buildCellStyle(ICellContent cell,StringBuffer styleBuffer,boolean isHead){
  if (HTMLRenderOption.LAYOUT_PREFERENCE_FIXED.equals(layoutPreference)) {
    styleBuffer.append("String_Node_Str");
  }
  IStyle style=cell.getStyle();
  CSSValue display=style.getProperty(IStyle.STYLE_DISPLAY);
  if (IStyle.NONE_VALUE == display) {
    styleBuffer.append("String_Node_Str");
  }
  style=getElementStyle(cell);
  if (style == null) {
    return;
  }
  AttributeBuilder.buildFont(styleBuffer,style);
  AttributeBuilder.buildBox(styleBuffer,style);
  AttributeBuilder.buildBackground(styleBuffer,style,reportEmitter);
  AttributeBuilder.buildText(styleBuffer,style);
  AttributeBuilder.buildVisual(styleBuffer,style);
  AttributeBuilder.buildTextDecoration(styleBuffer,style);
}

Fixed version (ground truth):
/** 
 * Build the style of cell content.
 */
public void buildCellStyle(ICellContent cell,StringBuffer styleBuffer,boolean isHead,boolean fixedCellHeight){
  if (fixedReport) {
    styleBuffer.append("String_Node_Str");
  }
  IStyle style=cell.getStyle();
  CSSValue display=style.getProperty(IStyle.STYLE_DISPLAY);
  if (IStyle.NONE_VALUE == display) {
    styleBuffer.append("String_Node_Str");
  }
  style=getElementStyle(cell);
  if (style == null) {
    if (fixedCellHeight) {
      styleBuffer.append("String_Node_Str");
    }
    return;
  }
  AttributeBuilder.buildFont(styleBuffer,style);
  AttributeBuilder.buildMargins(styleBuffer,style);
  if (fixedCellHeight) {
    styleBuffer.append("String_Node_Str");
  }
 else {
    AttributeBuilder.buildPaddings(styleBuffer,style);
  }
  AttributeBuilder.buildBorders(styleBuffer,style);
  AttributeBuilder.buildBackground(styleBuffer,style,reportEmitter);
  AttributeBuilder.buildText(styleBuffer,style);
  AttributeBuilder.buildVisual(styleBuffer,style);
  AttributeBuilder.buildTextDecoration(styleBuffer,style);
}
Program: 69554
Project: 69554
Buggy source:
public IPage newPage(int width,int height,Color backgroundColor){
  currentPage=new PDFPage(width,height,doc,writer,this);
  currentPage.drawBackgroundColor(backgroundColor,0,0,width,height);
  return currentPage;
}

Fixed version (ground truth):
public IPage newPage(int width,int height,Color backgroundColor){
  int w=Math.min(width,MAX_PAGE_WIDTH);
  int h=Math.min(height,MAX_PAGE_HEIGHT);
  currentPage=new PDFPage(w,h,doc,writer,this);
  currentPage.drawBackgroundColor(backgroundColor,0,0,w,h);
  return currentPage;
}
Program: 69555
Project: 69555
Buggy source:
String removeSpace(String v){
  return v;
}

Fixed version (ground truth):
String removeSpace(String v){
  StringBuilder sb=new StringBuilder(v.length());
  try {
    BufferedReader reader=new BufferedReader(new StringReader(v));
    String line=reader.readLine();
    while (line != null) {
      line=line.trim();
      if (!line.startsWith("String_Node_Str")) {
        sb.append(line);
        sb.append('\n');
      }
      line=reader.readLine();
    }
  }
 catch (  IOException ex) {
  }
  return sb.toString();
}
Program: 69556
Project: 69556
Buggy source:
public void write(OutputStream out,Report report) throws Exception {
  Document document=DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument();
  new ReportDumpVisitor(document).createDocument(report);
  Transformer tr=TransformerFactory.newInstance().newTransformer();
  tr.setOutputProperty(OutputKeys.INDENT,"String_Node_Str");
  tr.setOutputProperty(OutputKeys.METHOD,"String_Node_Str");
  tr.setOutputProperty("String_Node_Str","String_Node_Str");
  tr.transform(new DOMSource(document),new StreamResult(out));
}

Fixed version (ground truth):
public void write(OutputStream out,Report report) throws Exception {
  Document document=DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument();
  new ReportDumpVisitor(document).createDocument(report);
  Transformer tr=TransformerFactory.newInstance().newTransformer();
  tr.setOutputProperty(OutputKeys.STANDALONE,"String_Node_Str");
  tr.setOutputProperty(OutputKeys.INDENT,"String_Node_Str");
  tr.setOutputProperty(OutputKeys.METHOD,"String_Node_Str");
  tr.setOutputProperty("String_Node_Str","String_Node_Str");
  tr.transform(new DOMSource(document),new StreamResult(out));
}
Program: 69557
Project: 69557
Buggy source:
/** 
 * @param name
 * @param resultSets
 * @param writer
 * @throws IOException
 */
public static void save(String name,IAggregationResultSet[] resultSets,IDocArchiveWriter writer) throws IOException {
  RAOutputStream outputStream=writer.createRandomAccessStream(name);
  DataOutputStream dataOutputStream=new DataOutputStream(outputStream);
  if (resultSets == null) {
    dataOutputStream.writeInt(-1);
    return;
  }
  dataOutputStream.writeInt(resultSets.length);
  dataOutputStream.close();
  for (int i=0; i < resultSets.length; i++) {
    outputStream=writer.createRandomAccessStream(name + PREFIX_RESULTSET + i);
    dataOutputStream=new DataOutputStream(outputStream);
    saveOneResultSet(dataOutputStream,resultSets[i]);
    dataOutputStream.close();
  }
}

Fixed version (ground truth):
/** 
 * @param name
 * @param resultSets
 * @param writer
 * @throws IOException
 */
public static void save(String name,IAggregationResultSet[] resultSets,IDocArchiveWriter writer) throws IOException {
  if (name == null)   return;
  RAOutputStream outputStream=writer.createRandomAccessStream(name);
  DataOutputStream dataOutputStream=new DataOutputStream(outputStream);
  if (resultSets == null) {
    dataOutputStream.writeInt(-1);
    return;
  }
  dataOutputStream.writeInt(resultSets.length);
  dataOutputStream.close();
  for (int i=0; i < resultSets.length; i++) {
    outputStream=writer.createRandomAccessStream(name + PREFIX_RESULTSET + i);
    dataOutputStream=new DataOutputStream(outputStream);
    saveOneResultSet(dataOutputStream,resultSets[i]);
    dataOutputStream.close();
  }
}
Program: 69559
Project: 69559
Buggy source:
private void traverse(IArea area){
  if (area instanceof ContainerArea) {
    if (area instanceof TableArea) {
      tableIds.add(((TableArea)area).getContent().getInstanceID().toUniqueString());
    }
    ContainerArea container=(ContainerArea)area;
    if (container.content != null) {
      start(container);
    }
    if (!(container.content instanceof ForeignContent)) {
      for (Iterator<IArea> i=container.getChildren(); i.hasNext(); ) {
        IArea child=i.next();
        traverse(child);
      }
    }
  }
}

Fixed version (ground truth):
private void traverse(IArea area){
  if (area instanceof ContainerArea) {
    if (area instanceof TableArea) {
      tableIds.add(((TableArea)area).getContent().getInstanceID().toUniqueString());
    }
    ContainerArea container=(ContainerArea)area;
    if (container.content != null) {
      start(container);
    }
    if (!(container.content instanceof ForeignContent)) {
      for (Iterator<IArea> i=container.getChildren(); i.hasNext(); ) {
        IArea child=i.next();
        traverse(child);
      }
    }
  }
  String bookmark=area.getBookmark();
  if (bookmark != null) {
    context.addBookmarkMap(context.getPageNumber(),bookmark);
  }
}
Program: 69560
Project: 69560
Buggy source:
public FixedLayoutPageHintGenerator(LayoutContext context){
  htmlLayoutContext=context.getHtmlLayoutContext();
}

Fixed version (ground truth):
public FixedLayoutPageHintGenerator(LayoutContext context){
  this.context=context;
  htmlLayoutContext=context.getHtmlLayoutContext();
}
Program: 69561
Project: 69561
Buggy source:
public void onPage(long pageNumber,Object context){
  if (context instanceof LayoutContext) {
    LayoutContext pdfContext=(LayoutContext)context;
    document.setPageCount(pageNumber);
    boolean reportFinished=pdfContext.isFinished();
    if (reportFinished) {
      writePageVariables();
      writeTotalPage(pageNumber);
      close();
      return;
    }
    boolean checkpoint=false;
    if (executionContext.isProgressiveViewingEnable()) {
      if (pageNumber == 1 || pageNumber == 10 || pageNumber == 50 || pageNumber % 100 == 0) {
        checkpoint=true;
      }
    }
    writePageHint(pdfContext);
    if (checkpoint) {
      try {
        IDocArchiveWriter archive=document.getArchive();
        writeTotalPage(pageNumber);
        document.savePersistentObjects(ReportDocumentBuilder.this.executionContext.getGlobalBeans());
        document.saveCoreStreams();
        archive.flush();
      }
 catch (      Exception e) {
        logger.log(Level.WARNING,"String_Node_Str",e);
      }
    }
    if (pageHandler != null) {
{
        IReportDocumentInfo docInfo=new ReportDocumentInfo(executionContext,pageNumber,false);
        pageHandler.onPage((int)pageNumber,checkpoint,docInfo);
      }
    }
  }
  executionContext.getProgressMonitor().onProgress(IProgressMonitor.END_PAGE,(int)pageNumber);
}

Fixed version (ground truth):
public void onPage(long pageNumber,Object context){
  if (context instanceof LayoutContext) {
    LayoutContext pdfContext=(LayoutContext)context;
    document.setPageCount(pageNumber);
    boolean reportFinished=pdfContext.isFinished();
    if (reportFinished) {
      addBookmarkMap(pdfContext);
      writePageVariables();
      writeTotalPage(pageNumber);
      close();
      return;
    }
    boolean checkpoint=false;
    if (executionContext.isProgressiveViewingEnable()) {
      if (pageNumber == 1 || pageNumber == 10 || pageNumber == 50 || pageNumber % 100 == 0) {
        checkpoint=true;
      }
    }
    writePageHint(pdfContext);
    if (checkpoint) {
      try {
        IDocArchiveWriter archive=document.getArchive();
        writeTotalPage(pageNumber);
        document.savePersistentObjects(ReportDocumentBuilder.this.executionContext.getGlobalBeans());
        document.saveCoreStreams();
        archive.flush();
      }
 catch (      Exception e) {
        logger.log(Level.WARNING,"String_Node_Str",e);
      }
    }
    if (pageHandler != null) {
{
        IReportDocumentInfo docInfo=new ReportDocumentInfo(executionContext,pageNumber,false);
        pageHandler.onPage((int)pageNumber,checkpoint,docInfo);
      }
    }
  }
  executionContext.getProgressMonitor().onProgress(IProgressMonitor.END_PAGE,(int)pageNumber);
}
Program: 69562
Project: 69562
Buggy source:
public void startForeign(IForeignContent foreign) throws BirtException {
  if (IForeignContent.HTML_TYPE.equals(foreign.getRawType())) {
    _startContainer(foreign);
    HTML2Content.html2Content(foreign);
    if (context.isFixedLayout()) {
      IStyle style=foreign.getStyle();
      style.setProperty(IStyle.STYLE_PAGE_BREAK_INSIDE,IStyle.AVOID_VALUE);
    }
    java.util.Collection children=foreign.getChildren();
    if (children != null && !children.isEmpty()) {
      Iterator iter=children.iterator();
      IContent child=(IContent)iter.next();
      visitContent(child,this);
    }
    foreign.getChildren().clear();
    _endContainer(foreign);
  }
 else {
    startContent(foreign);
  }
}

Fixed version (ground truth):
public void startForeign(IForeignContent foreign) throws BirtException {
  _startContainer(foreign);
  if (IForeignContent.HTML_TYPE.equals(foreign.getRawType())) {
    HTML2Content.html2Content(foreign);
    if (context.isFixedLayout()) {
      IStyle style=foreign.getStyle();
      style.setProperty(IStyle.STYLE_PAGE_BREAK_INSIDE,IStyle.AVOID_VALUE);
    }
    java.util.Collection children=foreign.getChildren();
    if (children != null && !children.isEmpty()) {
      Iterator iter=children.iterator();
      IContent child=(IContent)iter.next();
      visitContent(child,this);
    }
    foreign.getChildren().clear();
  }
  _endContainer(foreign);
}
Program: 69563
Project: 69563
Buggy source:
protected Data addDataContent(IDataContent data){
  HyperlinkDef url=parseHyperLink(data);
  BookmarkDef bookmark=getBookmark(data);
  Data excelData=null;
  Object generateBy=data.getGenerateBy();
  IStyle style=data.getComputedStyle();
  DataFormatValue dataformat=style.getDataFormat();
  DataItemDesign design=(DataItemDesign)generateBy;
  MapDesign map=design.getMap();
  if (map != null && map.getRuleCount() > 0 && data.getLabelText() != null) {
    excelData=engine.addData(data.getLabelText().trim(),style,url,bookmark);
  }
 else {
    String locale=null;
    int type=ExcelUtil.getType(data.getValue());
    if (type == SheetData.STRING) {
      if (dataformat != null) {
        locale=dataformat.getStringLocale();
      }
      excelData=engine.addData(data.getText(),style,url,bookmark,locale);
    }
 else     if (type == Data.NUMBER) {
      if (dataformat != null) {
        locale=dataformat.getStringLocale();
      }
      excelData=engine.addData(data.getValue(),style,url,bookmark,locale);
    }
 else {
      if (dataformat != null) {
        locale=dataformat.getStringLocale();
      }
      excelData=engine.addDateTime(data,style,url,bookmark,locale);
    }
  }
  return excelData;
}

Fixed version (ground truth):
protected Data addDataContent(IDataContent data){
  HyperlinkDef url=parseHyperLink(data);
  BookmarkDef bookmark=getBookmark(data);
  Data excelData=null;
  Object generateBy=data.getGenerateBy();
  IStyle style=data.getComputedStyle();
  DataFormatValue dataformat=style.getDataFormat();
  MapDesign map=null;
  if (generateBy instanceof DataItemDesign) {
    DataItemDesign design=(DataItemDesign)generateBy;
    map=design.getMap();
  }
  if (map != null && map.getRuleCount() > 0 && data.getLabelText() != null) {
    excelData=engine.addData(data.getLabelText().trim(),style,url,bookmark);
  }
 else {
    String locale=null;
    int type=ExcelUtil.getType(data.getValue());
    if (type == SheetData.STRING) {
      if (dataformat != null) {
        locale=dataformat.getStringLocale();
      }
      excelData=engine.addData(data.getText(),style,url,bookmark,locale);
    }
 else     if (type == Data.NUMBER) {
      if (dataformat != null) {
        locale=dataformat.getStringLocale();
      }
      excelData=engine.addData(data.getValue(),style,url,bookmark,locale);
    }
 else {
      if (dataformat != null) {
        locale=dataformat.getStringLocale();
      }
      excelData=engine.addDateTime(data,style,url,bookmark,locale);
    }
  }
  return excelData;
}
Program: 69564
Project: 69564
Buggy source:
public IContent execute(){
  context.setPageNumber(pageNumber);
  tocBuilder=context.getTOCBuilder();
  context.setTOCBuilder(null);
  context.setExecutingMasterPage(true);
  IPageContent pageContent=report.createPageContent();
  pageContent.setPageNumber(pageNumber);
  content=pageContent;
  content.setGenerateBy(masterPage);
  instanceId=new InstanceID(null,pageNumber,masterPage.getID(),null);
  content.setInstanceID(instanceId);
  return content;
}

Fixed version (ground truth):
public IContent execute(){
  context.setPageNumber(pageNumber);
  tocBuilder=context.getTOCBuilder();
  context.setTOCBuilder(null);
  rs=context.getResultSets();
  context.setExecutingMasterPage(true);
  IPageContent pageContent=report.createPageContent();
  pageContent.setPageNumber(pageNumber);
  content=pageContent;
  content.setGenerateBy(masterPage);
  instanceId=new InstanceID(null,pageNumber,masterPage.getID(),null);
  content.setInstanceID(instanceId);
  return content;
}
Program: 69565
Project: 69565
Buggy source:
public void close() throws BirtException {
  context.setExecutingMasterPage(false);
  context.setTOCBuilder(tocBuilder);
  super.close();
}

Fixed version (ground truth):
public void close() throws BirtException {
  context.setExecutingMasterPage(false);
  context.setTOCBuilder(tocBuilder);
  context.setResultSets(rs);
  super.close();
}
Program: 69566
Project: 69566
Buggy source:
public void close(){
  context.setExecutingMasterPage(false);
  pageNumber=0;
  if (pageOffset != -1) {
    manager.getPageReader().unloadContent(pageOffset);
  }
  nextBand=0;
  super.close();
}

Fixed version (ground truth):
public void close(){
  context.setExecutingMasterPage(false);
  context.setResultSets(rs);
  pageNumber=0;
  if (pageOffset != -1) {
    manager.getPageReader().unloadContent(pageOffset);
  }
  nextBand=0;
  super.close();
}
Program: 69567
Project: 69567
Buggy source:
public IContent execute(){
  if (executed) {
    return content;
  }
  context.setExecutingMasterPage(true);
  context.setPageNumber(pageNumber);
  executed=true;
  try {
    long pageNo=pageNumber;
    PageHintReader hintReader=manager.getPageHintReader();
    long totalPage=hintReader.getTotalPage();
    if (pageNumber > totalPage) {
      pageNo=totalPage;
    }
    IPageHint pageHint=hintReader.getPageHint(pageNo);
    Collection<PageVariable> vars=pageHint.getPageVariables();
    if (vars != null) {
      context.addPageVariables(vars);
    }
    pageOffset=hintReader.getPageOffset(pageNo,masterPage.getName());
    CachedReportContentReaderV3 pageReader=manager.getPageReader();
    content=pageReader.loadContent(pageOffset);
    InstanceID iid=content.getInstanceID();
    long id=iid.getComponentID();
    masterPage=(SimpleMasterPageDesign)context.getReport().getReportItemByID(id);
    content.setGenerateBy(masterPage);
    IPageContent pageContent=(IPageContent)content;
    pageContent.setPageNumber(pageNumber);
    return content;
  }
 catch (  IOException ex) {
    context.addException(this.getDesign(),new EngineException(ex.getLocalizedMessage(),ex));
  }
  return null;
}

Fixed version (ground truth):
public IContent execute(){
  if (executed) {
    return content;
  }
  context.setExecutingMasterPage(true);
  rs=context.getResultSets();
  context.setPageNumber(pageNumber);
  executed=true;
  try {
    long pageNo=pageNumber;
    PageHintReader hintReader=manager.getPageHintReader();
    long totalPage=hintReader.getTotalPage();
    if (pageNumber > totalPage) {
      pageNo=totalPage;
    }
    IPageHint pageHint=hintReader.getPageHint(pageNo);
    Collection<PageVariable> vars=pageHint.getPageVariables();
    if (vars != null) {
      context.addPageVariables(vars);
    }
    pageOffset=hintReader.getPageOffset(pageNo,masterPage.getName());
    CachedReportContentReaderV3 pageReader=manager.getPageReader();
    content=pageReader.loadContent(pageOffset);
    InstanceID iid=content.getInstanceID();
    long id=iid.getComponentID();
    masterPage=(SimpleMasterPageDesign)context.getReport().getReportItemByID(id);
    content.setGenerateBy(masterPage);
    IPageContent pageContent=(IPageContent)content;
    pageContent.setPageNumber(pageNumber);
    return content;
  }
 catch (  IOException ex) {
    context.addException(this.getDesign(),new EngineException(ex.getLocalizedMessage(),ex));
  }
  return null;
}
Program: 69568
Project: 69568
Buggy source:
private void checkTask(String designFile,String[][] bookmarksWithMetadata,String[][] bookmarksWithoutMetadata,boolean isRenderTask) throws EngineException, IOException {
  HTMLRenderOption options=new HTMLRenderOption();
  RenderResult result=getRenderResult(designFile,isRenderTask,options);
  checkOutput(result.content,result.instanceIDs,bookmarksWithMetadata,bookmarksWithoutMetadata);
}

Fixed version (ground truth):
private void checkTask(String designFile,String[][] bookmarksWithMetadata,String[][] bookmarksWithoutMetadata,boolean isRenderTask) throws EngineException, IOException {
  HTMLRenderOption options=new HTMLRenderOption();
  options.setSupportedImageFormats("String_Node_Str");
  RenderResult result=getRenderResult(designFile,isRenderTask,options);
  checkOutput(result.content,result.instanceIDs,bookmarksWithMetadata,bookmarksWithoutMetadata);
}
Program: 69571
Project: 69571
Buggy source:
private void traverse(IArea area){
  if (area instanceof ContainerArea) {
    if (((ContainerArea)area).content instanceof ForeignContent) {
      return;
    }
    if (area instanceof TableArea) {
      tableIds.add(((TableArea)area).getContent().getInstanceID().toUniqueString());
    }
    ContainerArea container=(ContainerArea)area;
    if (container.content != null) {
      start(container);
    }
    for (Iterator<IArea> i=container.getChildren(); i.hasNext(); ) {
      IArea child=i.next();
      traverse(child);
    }
  }
}

Fixed version (ground truth):
private void traverse(IArea area){
  if (area instanceof ContainerArea) {
    if (area instanceof TableArea) {
      tableIds.add(((TableArea)area).getContent().getInstanceID().toUniqueString());
    }
    ContainerArea container=(ContainerArea)area;
    if (container.content != null) {
      start(container);
    }
    if (!(container.content instanceof ForeignContent)) {
      for (Iterator<IArea> i=container.getChildren(); i.hasNext(); ) {
        IArea child=i.next();
        traverse(child);
      }
    }
  }
}
Program: 69572
Project: 69572
Buggy source:
public void changeTask(Notification notification){
  if (previewPainter != null) {
    if (notification == null) {
      if (getChartModel() instanceof ChartWithAxes) {
        checkDataTypeForChartWithAxes();
      }
      return;
    }
    if (notification.getEventType() == Notification.REMOVE && notification.getNotifier() instanceof Axis) {
      ChartWizard.removeAllExceptions("String_Node_Str" + notification.getOldValue().hashCode());
    }
    if (notification.getNotifier() instanceof SeriesDefinition && getChartModel() instanceof ChartWithAxes) {
      checkDataTypeForChartWithAxes();
    }
    if (notification.getNotifier() instanceof Query || notification.getNotifier() instanceof Axis || notification.getNotifier() instanceof SeriesDefinition|| notification.getNotifier() instanceof SeriesGrouping) {
      doPreview();
    }
 else     if (ChartPreviewPainterBase.isLivePreviewActive()) {
      ChartAdapter.beginIgnoreNotifications();
      ChartUIUtil.syncRuntimeSeries(getChartModel());
      ChartAdapter.endIgnoreNotifications();
      doPreview();
    }
 else {
      doPreview();
    }
  }
}

Fixed version (ground truth):
public void changeTask(Notification notification){
  if (previewPainter != null) {
    if (notification == null) {
      if (getChartModel() instanceof ChartWithAxes) {
        checkDataTypeForChartWithAxes();
      }
      return;
    }
    if (notification.getEventType() == Notification.REMOVE && notification.getNotifier() instanceof Axis) {
      ChartWizard.removeAllExceptions("String_Node_Str" + notification.getOldValue().hashCode());
    }
    if ((notification.getNotifier() instanceof Query && ((Query)notification.getNotifier()).eContainer() instanceof Series)) {
      checkDataType((Query)notification.getNotifier(),(Series)((Query)notification.getNotifier()).eContainer());
    }
    if (notification.getNotifier() instanceof SeriesDefinition && getChartModel() instanceof ChartWithAxes) {
      checkDataTypeForChartWithAxes();
    }
    if (notification.getNotifier() instanceof Query || notification.getNotifier() instanceof Axis || notification.getNotifier() instanceof SeriesDefinition|| notification.getNotifier() instanceof SeriesGrouping) {
      doPreview();
    }
 else     if (ChartPreviewPainterBase.isLivePreviewActive()) {
      ChartAdapter.beginIgnoreNotifications();
      ChartUIUtil.syncRuntimeSeries(getChartModel());
      ChartAdapter.endIgnoreNotifications();
      doPreview();
    }
 else {
      doPreview();
    }
  }
}
Program: 69573
Project: 69573
Buggy source:
private void setQueryExpression(String expression){
  if (query != null) {
    query.setDefinition(expression);
  }
 else {
    query=QueryImpl.create(expression);
    query.eAdapters().addAll(seriesdefinition.eAdapters());
    seriesdefinition.setQuery(query);
  }
  if (ChartUIConstants.QUERY_VALUE.equals(queryType)) {
    if (!(context.getChartType() instanceof GanttChart) && !context.getDataServiceProvider().checkState(IDataServiceProvider.SHARE_QUERY) && context.getDataServiceProvider().checkState(IDataServiceProvider.HAS_DATA_SET)) {
      if (context.getDataServiceProvider().getDataType(expression) == DataType.DATE_TIME_LITERAL) {
        if (query.getGrouping() == null) {
          query.setGrouping(DataFactoryImpl.init().createSeriesGrouping());
        }
        SeriesGrouping group=query.getGrouping();
        group.setEnabled(true);
        group.setAggregateExpression("String_Node_Str");
      }
    }
  }
}

Fixed version (ground truth):
private void setQueryExpression(String expression){
  if (ChartUIConstants.QUERY_VALUE.equals(queryType)) {
    if (!(context.getChartType() instanceof GanttChart) && !context.getDataServiceProvider().checkState(IDataServiceProvider.SHARE_QUERY) && context.getDataServiceProvider().checkState(IDataServiceProvider.HAS_DATA_SET)) {
      if (context.getDataServiceProvider().getDataType(expression) == DataType.DATE_TIME_LITERAL) {
        ChartAdapter.beginIgnoreNotifications();
        if (query.getGrouping() == null) {
          query.setGrouping(DataFactoryImpl.init().createSeriesGrouping());
        }
        SeriesGrouping group=query.getGrouping();
        group.setEnabled(true);
        group.setAggregateExpression("String_Node_Str");
        ChartAdapter.endIgnoreNotifications();
      }
    }
  }
  if (query != null) {
    query.setDefinition(expression);
  }
 else {
    query=QueryImpl.create(expression);
    query.eAdapters().addAll(seriesdefinition.eAdapters());
    seriesdefinition.setQuery(query);
  }
}
Program: 69574
Project: 69574
Buggy source:
/** 
 * Get a List of JDBCDriverInformations loaded from the given fileList
 * @param fileList the File List
 * @param urlClassLoader
 * @return List of JDBCDriverInformation
 */
private static List getJDBCDriverInfoList(List fileList){
  List driverList=new ArrayList();
  URLClassLoader urlClassLoader=createClassLoader(fileList.toArray());
  for (int i=0; i < fileList.size(); i++) {
    String[] resourceNames=getAllResouceNames((File)fileList.get(i));
    List subDriverList=new ArrayList();
    for (int j=0; j < resourceNames.length; j++) {
      String resourceName=resourceNames[j];
      if (resourceName.endsWith("String_Node_Str")) {
        resourceName=modifyResourceName(resourceName);
        Class aClass=loadClass(urlClassLoader,resourceName);
        if (isImplementedDriver(aClass)) {
          JDBCDriverInformation info=JDBCDriverInformation.newInstance(aClass);
          if (info != null) {
            driverList.add(info);
            subDriverList.add(info);
          }
        }
      }
    }
    if (subDriverList.isEmpty()) {
      if (!failLoadFileList.contains(fileList.get(i)))       failLoadFileList.add(fileList.get(i));
    }
 else {
      if (failLoadFileList.contains(fileList.get(i)))       failLoadFileList.remove(fileList.get(i));
    }
    file2Drivers.put(((File)fileList.get(i)).getName(),subDriverList);
  }
  urlClassLoader.close();
  return driverList;
}

Fixed version (ground truth):
/** 
 * Get a List of JDBCDriverInformations loaded from the given fileList
 * @param fileList the File List
 * @param urlClassLoader
 * @return List of JDBCDriverInformation
 */
private static List getJDBCDriverInfoList(List fileList){
  List driverList=new ArrayList();
  URLClassLoader urlClassLoader=createClassLoader(fileList.toArray());
  for (int i=0; i < fileList.size(); i++) {
    String[] resourceNames=getAllResouceNames((File)fileList.get(i));
    List subDriverList=new ArrayList();
    for (int j=0; j < resourceNames.length; j++) {
      String resourceName=resourceNames[j];
      if (resourceName.endsWith("String_Node_Str")) {
        resourceName=modifyResourceName(resourceName);
        Class aClass=loadClass(urlClassLoader,resourceName);
        if (isImplementedDriver(aClass)) {
          JDBCDriverInformation info=JDBCDriverInformation.newInstance(aClass);
          if (info != null) {
            driverList.add(info);
            subDriverList.add(info);
          }
        }
      }
    }
    if (subDriverList.isEmpty()) {
      if (!failLoadFileList.contains(fileList.get(i)))       failLoadFileList.add(fileList.get(i));
    }
 else {
      if (failLoadFileList.contains(fileList.get(i)))       failLoadFileList.remove(fileList.get(i));
    }
    file2Drivers.put(((File)fileList.get(i)).getName(),subDriverList);
  }
  return driverList;
}
Program: 69576
Project: 69576
Buggy source:
/** 
 * @param severity
 * @param message
 * @return
 */
protected Status getMiscStatus(int severity,String message){
  return new Status(severity,PlatformUI.PLUGIN_ID,IStatus.OK,message,null);
}

Fixed version (ground truth):
/** 
 * @param severity
 * @param message
 * @return
 */
protected Status getMiscStatus(int severity,String message){
  return new Status(severity,PlatformUI.PLUGIN_ID,severity,message,null);
}
Program: 69577
Project: 69577
Buggy source:
public ExportDataSourceDialog(Shell parentShell,String title,DataSourceHandle selection){
  this(parentShell,title);
  this.dataSourceHandle=selection;
  this.fileName=this.dataSourceHandle.getQualifiedName();
}

Fixed version (ground truth):
public ExportDataSourceDialog(Shell parentShell,String title,DataSourceHandle selection){
  this(parentShell,title);
  this.dataSourceHandle=selection;
  initProfileName();
}
Program: 69578
Project: 69578
Buggy source:
protected void writePageHint(LayoutContext pdfContext){
  ArrayList pageHintList=pdfContext.getPageHint();
  PageHint hint=new PageHint(pdfContext.getPageNumber(),pdfContext.getMasterPage());
  for (int i=0; i < pageHintList.size(); i++) {
    SizeBasedContent[] range=(SizeBasedContent[])pageHintList.get(i);
    PageSection section=createPageSection(range[0],range[1]);
    hint.addSection(section);
  }
  hint.addUnresolvedRowHints(pdfContext.getUnresolvedRowHints());
  hint.addTableColumnHints(pdfContext.getTableColumnHints());
  if (ensureOpen()) {
    try {
      hintWriter.writePageHint(hint);
    }
 catch (    IOException ex) {
      logger.log(Level.SEVERE,"String_Node_Str",ex);
      close();
    }
  }
}

Fixed version (ground truth):
protected void writePageHint(LayoutContext pdfContext){
  ArrayList pageHintList=pdfContext.getPageHint();
  PageHint hint=new PageHint(pdfContext.getPageNumber(),pdfContext.getMasterPage());
  for (int i=0; i < pageHintList.size(); i++) {
    SizeBasedContent[] range=(SizeBasedContent[])pageHintList.get(i);
    PageSection section=createPageSection(range[0],range[1]);
    hint.addSection(section);
  }
  hint.addUnresolvedRowHints(pdfContext.getUnresolvedRowHints());
  hint.addTableColumnHints(pdfContext.getTableColumnHints());
  Collection<PageVariable> vars=getPageVariable();
  hint.getPageVariables().addAll(vars);
  if (ensureOpen()) {
    try {
      hintWriter.writePageHint(hint);
    }
 catch (    IOException ex) {
      logger.log(Level.SEVERE,"String_Node_Str",ex);
      close();
    }
  }
}
Program: 69579
Project: 69579
Buggy source:
public void onPage(long pageNumber,Object context){
  if (context instanceof LayoutContext) {
    LayoutContext pdfContext=(LayoutContext)context;
    document.setPageCount(pageNumber);
    boolean reportFinished=pdfContext.isFinished();
    if (reportFinished) {
      writeTotalPage(pageNumber);
      close();
      return;
    }
    boolean checkpoint=false;
    if (executionContext.isProgressiveViewingEnable()) {
      if (pageNumber == 1 || pageNumber == 10 || pageNumber == 50 || pageNumber % 100 == 0) {
        checkpoint=true;
      }
    }
    writePageHint(pdfContext);
    if (checkpoint) {
      try {
        IDocArchiveWriter archive=document.getArchive();
        writeTotalPage(pageNumber);
        document.savePersistentObjects(ReportDocumentBuilder.this.executionContext.getGlobalBeans());
        document.saveCoreStreams();
        archive.flush();
      }
 catch (      Exception e) {
        logger.log(Level.WARNING,"String_Node_Str",e);
      }
    }
    if (pageHandler != null) {
{
        IReportDocumentInfo docInfo=new ReportDocumentInfo(executionContext,pageNumber,false);
        pageHandler.onPage((int)pageNumber,checkpoint,docInfo);
      }
    }
  }
  executionContext.getProgressMonitor().onProgress(IProgressMonitor.END_PAGE,(int)pageNumber);
}

Fixed version (ground truth):
public void onPage(long pageNumber,Object context){
  if (context instanceof LayoutContext) {
    LayoutContext pdfContext=(LayoutContext)context;
    document.setPageCount(pageNumber);
    boolean reportFinished=pdfContext.isFinished();
    if (reportFinished) {
      writePageVariables();
      writeTotalPage(pageNumber);
      close();
      return;
    }
    boolean checkpoint=false;
    if (executionContext.isProgressiveViewingEnable()) {
      if (pageNumber == 1 || pageNumber == 10 || pageNumber == 50 || pageNumber % 100 == 0) {
        checkpoint=true;
      }
    }
    writePageHint(pdfContext);
    if (checkpoint) {
      try {
        IDocArchiveWriter archive=document.getArchive();
        writeTotalPage(pageNumber);
        document.savePersistentObjects(ReportDocumentBuilder.this.executionContext.getGlobalBeans());
        document.saveCoreStreams();
        archive.flush();
      }
 catch (      Exception e) {
        logger.log(Level.WARNING,"String_Node_Str",e);
      }
    }
    if (pageHandler != null) {
{
        IReportDocumentInfo docInfo=new ReportDocumentInfo(executionContext,pageNumber,false);
        pageHandler.onPage((int)pageNumber,checkpoint,docInfo);
      }
    }
  }
  executionContext.getProgressMonitor().onProgress(IProgressMonitor.END_PAGE,(int)pageNumber);
}
Program: 69580
Project: 69580
Buggy source:
private Collection<PageVariable> getPageVariable(){
  Collection<PageVariable> pageVars=new ArrayList<PageVariable>();
  Collection<PageVariable> vars=executionContext.getPageVariables();
  for (  PageVariable var : vars) {
    if (PageVariable.SCOPE_PAGE.equals(var.getScope())) {
      pageVars.add(var);
    }
  }
  return pageVars;
}

Fixed version (ground truth):
protected Collection<PageVariable> getPageVariable(){
  Collection<PageVariable> pageVars=new ArrayList<PageVariable>();
  Collection<PageVariable> vars=executionContext.getPageVariables();
  for (  PageVariable var : vars) {
    if (PageVariable.SCOPE_PAGE.equals(var.getScope())) {
      pageVars.add(var);
    }
  }
  return pageVars;
}
Program: 69581
Project: 69581
Buggy source:
public Object[] getFieldValues(){
  ArrayList fields=new ArrayList();
  fields.add(new Integer(startIndex));
  fields.add(new Integer(endIndex));
  if (sortKeys != null) {
    fields.add(new Integer(sortKeys.length));
    for (int i=0; i < sortKeys.length; i++)     fields.add(sortKeys[i]);
  }
 else {
    fields.add(null);
  }
  if (sortDirections != null) {
    fields.add(new Integer(sortDirections.length));
    for (int i=0; i < sortDirections.length; i++)     fields.add(new Boolean(sortDirections[i]));
  }
 else {
    fields.add(null);
  }
  if (this.comparator != null) {
    fields.add(new Integer(comparator.length));
    for (int i=0; i < comparator.length; i++)     fields.add(comparator[i] == null ? ISortDefinition.ASCII_SORT_STRENGTH : new Integer(comparator[i].getStrength()));
    for (int i=0; i < comparator.length; i++)     fields.add(comparator[i] == null ? null : comparator[i].getLocale(ULocale.ACTUAL_LOCALE).getBaseName());
  }
 else {
    fields.add(null);
    fields.add(null);
  }
  fields.add(new Boolean(accept));
  return fields.toArray();
}

Fixed version (ground truth):
public Object[] getFieldValues(){
  ArrayList fields=new ArrayList();
  fields.add(new Integer(startIndex));
  fields.add(new Integer(endIndex));
  if (sortKeys != null) {
    fields.add(new Integer(sortKeys.length));
    for (int i=0; i < sortKeys.length; i++)     fields.add(sortKeys[i]);
  }
 else {
    fields.add(null);
  }
  if (sortDirections != null) {
    fields.add(new Integer(sortDirections.length));
    for (int i=0; i < sortDirections.length; i++)     fields.add(new Boolean(sortDirections[i]));
  }
 else {
    fields.add(null);
  }
  if (this.comparator != null) {
    fields.add(new Integer(comparator.length));
    for (int i=0; i < comparator.length; i++)     fields.add(comparator[i] == null ? ISortDefinition.ASCII_SORT_STRENGTH : new Integer(comparator[i].getStrength()));
    for (int i=0; i < comparator.length; i++)     fields.add(comparator[i] == null ? null : comparator[i].getLocale(ULocale.ACTUAL_LOCALE).getBaseName());
  }
 else {
    fields.add(null);
  }
  fields.add(new Boolean(accept));
  return fields.toArray();
}
Program: 69583
Project: 69583
Buggy source:
/** 
 * @param uri The uri to set.
 */
public void setURI(String uri){
  if (sourceType == IMAGE_NAME) {
    setImageName(uri);
  }
 else {
    setImageURI(uri);
  }
}

Fixed version (ground truth):
/** 
 * @param uri The uri to set.
 */
public void setURI(String uri){
switch (sourceType) {
case IMAGE_NAME:
    setImageName(uri);
  break;
case IMAGE_FILE:
case IMAGE_URL:
setImageURI(uri);
break;
default :
this.uri=uri;
break;
}
}
Program: 69584
Project: 69584
Buggy source:
public String getURI(){
  if (sourceType == IMAGE_NAME) {
    return getImageName();
  }
  return getImageURI();
}

Fixed version (ground truth):
public String getURI(){
switch (sourceType) {
case IMAGE_NAME:
    return getImageName();
case IMAGE_FILE:
case IMAGE_URL:
  return getImageURI();
default :
return uri;
}
}
Program: 69587
Project: 69587
Buggy source:
int invokeDataBinding(){
  Shell shell=new Shell(Display.getDefault(),SWT.DIALOG_TRIM | SWT.RESIZE | SWT.APPLICATION_MODAL);
  ExtendedItemHandle handle=getItemHandle();
  handle.getModuleHandle().getCommandStack().startTrans(null);
  ColumnBindingDialog page=new ChartColumnBindingDialog(handle,shell,getContext());
  ExpressionProvider ep=new ExpressionProvider(getItemHandle());
  ep.addFilter(new ExpressionFilter(){
    public boolean select(    Object parentElement,    Object element){
      return !(parentElement.equals(ExpressionProvider.BIRT_OBJECTS) && element instanceof IClassInfo && ((IClassInfo)element).getName().equals("String_Node_Str"));
    }
  }
);
  page.setExpressionProvider(ep);
  ((ChartColumnBindingDialog)page).setReadOnly(getDataServiceProvider().isSharedBinding() || getDataServiceProvider().isInheritanceOnly());
  int openStatus=page.open();
  if (openStatus == Window.OK) {
    handle.getModuleHandle().getCommandStack().commit();
    updatePredefinedQueries();
  }
 else {
    handle.getModuleHandle().getCommandStack().rollback();
  }
  return openStatus;
}

Fixed version (ground truth):
int invokeDataBinding(){
  Shell shell=new Shell(Display.getDefault(),SWT.DIALOG_TRIM | SWT.RESIZE | SWT.APPLICATION_MODAL);
  ExtendedItemHandle handle=getItemHandle();
  handle.getModuleHandle().getCommandStack().startTrans(null);
  ColumnBindingDialog page=new ChartColumnBindingDialog(handle,shell,getContext());
  ExpressionProvider ep=new ExpressionProvider(getItemHandle());
  ep.addFilter(new ExpressionFilter(){
    public boolean select(    Object parentElement,    Object element){
      return !(parentElement.equals(ExpressionProvider.BIRT_OBJECTS) && element instanceof IClassInfo && ((IClassInfo)element).getName().equals("String_Node_Str"));
    }
  }
);
  page.setExpressionProvider(ep);
  ((ChartColumnBindingDialog)page).setReadOnly(getDataServiceProvider().isSharedBinding() || getDataServiceProvider().isInheritanceOnly());
  int openStatus=page.open();
  if (openStatus == Window.OK) {
    handle.getModuleHandle().getCommandStack().commit();
    updatePredefinedQueries();
    checkColBindingForCube();
  }
 else {
    handle.getModuleHandle().getCommandStack().rollback();
  }
  return openStatus;
}
Program: 69588
Project: 69588
Buggy source:
private void autoSelect(boolean force){
  if (dataProvider.checkState(IDataServiceProvider.SHARE_CROSSTAB_QUERY)) {
    Query query=ChartUIUtil.getAllOrthogonalSeriesDefinitions(getContext().getModel()).get(0).getDesignTimeSeries().getDataDefinition().get(0);
    Object[] valueExprs=getContext().getPredefinedQuery(ChartUIConstants.QUERY_VALUE);
    if ((force || query.getDefinition() == null || query.getDefinition().trim().length() == 0) && valueExprs != null && valueExprs.length == 1) {
      String text=valueExprs[0].toString();
      query.setDefinition(text);
      if (dataProvider.update(ChartUIConstants.QUERY_VALUE,text)) {
        Event e=new Event();
        e.type=IChartDataSheet.EVENT_QUERY;
        this.notifyListeners(e);
      }
      if (force) {
        fireEvent(tablePreview,EVENT_PREVIEW);
      }
    }
  }
}

Fixed version (ground truth):
private void autoSelect(boolean force){
  if (dataProvider.checkState(IDataServiceProvider.SHARE_CROSSTAB_QUERY) && !dataProvider.checkState(IDataServiceProvider.SHARE_CHART_QUERY)) {
    Query query=ChartUIUtil.getAllOrthogonalSeriesDefinitions(getContext().getModel()).get(0).getDesignTimeSeries().getDataDefinition().get(0);
    Object[] valueExprs=getContext().getPredefinedQuery(ChartUIConstants.QUERY_VALUE);
    if ((force || query.getDefinition() == null || query.getDefinition().trim().length() == 0) && valueExprs != null && valueExprs.length == 1) {
      String text=valueExprs[0].toString();
      query.setDefinition(text);
      if (dataProvider.update(ChartUIConstants.QUERY_VALUE,text)) {
        Event e=new Event();
        e.type=IChartDataSheet.EVENT_QUERY;
        this.notifyListeners(e);
      }
      if (force) {
        fireEvent(tablePreview,EVENT_PREVIEW);
      }
    }
  }
}