nus-yam/ex-repair huggingface dataset:
Program: 108209
Project: 108209
Buggy source:
/** 
 * Tries to detect the line break.
 * @throws IOException Signals that an I/O exception has occurred.
 */
private void detectLinebreak() throws IOException {
  BufferedReader r=null;
  final char[] buffer=new char[ImportWizardModel.DETECT_MAX_CHARS];
  int read=0;
  try {
    r=new BufferedReader(new FileReader(new File(comboLocation.getText())));
    read=r.read(buffer);
  }
  finally {
    if (r != null) {
      r.close();
    }
  }
  if (read > 0) {
    for (int i=0; i < buffer.length; i++) {
      char current=buffer[i];
      if (current == '\r') {
        if (i < buffer.length - 1 && buffer[i + 1] == '\n') {
          selectedLinebreak=1;
        }
 else {
          selectedLinebreak=2;
        }
        return;
      }
      if (current == '\n') {
        selectedLinebreak=0;
        return;
      }
    }
  }
}

Fixed version (ground truth):
/** 
 * Tries to detect the line break.
 * @throws IOException Signals that an I/O exception has occurred.
 */
private void detectLinebreak() throws IOException {
  BufferedReader r=null;
  final char[] buffer=new char[ImportWizardModel.DETECT_MAX_CHARS];
  int read=0;
  try {
    r=new BufferedReader(new FileReader(new File(comboLocation.getText())));
    read=r.read(buffer);
  }
  finally {
    if (r != null) {
      r.close();
    }
  }
  if (read > 0) {
    for (int i=0; i < read; i++) {
      char current=buffer[i];
      if (current == '\r') {
        if (i < buffer.length - 1 && buffer[i + 1] == '\n') {
          selectedLinebreak=1;
        }
 else {
          selectedLinebreak=2;
        }
        return;
      }
      if (current == '\n') {
        selectedLinebreak=0;
        return;
      }
    }
  }
}
Program: 108212
Project: 108212
Buggy source:
public void modifyText(ModifyEvent arg0){
  double value;
  try {
    value=Double.valueOf(text2.getText());
  }
 catch (  Exception e) {
    value=-1;
  }
  if (model == null || model.getInputConfig() == null || model.getInputConfig().getInput() == null) {
    return;
  }
  DataHandle handle=model.getInputConfig().getInput().getHandle();
  if (value < handle.getNumRows()) {
    text2.setForeground(GUIHelper.COLOR_RED);
    return;
  }
 else {
    text2.setForeground(GUIHelper.COLOR_BLACK);
  }
  if (value == model.getRiskModel().getPopulationSize(handle)) {
    return;
  }
  model.getRiskModel().setPopulationSize(handle,value);
  for (int i=0; i < list.getItemCount(); i++) {
    if (list.getItem(i).equals(Region.NONE.getName())) {
      list.select(i);
      break;
    }
  }
  text.setText(format.format(model.getRiskModel().getSampleFraction(handle)));
  controller.update(new ModelEvent(ViewRisksPopulationModel.this,ModelPart.POPULATION_MODEL,model.getRiskModel()));
}

Fixed version (ground truth):
public void modifyText(ModifyEvent arg0){
  double value;
  try {
    value=format.parse(text2.getText()).doubleValue();
  }
 catch (  Exception e) {
    value=-1;
  }
  if (model == null || model.getInputConfig() == null || model.getInputConfig().getInput() == null) {
    return;
  }
  DataHandle handle=model.getInputConfig().getInput().getHandle();
  if (value < handle.getNumRows()) {
    text2.setForeground(GUIHelper.COLOR_RED);
    return;
  }
 else {
    text2.setForeground(GUIHelper.COLOR_BLACK);
  }
  if (value == model.getRiskModel().getPopulationSize(handle)) {
    return;
  }
  model.getRiskModel().setPopulationSize(handle,value);
  for (int i=0; i < list.getItemCount(); i++) {
    if (list.getItem(i).equals(Region.NONE.getName())) {
      list.select(i);
      break;
    }
  }
  text.setText(format.format(model.getRiskModel().getSampleFraction(handle)));
  controller.update(new ModelEvent(ViewRisksPopulationModel.this,ModelPart.POPULATION_MODEL,model.getRiskModel()));
}
Program: 108214
Project: 108214
Buggy source:
/** 
 * @param context
 * @return
 */
protected abstract T createViewConfig(AnalysisContext context);

Fixed version (ground truth):
/** 
 * Creates a view config
 * @param context
 * @return
 */
protected abstract T createViewConfig(AnalysisContext context);
Program: 108215
Project: 108215
Buggy source:
@Override public void onInterrupt(){
  if (!isEnabled()) {
    setStatusEmpty();
  }
 else {
    setStatusWorking();
  }
}

Fixed version (ground truth):
@Override public void onInterrupt(){
  if (!isEnabled() || !isValid()) {
    setStatusEmpty();
  }
 else {
    setStatusWorking();
  }
}
Program: 108217
Project: 108217
Buggy source:
@Override public void onInterrupt(){
  if (!isEnabled()) {
    setStatusEmpty();
  }
 else {
    setStatusWorking();
  }
}

Fixed version (ground truth):
@Override public void onInterrupt(){
  if (!isEnabled() || !isValid()) {
    setStatusEmpty();
  }
 else {
    setStatusWorking();
  }
}
Program: 108219
Project: 108219
Buggy source:
@Override public void onInterrupt(){
  if (!isEnabled()) {
    setStatusEmpty();
  }
 else {
    setStatusWorking();
  }
}

Fixed version (ground truth):
@Override public void onInterrupt(){
  if (!isEnabled() || !isValid()) {
    setStatusEmpty();
  }
 else {
    setStatusWorking();
  }
}
Program: 108221
Project: 108221
Buggy source:
@Override public void onInterrupt(){
  if (!isEnabled()) {
    setStatusEmpty();
  }
 else {
    setStatusWorking();
  }
}

Fixed version (ground truth):
@Override public void onInterrupt(){
  if (!isEnabled() || !isValid()) {
    setStatusEmpty();
  }
 else {
    setStatusWorking();
  }
}
Program: 108223
Project: 108223
Buggy source:
@Override public void onInterrupt(){
  if (!isEnabled()) {
    setStatusEmpty();
  }
 else {
    setStatusWorking();
  }
}

Fixed version (ground truth):
@Override public void onInterrupt(){
  if (!isEnabled() || !isValid()) {
    setStatusEmpty();
  }
 else {
    setStatusWorking();
  }
}
Program: 108227
Project: 108227
Buggy source:
/** 
 */
private void parse(){
  final String query=text.getText();
  final DataSelector selector;
  try {
    selector=DataSelector.create(data,query);
    selector.build();
  }
 catch (  Exception e) {
    this.status.setText(e.getMessage());
    this.ok.setEnabled(false);
    this.selector=null;
    return;
  }
  this.status.setText("String_Node_Str");
  this.queryString=text.getText();
  this.selector=selector;
  this.ok.setEnabled(true);
}

Fixed version (ground truth):
/** 
 */
private void parse(){
synchronized (this) {
    final String query=text.getText();
    final DataSelector selector;
    try {
      selector=DataSelector.create(data,query);
      selector.build();
    }
 catch (    Exception e) {
      this.status.setText(e.getMessage());
      this.ok.setEnabled(false);
      this.selector=null;
      return;
    }
    this.status.setText("String_Node_Str");
    this.queryString=text.getText();
    this.selector=selector;
    this.ok.setEnabled(true);
  }
}
Program: 108228
Project: 108228
Buggy source:
@Override public void onInterrupt(){
  if (stopped || !isEnabled()) {
    setStatusEmpty();
  }
 else {
    setStatusWorking();
  }
}

Fixed version (ground truth):
@Override public void onInterrupt(){
  if (!isEnabled()) {
    setStatusEmpty();
  }
 else {
    setStatusWorking();
  }
}
Program: 108230
Project: 108230
Buggy source:
@Override public void onInterrupt(){
  if (stopped || !isEnabled()) {
    setStatusEmpty();
  }
 else {
    setStatusWorking();
  }
}

Fixed version (ground truth):
@Override public void onInterrupt(){
  if (!isEnabled()) {
    setStatusEmpty();
  }
 else {
    setStatusWorking();
  }
}
Program: 108232
Project: 108232
Buggy source:
@Override public void onInterrupt(){
  if (stopped || !isEnabled()) {
    setStatusEmpty();
  }
 else {
    setStatusWorking();
  }
}

Fixed version (ground truth):
@Override public void onInterrupt(){
  if (!isEnabled()) {
    setStatusEmpty();
  }
 else {
    setStatusWorking();
  }
}
Program: 108234
Project: 108234
Buggy source:
@Override public void onInterrupt(){
  if (stopped || !isEnabled()) {
    setStatusEmpty();
  }
 else {
    setStatusWorking();
  }
}

Fixed version (ground truth):
@Override public void onInterrupt(){
  if (!isEnabled()) {
    setStatusEmpty();
  }
 else {
    setStatusWorking();
  }
}
Program: 108236
Project: 108236
Buggy source:
@Override public void onInterrupt(){
  if (stopped || !isEnabled()) {
    setStatusEmpty();
  }
 else {
    setStatusWorking();
  }
}

Fixed version (ground truth):
@Override public void onInterrupt(){
  if (!isEnabled()) {
    setStatusEmpty();
  }
 else {
    setStatusWorking();
  }
}
Program: 108238
Project: 108238
Buggy source:
/** 
 * Reads the clipboard from the file.
 * @param map
 * @param zip
 * @throws SAXException
 * @throws IOException
 */
private void readClipboard(final Map<String,ARXNode> map,final ZipFile zip) throws SAXException, IOException {
  final ZipEntry entry=zip.getEntry("String_Node_Str");
  if (entry == null) {
    return;
  }
  model.getClipboard().clearClipboard();
  final XMLReader xmlReader=XMLReaderFactory.createXMLReader();
  final InputSource inputSource=new InputSource(new BufferedInputStream(zip.getInputStream(entry)));
  xmlReader.setContentHandler(new XMLHandler(){
    @Override protected boolean end(    final String uri,    final String localName,    final String qName) throws SAXException {
      if (vocabulary.isClipboard(localName)) {
        return true;
      }
 else       if (vocabulary.isNode(localName)) {
        final ARXNode node=map.get(payload.trim());
        model.getClipboard().addToClipboard(node);
        return true;
      }
 else {
        return false;
      }
    }
    @Override protected boolean start(    final String uri,    final String localName,    final String qName,    final Attributes attributes) throws SAXException {
      if (vocabulary.isClipboard(localName) || vocabulary.isNode(localName)) {
        return true;
      }
 else {
        return false;
      }
    }
  }
);
  xmlReader.parse(inputSource);
}

Fixed version (ground truth):
/** 
 * Reads the clipboard from the file.
 * @param map
 * @param zip
 * @throws SAXException
 * @throws IOException
 */
private void readClipboard(final Map<String,ARXNode> map,final ZipFile zip) throws SAXException, IOException {
  final ZipEntry entry=zip.getEntry("String_Node_Str");
  if (entry == null) {
    return;
  }
  model.getClipboard().clearClipboard();
  final XMLReader xmlReader=XMLReaderFactory.createXMLReader();
  final InputSource inputSource=new InputSource(new BufferedInputStream(zip.getInputStream(entry)));
  xmlReader.setContentHandler(new XMLHandler(){
    @Override protected boolean end(    final String uri,    final String localName,    final String qName) throws SAXException {
      if (vocabulary.isClipboard(localName)) {
        return true;
      }
 else       if (vocabulary.isNode(localName)) {
        if (payload == null || map == null)         return true;
        final ARXNode node=map.get(payload.trim());
        model.getClipboard().addToClipboard(node);
        return true;
      }
 else {
        return false;
      }
    }
    @Override protected boolean start(    final String uri,    final String localName,    final String qName,    final Attributes attributes) throws SAXException {
      if (vocabulary.isClipboard(localName) || vocabulary.isNode(localName)) {
        return true;
      }
 else {
        return false;
      }
    }
  }
);
  xmlReader.parse(inputSource);
}
Program: 108239
Project: 108239
Buggy source:
@Override protected void doUpdate(final AnalysisContextRisk context){
  Analysis analysis=new Analysis(){
    RiskEstimateBuilderInterruptible builder=getBuilder(context,context.context.getModel().getSelectedQuasiIdentifiers());
    private boolean stopped=false;
    private RiskModelAttributes risks;
    @Override public void onError(){
      setStatusEmpty();
    }
    @Override public void onFinish(){
      if (stopped) {
        return;
      }
      for (      final TableItem i : items) {
        i.dispose();
      }
      items.clear();
      for (      QuasiIdentifierRisks item : risks.getAttributeRisks()) {
        createItem(item);
      }
      for (      final TableColumn col : columns) {
        col.pack();
      }
      setStatusDone();
      table.layout();
      table.redraw();
    }
    @Override public void onInterrupt(){
      setStatusWorking();
    }
    @Override public void run() throws InterruptedException {
      long time=System.currentTimeMillis();
      risks=builder.getPopulationBasedAttributeRisks();
      while (System.currentTimeMillis() - time < MINIMAL_WORKING_TIME && !stopped) {
        Thread.sleep(10);
      }
    }
    @Override public void stop(){
      builder.interrupt();
      this.stopped=true;
    }
  }
;
  this.manager.start(analysis);
}

Fixed version (ground truth):
@Override protected void doUpdate(final AnalysisContextRisk context){
  Analysis analysis=new Analysis(){
    RiskEstimateBuilderInterruptible builder=getBuilder(context,context.context.getModel().getSelectedQuasiIdentifiers());
    private boolean stopped=false;
    private RiskModelAttributes risks;
    @Override public void onError(){
      setStatusEmpty();
    }
    @Override public void onFinish(){
      if (stopped) {
        return;
      }
      for (      final TableItem i : items) {
        i.dispose();
      }
      items.clear();
      for (      QuasiIdentifierRisks item : risks.getAttributeRisks()) {
        createItem(item);
      }
      for (      final TableColumn col : columns) {
        col.pack();
      }
      if (risks.getAttributeRisks().length == 0) {
        setStatusEmpty();
      }
 else {
        setStatusDone();
      }
      table.layout();
      table.redraw();
    }
    @Override public void onInterrupt(){
      setStatusWorking();
    }
    @Override public void run() throws InterruptedException {
      long time=System.currentTimeMillis();
      risks=builder.getPopulationBasedAttributeRisks();
      while (System.currentTimeMillis() - time < MINIMAL_WORKING_TIME && !stopped) {
        Thread.sleep(10);
      }
    }
    @Override public void stop(){
      builder.interrupt();
      this.stopped=true;
    }
  }
;
  this.manager.start(analysis);
}
Program: 108240
Project: 108240
Buggy source:
@Override public void onFinish(){
  if (stopped) {
    return;
  }
  for (  final TableItem i : items) {
    i.dispose();
  }
  items.clear();
  for (  QuasiIdentifierRisks item : risks.getAttributeRisks()) {
    createItem(item);
  }
  for (  final TableColumn col : columns) {
    col.pack();
  }
  setStatusDone();
  table.layout();
  table.redraw();
}

Fixed version (ground truth):
@Override public void onFinish(){
  if (stopped) {
    return;
  }
  for (  final TableItem i : items) {
    i.dispose();
  }
  items.clear();
  for (  QuasiIdentifierRisks item : risks.getAttributeRisks()) {
    createItem(item);
  }
  for (  final TableColumn col : columns) {
    col.pack();
  }
  if (risks.getAttributeRisks().length == 0) {
    setStatusEmpty();
  }
 else {
    setStatusDone();
  }
  table.layout();
  table.redraw();
}
Program: 108241
Project: 108241
Buggy source:
public void widgetSelected(SelectionEvent arg0){
  if (model.getInputConfig() != null && model.getInputConfig().getInput() != null && list.getSelection() != null && list.getSelection().length != 0) {
    long sampleSize=model.getInputConfig().getInput().getHandle().getNumRows();
    long populationSize=-1;
    Region selected=null;
    for (    Region region : Region.values()) {
      if (region.getName().equals(list.getSelection()[0])) {
        populationSize=region.getPopulation();
        selected=region;
        break;
      }
    }
    if (populationSize == -1) {
      return;
    }
    double sampleFraction=(double)sampleSize / (double)populationSize;
    model.getPopulationModel().setRegion(selected);
    controller.update(new ModelEvent(ViewRisksPopulationModel.this,ModelPart.POPULATION_MODEL,model.getPopulationModel()));
    text.setText(format.format(sampleFraction));
    text2.setText(format.format(populationSize));
  }
}

Fixed version (ground truth):
public void widgetSelected(SelectionEvent arg0){
  if (model.getInputConfig() != null && model.getInputConfig().getInput() != null && list.getSelection() != null && list.getSelection().length != 0) {
    long sampleSize=model.getInputConfig().getInput().getHandle().getNumRows();
    long populationSize=-1;
    Region selected=null;
    for (    Region region : Region.values()) {
      if (region.getName().equals(list.getSelection()[0])) {
        populationSize=region.getPopulation();
        selected=region;
        break;
      }
    }
    if (populationSize == -1) {
      return;
    }
    model.getPopulationModel().setRegion(selected);
    controller.update(new ModelEvent(ViewRisksPopulationModel.this,ModelPart.POPULATION_MODEL,model.getPopulationModel()));
    text.setText(format.format(model.getPopulationModel().getSampleFraction(sampleSize)));
    text2.setText(format.format(model.getPopulationModel().getPopulationSize(sampleSize)));
  }
}
Program: 108243
Project: 108243
Buggy source:
public void widgetSelected(SelectionEvent arg0){
  Set<String> selection=new HashSet<String>();
  for (  TableItem item : table.getItems()) {
    if (item.getChecked()) {
      selection.add(item.getText());
    }
  }
  if (model != null) {
    if (selection.size() <= model.getPopulationModel().getMaxQiSize()) {
      model.setSelectedQuasiIdentifiers(selection);
      controller.update(new ModelEvent(ViewRisksQuasiIdentifiers.this,ModelPart.SELECTED_QUASI_IDENTIFIERS,selection));
      label.setText("String_Node_Str" + (int)(Math.pow(2,selection.size()) - 1));
      label.setForeground(GUIHelper.COLOR_BLACK);
    }
 else {
      label.setText("String_Node_Str" + (int)(Math.pow(2,selection.size()) - 1));
      label.setForeground(GUIHelper.COLOR_RED);
    }
  }
}

Fixed version (ground truth):
public void widgetSelected(SelectionEvent arg0){
  fireEvent();
}
Program: 108244
Project: 108244
Buggy source:
/** 
 * Creates a new instance.
 * @param parent
 * @param controller
 */
public ViewRisksQuasiIdentifiers(final Composite parent,final Controller controller){
  controller.addListener(ModelPart.INPUT,this);
  controller.addListener(ModelPart.MODEL,this);
  controller.addListener(ModelPart.SELECTED_QUASI_IDENTIFIERS,this);
  this.controller=controller;
  root=parent;
  root.setLayout(GridLayoutFactory.swtDefaults().numColumns(1).create());
  create(root);
  reset();
}

Fixed version (ground truth):
/** 
 * Creates a new instance.
 * @param parent
 * @param controller
 */
public ViewRisksQuasiIdentifiers(final Composite parent,final Controller controller){
  controller.addListener(ModelPart.INPUT,this);
  controller.addListener(ModelPart.MODEL,this);
  controller.addListener(ModelPart.SELECTED_QUASI_IDENTIFIERS,this);
  this.controller=controller;
  root=parent;
  root.setLayout(GridLayoutFactory.swtDefaults().numColumns(2).create());
  create(root);
  reset();
}
Program: 108245
Project: 108245
Buggy source:
/** 
 * Creates the required controls.
 * @param parent
 */
private void create(final Composite parent){
  table=new Table(parent,SWT.CHECK | SWT.V_SCROLL | SWT.H_SCROLL| SWT.BORDER);
  table.setLayoutData(SWTUtil.createFillGridData());
  label=new Label(parent,SWT.NONE);
  label.setText("String_Node_Str");
  label.setLayoutData(SWTUtil.createFillHorizontallyGridData());
  table.addSelectionListener(new SelectionAdapter(){
    public void widgetSelected(    SelectionEvent arg0){
      Set<String> selection=new HashSet<String>();
      for (      TableItem item : table.getItems()) {
        if (item.getChecked()) {
          selection.add(item.getText());
        }
      }
      if (model != null) {
        if (selection.size() <= model.getPopulationModel().getMaxQiSize()) {
          model.setSelectedQuasiIdentifiers(selection);
          controller.update(new ModelEvent(ViewRisksQuasiIdentifiers.this,ModelPart.SELECTED_QUASI_IDENTIFIERS,selection));
          label.setText("String_Node_Str" + (int)(Math.pow(2,selection.size()) - 1));
          label.setForeground(GUIHelper.COLOR_BLACK);
        }
 else {
          label.setText("String_Node_Str" + (int)(Math.pow(2,selection.size()) - 1));
          label.setForeground(GUIHelper.COLOR_RED);
        }
      }
    }
  }
);
}

Fixed version (ground truth):
/** 
 * Creates the required controls.
 * @param parent
 */
private void create(final Composite parent){
  table=new Table(parent,SWT.CHECK | SWT.V_SCROLL | SWT.H_SCROLL| SWT.BORDER);
  table.setLayoutData(GridDataFactory.fillDefaults().grab(true,true).span(2,1).create());
  Button button=new Button(parent,SWT.PUSH);
  button.setLayoutData(SWTUtil.createGridData());
  button.setText("String_Node_Str");
  button.addSelectionListener(new SelectionAdapter(){
    public void widgetSelected(    SelectionEvent arg0){
      for (      TableItem item : table.getItems()) {
        item.setChecked(false);
      }
      fireEvent();
    }
  }
);
  label=new Label(parent,SWT.RIGHT);
  label.setText("String_Node_Str");
  label.setLayoutData(SWTUtil.createFillHorizontallyGridData());
  table.addSelectionListener(new SelectionAdapter(){
    public void widgetSelected(    SelectionEvent arg0){
      fireEvent();
    }
  }
);
}
Program: 108247
Project: 108247
Buggy source:
/** 
 * Reads the clipboard from the file.
 * @param map
 * @param zip
 * @throws SAXException
 * @throws IOException
 */
private void readClipboard(final Map<String,ARXNode> map,final ZipFile zip) throws SAXException, IOException {
  final ZipEntry entry=zip.getEntry("String_Node_Str");
  if (entry == null) {
    return;
  }
  model.getClipboard().clearClipboard();
  final XMLReader xmlReader=XMLReaderFactory.createXMLReader();
  final InputSource inputSource=new InputSource(new BufferedInputStream(zip.getInputStream(entry)));
  xmlReader.setContentHandler(new XMLHandler(){
    @Override protected boolean end(    final String uri,    final String localName,    final String qName) throws SAXException {
      if (vocabulary.isClipboard(localName)) {
        return true;
      }
 else       if (vocabulary.isNode(localName)) {
        final ARXNode node=map.get(payload.trim());
        model.getClipboard().addToClipboard(node);
        return true;
      }
 else {
        return false;
      }
    }
    @Override protected boolean start(    final String uri,    final String localName,    final String qName,    final Attributes attributes) throws SAXException {
      if (vocabulary.isClipboard(localName) || vocabulary.isNode(localName)) {
        return true;
      }
 else {
        return false;
      }
    }
  }
);
  xmlReader.parse(inputSource);
}

Fixed version (ground truth):
/** 
 * Reads the clipboard from the file.
 * @param map
 * @param zip
 * @throws SAXException
 * @throws IOException
 */
private void readClipboard(final Map<String,ARXNode> map,final ZipFile zip) throws SAXException, IOException {
  final ZipEntry entry=zip.getEntry("String_Node_Str");
  if (entry == null) {
    return;
  }
  model.getClipboard().clearClipboard();
  final XMLReader xmlReader=XMLReaderFactory.createXMLReader();
  final InputSource inputSource=new InputSource(new BufferedInputStream(zip.getInputStream(entry)));
  xmlReader.setContentHandler(new XMLHandler(){
    @Override protected boolean end(    final String uri,    final String localName,    final String qName) throws SAXException {
      if (vocabulary.isClipboard(localName)) {
        return true;
      }
 else       if (vocabulary.isNode(localName)) {
        if (payload == null || map == null)         return true;
        final ARXNode node=map.get(payload.trim());
        model.getClipboard().addToClipboard(node);
        return true;
      }
 else {
        return false;
      }
    }
    @Override protected boolean start(    final String uri,    final String localName,    final String qName,    final Attributes attributes) throws SAXException {
      if (vocabulary.isClipboard(localName) || vocabulary.isNode(localName)) {
        return true;
      }
 else {
        return false;
      }
    }
  }
);
  xmlReader.parse(inputSource);
}
Program: 108248
Project: 108248
Buggy source:
/** 
 * @param hierarchy
 * @throws IOException
 */
public void write(final String[][] hierarchy) throws IOException {
  CsvWriter csvwriter=new CsvWriter(writer,settings);
  csvwriter.writeRowsAndClose(hierarchy);
}

Fixed version (ground truth):
/** 
 * @param hierarchy
 * @throws IOException
 */
public void write(final String[][] hierarchy) throws IOException {
  CsvWriter csvwriter=new CsvWriter(writer,settings);
  for (int i=0; i < hierarchy.length; i++) {
    csvwriter.writeRow((Object[])hierarchy[i]);
  }
  if (close)   csvwriter.close();
 else   csvwriter.flush();
}
Program: 108249
Project: 108249
Buggy source:
/** 
 * Adds input to table viewer once page gets visible.
 * @param visible
 */
@Override public void setVisible(boolean visible){
  super.setVisible(visible);
  if (visible) {
    checkboxTableViewer.setInput(wizardImport.getData().getWizardColumns());
    setPageComplete((wizardImport.getData().getWizardColumns().size() > 0));
  }
}

Fixed version (ground truth):
/** 
 * Adds input to table viewer once page gets visible.
 * @param visible
 */
@Override public void setVisible(boolean visible){
  super.setVisible(visible);
  if (visible) {
    checkboxTableViewer.setInput(wizardImport.getData().getWizardColumns());
    check();
  }
}
Program: 108250
Project: 108250
Buggy source:
/** 
 * Sets name for given column (  {@link ImportColumn#setAliasName(String)}).
 * @param element
 * @param value
 */
@Override protected void setValue(Object element,Object value){
  ((ImportWizardModelColumn)element).getColumn().setAliasName((String)value);
  getViewer().update(element,null);
}

Fixed version (ground truth):
/** 
 * Sets name for given column (  {@link ImportColumn#setAliasName(String)}).
 * @param element
 * @param value
 */
@Override protected void setValue(Object element,Object value){
  ((ImportWizardModelColumn)element).getColumn().setAliasName((String)value);
  getViewer().update(element,null);
  check();
}
Program: 108251
Project: 108251
Buggy source:
/** 
 * Sets the enabled status for the given item Using   {@link ImportWizardModelColumn#setEnabled(boolean)} thismethod will set the enabled flag for the given column. Furthermore it makes sure the page is marked as complete once at least one item is selected.
 */
@Override public void checkStateChanged(CheckStateChangedEvent event){
  setPageComplete(false);
  ((ImportWizardModelColumn)event.getElement()).setEnabled(event.getChecked());
  for (  ImportWizardModelColumn column : wizardImport.getData().getWizardColumns()) {
    if (column.isEnabled()) {
      setPageComplete(true);
      return;
    }
  }
}

Fixed version (ground truth):
/** 
 * Sets the enabled status for the given item Using   {@link ImportWizardModelColumn#setEnabled(boolean)} thismethod will set the enabled flag for the given column. Furthermore it makes sure the page is marked as complete once at least one item is selected.
 */
@Override public void checkStateChanged(CheckStateChangedEvent event){
  ((ImportWizardModelColumn)event.getElement()).setEnabled(event.getChecked());
  check();
}
Program: 108253
Project: 108253
Buggy source:
@Override protected String[] readRow() throws IOException {
  final String line=reader.readLine();
  if (line == null) {
    reader.close();
    return null;
  }
  if (columns == -1) {
    columns=countColumns(line);
  }
  final String[] tuple=new String[columns];
  int column=0;
  int offset=0;
  int index=0;
  while (column < (columns - 1)) {
    index=line.indexOf(separator,offset);
    if (index < 0) {
      throw new IOException("String_Node_Str" + tuple.length + "String_Node_Str");
    }
    tuple[column++]=line.substring(offset,index);
    offset=index + 1;
  }
  tuple[column]=line.substring(offset);
  return tuple;
}

Fixed version (ground truth):
@Override protected String[] readRow() throws IOException {
  final String line=reader.readLine();
  if (line == null) {
    reader.close();
    return null;
  }
  if (columns == -1) {
    columns=countColumns(line);
  }
  final String[] tuple=new String[columns];
  int column=0;
  int offset=0;
  int index=0;
  while (column < (columns - 1)) {
    index=line.indexOf(separator,offset);
    if (index < 0) {
      System.out.println(line);
      throw new IOException("String_Node_Str" + tuple.length + "String_Node_Str");
    }
    tuple[column++]=line.substring(offset,index);
    offset=index + 1;
  }
  tuple[column]=line.substring(offset);
  return tuple;
}
Program: 108254
Project: 108254
Buggy source:
/** 
 * Returns the next row The returned element is sorted as defined by   {@link ImportColumn#index} and contains as many elements as there are columns selected to importfrom  {@link #indexes}. The first row will always contain the names of the columns.   {@link #headerReturned} is used to keep track of that.
 * @return
 */
@Override public String[] next(){
  if (!headerReturned) {
    headerReturned=true;
    return header;
  }
  if (row.getPhysicalNumberOfCells() > numberOfColumns) {
    throw new IllegalArgumentException("String_Node_Str" + currentRow + "String_Node_Str");
  }
  String[] result=new String[indexes.length];
  for (int i=0; i < indexes.length; i++) {
    row.getCell(indexes[i]).setCellType(Cell.CELL_TYPE_STRING);
    result[i]=row.getCell(indexes[i]).getStringCellValue();
    if (!dataTypes[i].isValid(result[i])) {
      throw new IllegalArgumentException("String_Node_Str");
    }
  }
  if (iterator.hasNext()) {
    row=iterator.next();
    currentRow++;
  }
 else {
    row=null;
    try {
      input.close();
    }
 catch (    Exception e) {
    }
  }
  return result;
}

Fixed version (ground truth):
/** 
 * Returns the next row The returned element is sorted as defined by   {@link ImportColumn#index} and contains as many elements as there are columns selected to importfrom  {@link #indexes}. The first row will always contain the names of the columns.   {@link #headerReturned} is used to keep track of that.
 * @return
 */
@Override public String[] next(){
  if (!headerReturned) {
    headerReturned=true;
    return header;
  }
  String[] result=new String[indexes.length];
  for (int i=0; i < indexes.length; i++) {
    row.getCell(indexes[i]).setCellType(Cell.CELL_TYPE_STRING);
    result[i]=row.getCell(indexes[i]).getStringCellValue();
    if (!dataTypes[i].isValid(result[i])) {
      throw new IllegalArgumentException("String_Node_Str");
    }
  }
  if (iterator.hasNext()) {
    row=iterator.next();
    currentRow++;
  }
 else {
    row=null;
    try {
      input.close();
    }
 catch (    Exception e) {
    }
  }
  return result;
}
Program: 108255
Project: 108255
Buggy source:
/** 
 * Creates the header row This returns a string array with the names of the columns that will be returned later on by iterating over this object. Depending upon the configuration   {@link ImportConfigurationExcel#getContainsHeader()} andwhether or not names have been assigned explicitly either the appropriate values will be returned, or names will be made up on the fly following the pattern "Column #x", where x is incremented for each column.
 * @return
 */
private String[] createHeader(){
  if (config.getContainsHeader())   this.config.prepare(row);
  this.indexes=getIndexesToImport();
  this.dataTypes=getColumnDatatypes();
  String[] header=new String[config.getColumns().size()];
  List<ImportColumn> columns=config.getColumns();
  for (int i=0, len=columns.size(); i < len; i++) {
    ImportColumn column=columns.get(i);
    row.getCell(((ImportColumnExcel)column).getIndex()).setCellType(Cell.CELL_TYPE_STRING);
    String name=row.getCell(((ImportColumnExcel)column).getIndex()).getStringCellValue();
    if (config.getContainsHeader() && !name.equals("String_Node_Str")) {
      header[i]=name;
    }
 else {
      header[i]="String_Node_Str" + ((ImportColumnExcel)column).getIndex();
    }
    if (column.getAliasName() != null) {
      header[i]=column.getAliasName();
    }
    column.setAliasName(header[i]);
  }
  if (config.getContainsHeader()) {
    if (iterator.hasNext()) {
      row=iterator.next();
      currentRow++;
    }
 else {
      row=null;
    }
  }
  numberOfColumns=header.length;
  return header;
}

Fixed version (ground truth):
/** 
 * Creates the header row This returns a string array with the names of the columns that will be returned later on by iterating over this object. Depending upon the configuration   {@link ImportConfigurationExcel#getContainsHeader()} andwhether or not names have been assigned explicitly either the appropriate values will be returned, or names will be made up on the fly following the pattern "Column #x", where x is incremented for each column.
 * @return
 */
private String[] createHeader(){
  if (config.getContainsHeader())   this.config.prepare(row);
  this.indexes=getIndexesToImport();
  this.dataTypes=getColumnDatatypes();
  String[] header=new String[config.getColumns().size()];
  List<ImportColumn> columns=config.getColumns();
  for (int i=0, len=columns.size(); i < len; i++) {
    ImportColumn column=columns.get(i);
    row.getCell(((ImportColumnExcel)column).getIndex()).setCellType(Cell.CELL_TYPE_STRING);
    String name=row.getCell(((ImportColumnExcel)column).getIndex()).getStringCellValue();
    if (config.getContainsHeader() && !name.equals("String_Node_Str")) {
      header[i]=name;
    }
 else {
      header[i]="String_Node_Str" + ((ImportColumnExcel)column).getIndex();
    }
    if (column.getAliasName() != null) {
      header[i]=column.getAliasName();
    }
    column.setAliasName(header[i]);
  }
  if (config.getContainsHeader()) {
    if (iterator.hasNext()) {
      row=iterator.next();
      currentRow++;
    }
 else {
      row=null;
    }
  }
  return header;
}
Program: 108257
Project: 108257
Buggy source:
/** 
 * Initializes the view.
 * @param result
 * @param nodeFilter
 */
private void initialize(final ARXResult result,final ModelNodeFilter nodeFilter){
  reset();
  if (result == null || result.getLattice() == null) {
    return;
  }
  this.result=result;
  if (nodeFilter == null) {
    filter=new ModelNodeFilter(result.getLattice().getTop().getTransformation(),model.getInitialNodesInViewer());
    filter.initialize(result);
    if (model != null) {
      model.setNodeFilter(filter);
      controller.update(new ModelEvent(this,ModelPart.FILTER,filter));
    }
  }
 else {
    filter=nodeFilter;
  }
  this.update();
}

Fixed version (ground truth):
/** 
 * Initializes the view.
 * @param result
 * @param nodeFilter
 */
private void initialize(final ARXResult result,final ModelNodeFilter nodeFilter){
  reset();
  if (result == null || result.getLattice() == null) {
    return;
  }
  this.result=result;
  if (nodeFilter == null) {
    throw new IllegalStateException("String_Node_Str");
  }
  filter=nodeFilter;
  this.update();
}
Program: 108258
Project: 108258
Buggy source:
@Override public void update(final ModelEvent event){
  if (event.part == ModelPart.SELECTED_NODE) {
    selectedNode=(ARXNode)event.data;
    eventNodeSelected();
  }
 else   if (event.part == ModelPart.RESULT) {
    if (model != null && model.getResult() != null && model.getResult().getGlobalOptimum() != null) {
      optimum=model.getResult().getGlobalOptimum();
    }
 else {
      optimum=null;
    }
    if (model != null && !isTooLarge(model.getResult(),model.getNodeFilter(),model.getMaxNodesInViewer())) {
      eventResultChanged(model.getResult());
    }
  }
 else   if (event.part == ModelPart.MODEL) {
    model=(Model)event.data;
    if (model != null && model.getResult() != null && model.getResult().getGlobalOptimum() != null) {
      optimum=model.getResult().getGlobalOptimum();
    }
 else {
      optimum=null;
    }
    if (model != null && !isTooLarge(model.getResult(),model.getNodeFilter(),model.getMaxNodesInViewer())) {
      eventModelChanged();
    }
  }
 else   if (event.part == ModelPart.FILTER) {
    if (model != null && !isTooLarge(model.getResult(),(ModelNodeFilter)event.data,model.getMaxNodesInViewer())) {
      eventFilterChanged(model.getResult(),(ModelNodeFilter)event.data);
    }
  }
}

Fixed version (ground truth):
@Override public void update(final ModelEvent event){
  if (event.part == ModelPart.SELECTED_NODE) {
    selectedNode=(ARXNode)event.data;
    eventNodeSelected();
  }
 else   if (event.part == ModelPart.RESULT) {
    ARXResult result=(ARXResult)event.data;
    if (model != null && result != null && result.getGlobalOptimum() != null) {
      optimum=result.getGlobalOptimum();
    }
 else {
      optimum=null;
    }
    if (model != null && !isTooLarge(result,model.getNodeFilter(),model.getMaxNodesInViewer())) {
      eventResultChanged(result);
    }
  }
 else   if (event.part == ModelPart.MODEL) {
    model=(Model)event.data;
    if (model != null && model.getResult() != null && model.getResult().getGlobalOptimum() != null) {
      optimum=model.getResult().getGlobalOptimum();
    }
 else {
      optimum=null;
    }
    if (model != null && !isTooLarge(model.getResult(),model.getNodeFilter(),model.getMaxNodesInViewer())) {
      eventModelChanged();
    }
  }
 else   if (event.part == ModelPart.FILTER) {
    if (model != null && !isTooLarge(model.getResult(),(ModelNodeFilter)event.data,model.getMaxNodesInViewer())) {
      eventFilterChanged(model.getResult(),(ModelNodeFilter)event.data);
    }
  }
}
Program: 108259
Project: 108259
Buggy source:
/** 
 * Replaces the original value with the replacement in the given column. Only supported by handles for input data.
 * @param original
 * @param replacement
 * @return Whether the original value was found
 */
public boolean replace(int column,String original,String replacement){
  checkRegistry();
  checkColumn(column);
  if (!getDataType(getAttributeName(column)).isValid("String_Node_Str")) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  return registry.replace(column,original,replacement);
}

Fixed version (ground truth):
/** 
 * Replaces the original value with the replacement in the given column. Only supported by handles for input data.
 * @param original
 * @param replacement
 * @return Whether the original value was found
 */
public boolean replace(int column,String original,String replacement){
  checkRegistry();
  checkColumn(column);
  if (!getDataType(getAttributeName(column)).isValid(replacement)) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  for (  String s : getDistinctValues(column)) {
    if (s.equals(replacement)) {
      throw new IllegalArgumentException("String_Node_Str");
    }
  }
  return registry.replace(column,original,replacement);
}
Program: 108260
Project: 108260
Buggy source:
/** 
 * Check whether the filtered part of the solution space is too large
 * @param result
 * @param filter
 * @return
 */
private boolean isTooLarge(ARXResult result,ModelNodeFilter filter,int max){
  int count=0;
  final ARXLattice l=result.getLattice();
  for (  final ARXNode[] level : l.getLevels()) {
    for (    final ARXNode node : level) {
      if (filter.isAllowed(result.getLattice(),node)) {
        count++;
      }
    }
  }
  if (count > max) {
    showSecondaryComposite(count,max);
    return true;
  }
 else {
    showPrimaryComposite();
    return false;
  }
}

Fixed version (ground truth):
/** 
 * Check whether the filtered part of the solution space is too large
 * @param result
 * @param filter
 * @return
 */
private boolean isTooLarge(ARXResult result,ModelNodeFilter filter,int max){
  if (result == null)   return false;
  int count=0;
  final ARXLattice l=result.getLattice();
  for (  final ARXNode[] level : l.getLevels()) {
    for (    final ARXNode node : level) {
      if (filter.isAllowed(result.getLattice(),node)) {
        count++;
      }
    }
  }
  if (count > max) {
    showSecondaryComposite(count,max);
    return true;
  }
 else {
    showPrimaryComposite();
    return false;
  }
}
Program: 108261
Project: 108261
Buggy source:
/** 
 * Check whether the filtered part of the solution space is too large
 * @param result
 * @param filter
 * @return
 */
private boolean isTooLarge(ARXResult result,ModelNodeFilter filter,int max){
  if (result == null)   return false;
  int count=0;
  final ARXLattice l=result.getLattice();
  for (  final ARXNode[] level : l.getLevels()) {
    for (    final ARXNode node : level) {
      if (filter.isAllowed(result.getLattice(),node)) {
        count++;
      }
    }
  }
  if (count > max) {
    showSecondaryComposite(count,max);
    return true;
  }
 else {
    showPrimaryComposite();
    return false;
  }
}

Fixed version (ground truth):
/** 
 * Check whether the filtered part of the solution space is too large
 * @param result
 * @param filter
 * @return
 */
private boolean isTooLarge(ARXResult result,ModelNodeFilter filter,int max){
  if (result == null) {
    showPrimaryComposite();
    return false;
  }
  int count=0;
  final ARXLattice l=result.getLattice();
  for (  final ARXNode[] level : l.getLevels()) {
    for (    final ARXNode node : level) {
      if (filter.isAllowed(result.getLattice(),node)) {
        count++;
      }
    }
  }
  if (count > max) {
    showSecondaryComposite(count,max);
    return true;
  }
 else {
    showPrimaryComposite();
    return false;
  }
}
Program: 108262
Project: 108262
Buggy source:
/** 
 * Replace a value in the given column
 * @param column
 * @param original
 * @param replacement
 * @return
 */
public boolean replace(int column,String original,String replacement){
  boolean replaced=false;
  replaced|=input.replace(column,original,replacement);
  if (!output.isEmpty()) {
    replaced|=output.values().iterator().next().replace(column,original,replacement);
  }
  return replaced;
}

Fixed version (ground truth):
/** 
 * Replace a value in the given column
 * @param column
 * @param original
 * @param replacement
 * @return
 */
public boolean replace(int column,String original,String replacement){
  boolean replaced=false;
  replaced|=input.internalReplace(column,original,replacement);
  if (!output.isEmpty()) {
    replaced|=output.values().iterator().next().internalReplace(column,original,replacement);
  }
  return replaced;
}
Program: 108264
Project: 108264
Buggy source:
public void run(){
synchronized (fireEvent) {
    if (fireEvent) {
      fireEvent=false;
      actionInfoLossChanged();
    }
  }
  parent.getDisplay().timerExec(SCALE_UPDATE_INTERVAL,this);
}

Fixed version (ground truth):
public void run(){
synchronized (fireEvent) {
    if (fireEvent) {
      fireEvent=false;
      actionInfoLossChanged();
    }
  }
  if (!parent.isDisposed() && !parent.getDisplay().isDisposed()) {
    parent.getDisplay().timerExec(SCALE_UPDATE_INTERVAL,this);
  }
}
Program: 108267
Project: 108267
Buggy source:
public void run(){
synchronized (fireEvent) {
    if (fireEvent) {
      fireEvent=false;
      actionInfoLossChanged();
    }
  }
  parent.getDisplay().timerExec(SCALE_UPDATE_INTERVAL,this);
}

Fixed version (ground truth):
public void run(){
synchronized (fireEvent) {
    if (fireEvent) {
      fireEvent=false;
      actionInfoLossChanged();
    }
  }
  if (!parent.isDisposed() && !parent.getDisplay().isDisposed()) {
    parent.getDisplay().timerExec(SCALE_UPDATE_INTERVAL,this);
  }
}
Program: 108269
Project: 108269
Buggy source:
/** 
 * Dynamically creates an image with the given color
 * @param color
 * @return
 */
private Image getSymbol(Color color){
  if (symbols.containsKey(color)) {
    return symbols.get(color);
  }
  final int WIDTH=16;
  final int HEIGHT=16;
  Image image=getTransparentImage(table.getDisplay(),WIDTH,HEIGHT);
  GC gc=new GC(image);
  gc.setBackground(color);
  if (System.getProperty("String_Node_Str").toLowerCase().indexOf("String_Node_Str") >= 0) {
    gc.fillRectangle(0,0,WIDTH,HEIGHT);
  }
 else {
    gc.setAntialias(SWT.ON);
    gc.fillOval(0,0,WIDTH,HEIGHT);
    gc.setAntialias(SWT.OFF);
  }
  gc.dispose();
  symbols.put(color,image);
  return image;
}

Fixed version (ground truth):
/** 
 * Dynamically creates an image with the given color
 * @param color
 * @return
 */
private Image getSymbol(Color color){
  if (symbols.containsKey(color)) {
    return symbols.get(color);
  }
  final int WIDTH=16;
  final int HEIGHT=16;
  Image image=null;
  GC gc=null;
  String os=System.getProperty("String_Node_Str").toLowerCase();
  if (os.indexOf("String_Node_Str") >= 0 || os.indexOf("String_Node_Str") >= 0) {
    image=new Image(table.getDisplay(),WIDTH,HEIGHT);
    gc=new GC(image);
    gc.setBackground(color);
    gc.fillRectangle(0,0,WIDTH,HEIGHT);
  }
 else {
    image=getTransparentImage(table.getDisplay(),WIDTH,HEIGHT);
    gc=new GC(image);
    gc.setBackground(color);
    gc.setAntialias(SWT.ON);
    gc.fillOval(0,0,WIDTH,HEIGHT);
    gc.setAntialias(SWT.OFF);
  }
  gc.dispose();
  symbols.put(color,image);
  return image;
}
Program: 108270
Project: 108270
Buggy source:
@Override public void characters(final char[] ch,final int start,final int length) throws SAXException {
  payload=new String(ch,start,length);
}

Fixed version (ground truth):
@Override public void characters(final char[] ch,final int start,final int length) throws SAXException {
  sb.add(ch,start,length);
}
Program: 108271
Project: 108271
Buggy source:
@Override public void endElement(final String uri,final String localName,final String qName) throws SAXException {
  if (!end(uri,localName,qName)) {
    throw new SAXException(Resources.getMessage("String_Node_Str") + localName);
  }
}

Fixed version (ground truth):
@Override public void endElement(final String uri,final String localName,final String qName) throws SAXException {
  payload=new String(sb.buffer,0,sb.size());
  if (!end(uri,localName,qName)) {
    throw new SAXException(Resources.getMessage("String_Node_Str") + localName);
  }
}
Program: 108272
Project: 108272
Buggy source:
@Override public void startElement(final String uri,final String localName,final String qName,final Attributes attributes) throws SAXException {
  if (!start(uri,localName,qName,attributes)) {
    throw new SAXException(Resources.getMessage("String_Node_Str") + localName);
  }
}

Fixed version (ground truth):
@Override public void startElement(final String uri,final String localName,final String qName,final Attributes attributes) throws SAXException {
  sb.clear();
  if (!start(uri,localName,qName,attributes)) {
    throw new SAXException(Resources.getMessage("String_Node_Str") + localName);
  }
}
Program: 108273
Project: 108273
Buggy source:
@Override protected double getAggregate(){
  double[] values=getValues();
  double[] weights=getWeights();
  double result=1.0d;
  for (int i=0; i < values.length; i++) {
    result*=Math.pow((values[i] + 1d) * weights[i],1.0d / (double)values.length) - 1d;
  }
  return result;
}

Fixed version (ground truth):
@Override protected double getAggregate(){
  double[] values=getValues();
  double[] weights=getWeights();
  double result=1.0d;
  for (int i=0; i < values.length; i++) {
    result*=Math.pow((values[i] + 1d) * weights[i],1.0d / (double)values.length);
  }
  return result - 1d;
}
Program: 108274
Project: 108274
Buggy source:
/** 
 * Returns the registered value if present, null otherwise.
 * @param dimension
 * @param string
 * @return
 */
public Integer probe(final int dimension,final String string){
  return maps[dimension].get(string);
}

Fixed version (ground truth):
/** 
 * Returns the registered value if present, null otherwise.
 * @param dimension
 * @param string
 * @return
 */
public Integer probe(final int dimension,final String string){
  if (maps[dimension].containsKey(string)) {
    return maps[dimension].lget();
  }
 else {
    return null;
  }
}
Program: 108275
Project: 108275
Buggy source:
@Override protected double getAggregate(){
  double[] values=getValues();
  double[] weights=getWeights();
  double result=1.0d;
  for (int i=0; i < values.length; i++) {
    result*=Math.pow((values[i] > 0d ? values[i] : Double.MIN_VALUE) * weights[i],1.0d / (double)values.length);
  }
  return result;
}

Fixed version (ground truth):
@Override protected double getAggregate(){
  double[] values=getValues();
  double[] weights=getWeights();
  double result=1.0d;
  for (int i=0; i < values.length; i++) {
    result*=Math.pow((values[i] + 1d) * weights[i],1.0d / (double)values.length) - 1d;
  }
  return result;
}