nus-yam/ex-repair huggingface dataset:
Program: 121149
Project: 121149
Buggy source:
@Override public void run(){
  List objects=getSelectedObjects();
  boolean connectionTextActived=false;
  if (!objects.isEmpty()) {
    ConnLabelEditPart connLabelEditPart=null;
    Text text=null;
    if (objects.size() == 1) {
      for (      Object o : objects) {
        if (o instanceof ConnLabelEditPart) {
          connLabelEditPart=(ConnLabelEditPart)objects.get(0);
          if (connLabelEditPart.getDirectEditManager() != null && connLabelEditPart.getDirectEditManager().getTextControl() != null) {
            connectionTextActived=true;
          }
        }
      }
    }
    if (connectionTextActived && connLabelEditPart != null) {
      text=connLabelEditPart.getDirectEditManager().getTextControl();
      text.setText(connLabelEditPart.getDirectEditManager().getOldName());
      text.selectAll();
      return;
    }
  }
  getCommandStack().undo();
}

Fixed version (ground truth):
@Override public void run(){
  getCommandStack().undo();
}
Program: 121150
Project: 121150
Buggy source:
@Override protected void initCellEditor(){
  connection=((ConnectionLabel)this.getEditPart().getModel()).getConnection();
  if (getCellEditor() instanceof NodeLabelCellEditor) {
    ((NodeLabelCellEditor)getCellEditor()).setCurrentConnection(connection);
  }
  Label label=(Label)(getEditPart()).getFigure();
  String initialLabelText=label.getText();
  getCellEditor().setValue(initialLabelText);
  text=(Text)getCellEditor().getControl();
  IFigure figure=(getEditPart()).getFigure();
  scaledFont=figure.getFont();
  FontData data=scaledFont.getFontData()[0];
  Dimension fontSize=new Dimension(0,data.getHeight());
  label.translateToAbsolute(fontSize);
  data.setHeight(fontSize.height);
  scaledFont=new Font(null,data);
  text.setFont(scaledFont);
  text.selectAll();
}

Fixed version (ground truth):
@Override protected void initCellEditor(){
  Connection connection=((ConnectionLabel)this.getEditPart().getModel()).getConnection();
  if (getCellEditor() instanceof NodeLabelCellEditor) {
    ((NodeLabelCellEditor)getCellEditor()).setCurrentConnection(connection);
  }
  Label label=(Label)(getEditPart()).getFigure();
  String initialLabelText=label.getText();
  getCellEditor().setValue(initialLabelText);
  text=(Text)getCellEditor().getControl();
  IFigure figure=(getEditPart()).getFigure();
  scaledFont=figure.getFont();
  FontData data=scaledFont.getFontData()[0];
  Dimension fontSize=new Dimension(0,data.getHeight());
  label.translateToAbsolute(fontSize);
  data.setHeight(fontSize.height);
  scaledFont=new Font(null,data);
  text.setFont(scaledFont);
  text.selectAll();
}
Program: 121151
Project: 121151
Buggy source:
public Class getClassForDoubleClick(){
  return JSONFileConnectionItem.class;
}

Fixed version (ground truth):
@Override public Class getClassForDoubleClick(){
  return JSONFileConnectionItem.class;
}
Program: 121152
Project: 121152
Buggy source:
@Override protected void doRun(){
  if (repositoryNode == null) {
    repositoryNode=getCurrentRepositoryNode();
  }
  if (isToolbar()) {
    if (repositoryNode != null && repositoryNode.getContentType() != JSONRepositoryNodeType.JSON) {
      repositoryNode=null;
    }
    if (repositoryNode == null) {
      repositoryNode=getRepositoryNodeForDefault(JSONRepositoryNodeType.JSON);
    }
  }
  WizardDialog wizardDialog=null;
  if (isToolbar()) {
    init(repositoryNode);
    JSONWizard hdfs=new JSONWizard(PlatformUI.getWorkbench(),creation,repositoryNode,getExistingNames());
    wizardDialog=new WizardDialog(Display.getCurrent().getActiveShell(),hdfs);
  }
 else {
    wizardDialog=new WizardDialog(Display.getCurrent().getActiveShell(),new JSONWizard(PlatformUI.getWorkbench(),creation,repositoryNode,getExistingNames()));
  }
  wizardDialog.setPageSize(WIZARD_WIDTH,WIZARD_HEIGHT);
  wizardDialog.create();
  wizardDialog.open();
}

Fixed version (ground truth):
@Override protected void doRun(){
  if (repositoryNode == null) {
    repositoryNode=getCurrentRepositoryNode();
  }
  if (isToolbar()) {
    if (repositoryNode != null && repositoryNode.getContentType() != JSONRepositoryNodeType.JSON) {
      repositoryNode=null;
    }
    if (repositoryNode == null) {
      repositoryNode=getRepositoryNodeForDefault(JSONRepositoryNodeType.JSON);
    }
  }
  WizardDialog wizardDialog=null;
  JSONWizard jsonWizard=null;
  try {
    if (isToolbar()) {
      init(repositoryNode);
      jsonWizard=new JSONWizard(PlatformUI.getWorkbench(),creation,repositoryNode,getExistingNames());
      wizardDialog=new WizardDialog(Display.getCurrent().getActiveShell(),jsonWizard);
    }
 else {
      jsonWizard=new JSONWizard(PlatformUI.getWorkbench(),creation,repositoryNode,getExistingNames());
      wizardDialog=new WizardDialog(Display.getCurrent().getActiveShell(),jsonWizard);
    }
    wizardDialog.setPageSize(WIZARD_WIDTH,WIZARD_HEIGHT);
    wizardDialog.create();
    wizardDialog.open();
  }
  finally {
    if (jsonWizard != null) {
      jsonWizard.deleteTemFile();
    }
  }
}
Program: 121153
Project: 121153
Buggy source:
public void focusGained(FocusEvent e){
}

Fixed version (ground truth):
@Override public void focusGained(FocusEvent e){
}
Program: 121154
Project: 121154
Buggy source:
public void widgetSelected(SelectionEvent event){
  if (fileFieldJSON.getResult() == null) {
    return;
  }
  String text=fileFieldJSON.getText();
  if (isContextMode()) {
    ContextType contextType=ConnectionContextHelper.getContextTypeForContextMode(connectionItem.getConnection(),true);
    text=TalendQuoteUtils.removeQuotes(ConnectionContextHelper.getOriginalValue(contextType,text));
  }
  File file=new File(text);
  if (file.exists()) {
    if (file.exists()) {
      String tempxml=JSONUtil.changeJsonToXml(text);
      JSONFileStep1Form.this.wizard.setTempJsonPath(tempxml);
      valid=treePopulator.populateTree(tempxml,treeNode);
    }
    checkFieldsValue();
  }
}

Fixed version (ground truth):
@Override public void widgetSelected(final SelectionEvent e){
  getShell().close();
}
Program: 121157
Project: 121157
Buggy source:
public void modifyText(final ModifyEvent e){
  getConnection().setEncoding(encodingCombo.getText());
  checkFieldsValue();
}

Fixed version (ground truth):
@Override public void modifyText(final ModifyEvent e){
  getConnection().setEncoding(encodingCombo.getText());
  checkFieldsValue();
}
Program: 121158
Project: 121158
Buggy source:
public void focusLost(FocusEvent e){
  commonNodesLimitation.setText(String.valueOf(TreePopulator.getLimit()));
}

Fixed version (ground truth):
@Override public void focusLost(FocusEvent e){
  commonNodesLimitation.setText(String.valueOf(TreePopulator.getLimit()));
}
Program: 121160
Project: 121160
Buggy source:
@Override protected void initCellEditor(){
  Connection connection=((ConnectionLabel)this.getEditPart().getModel()).getConnection();
  if (getCellEditor() instanceof NodeLabelCellEditor) {
    ((NodeLabelCellEditor)getCellEditor()).setCurrentConnection(connection);
  }
  Label label=(Label)(getEditPart()).getFigure();
  String initialLabelText=label.getText();
  getCellEditor().setValue(initialLabelText);
  text=(Text)getCellEditor().getControl();
  IFigure figure=(getEditPart()).getFigure();
  scaledFont=figure.getFont();
  FontData data=scaledFont.getFontData()[0];
  Dimension fontSize=new Dimension(0,data.getHeight());
  label.translateToAbsolute(fontSize);
  data.setHeight(fontSize.height);
  scaledFont=new Font(null,data);
  text.setFont(scaledFont);
  text.selectAll();
}

Fixed version (ground truth):
@Override protected void initCellEditor(){
  connection=((ConnectionLabel)this.getEditPart().getModel()).getConnection();
  if (getCellEditor() instanceof NodeLabelCellEditor) {
    ((NodeLabelCellEditor)getCellEditor()).setCurrentConnection(connection);
  }
  Label label=(Label)(getEditPart()).getFigure();
  String initialLabelText=label.getText();
  getCellEditor().setValue(initialLabelText);
  text=(Text)getCellEditor().getControl();
  IFigure figure=(getEditPart()).getFigure();
  scaledFont=figure.getFont();
  FontData data=scaledFont.getFontData()[0];
  Dimension fontSize=new Dimension(0,data.getHeight());
  label.translateToAbsolute(fontSize);
  data.setHeight(fontSize.height);
  scaledFont=new Font(null,data);
  text.setFont(scaledFont);
  text.selectAll();
}
Program: 121163
Project: 121163
Buggy source:
/** 
 * DOC Administrator Comment method "createLauncherFile".
 * @param process
 * @param list
 * @param cmdPrimary
 * @param cmdSecondary
 * @param tmpFold
 */
private void createLauncherFile(ProcessItem process,List<URL> list,String cmdPrimary,String fileName,String tmpFold){
  PrintWriter pw=null;
  try {
    File file=new File(tmpFold,process.getProperty().getLabel() + "String_Node_Str" + fileName);
    file.createNewFile();
    pw=new PrintWriter(new FileOutputStream(file));
    pw.print(cmdPrimary);
    pw.flush();
    list.add(file.toURL());
    pw.close();
  }
 catch (  Exception e) {
    ExceptionHandler.process(e);
  }
 finally {
    try {
      if (pw != null) {
        pw.close();
      }
    }
 catch (    Exception e) {
    }
  }
}

Fixed version (ground truth):
/** 
 * DOC Administrator Comment method "createLauncherFile".
 * @param process
 * @param list
 * @param cmdPrimary
 * @param cmdSecondary
 * @param tmpFold
 */
private void createLauncherFile(ProcessItem process,List<URL> list,String cmdPrimary,String fileName,String tmpFold){
  PrintWriter pw=null;
  try {
    if (cmdPrimary != null && UNIX_LAUNCHER.equals(fileName)) {
      StringBuffer strBuffer=new StringBuffer(cmdPrimary);
      strBuffer.insert(0,"String_Node_Str");
      cmdPrimary=strBuffer.toString();
    }
    File file=new File(tmpFold,process.getProperty().getLabel() + "String_Node_Str" + fileName);
    file.createNewFile();
    pw=new PrintWriter(new FileOutputStream(file));
    pw.print(cmdPrimary);
    pw.flush();
    list.add(file.toURL());
    pw.close();
  }
 catch (  Exception e) {
    ExceptionHandler.process(e);
  }
 finally {
    try {
      if (pw != null) {
        pw.close();
      }
    }
 catch (    Exception e) {
    }
  }
}
Program: 121165
Project: 121165
Buggy source:
@Override protected boolean calculateEnabled(){
  RepositoryNode rootNode=((ProjectRepositoryNode)ProjectRepositoryNode.getInstance()).getRootRepositoryNode(ERepositoryObjectType.METADATA);
  if (getSelectedObjects().isEmpty() || rootNode == null) {
    return false;
  }
 else {
    Object s=getSelectedObjects().get(0);
    if (s instanceof List && !((List)s).isEmpty()) {
      List selectedarts=(List)s;
      Object object=selectedarts.get(selectedarts.size() - 1);
      if (object instanceof TreeNodeEditPart) {
        TreeNodeEditPart parentPart=(TreeNodeEditPart)object;
        schemaNode=(TreeNode)parentPart.getModel();
        if (schemaNode.eContainer() instanceof AbstractInOutTree && XmlMapUtil.DOCUMENT.equals(schemaNode.getType())) {
          return true;
        }
      }
    }
  }
  return false;
}

Fixed version (ground truth):
@Override protected boolean calculateEnabled(){
  RepositoryNode rootNode=((ProjectRepositoryNode)ProjectRepositoryNode.getInstance()).getRootRepositoryNode(ERepositoryObjectType.METADATA);
  if (getSelectedObjects().isEmpty() || rootNode == null || rootNode.getChildren().size() == 0) {
    return false;
  }
 else {
    Object s=getSelectedObjects().get(0);
    if (s instanceof List && !((List)s).isEmpty()) {
      List selectedarts=(List)s;
      Object object=selectedarts.get(selectedarts.size() - 1);
      if (object instanceof TreeNodeEditPart) {
        TreeNodeEditPart parentPart=(TreeNodeEditPart)object;
        schemaNode=(TreeNode)parentPart.getModel();
        if (schemaNode.eContainer() instanceof AbstractInOutTree && XmlMapUtil.DOCUMENT.equals(schemaNode.getType())) {
          return true;
        }
      }
    }
  }
  return false;
}
Program: 121167
Project: 121167
Buggy source:
@Override public void run(){
  ComponentCompilations.deleteMarkers();
  ComponentsFactoryProvider.getInstance().resetCache();
  CorePlugin.getDefault().getLibrariesService().syncLibraries();
  CodeGeneratorEmittersPoolFactory.initialize();
  IDesignerCoreService designerCoreService=(IDesignerCoreService)GlobalServiceRegister.getDefault().getService(IDesignerCoreService.class);
  designerCoreService.getLastGeneratedJobsDateMap().clear();
}

Fixed version (ground truth):
@Override public void run(){
  IComponentSettingsView viewer=(IComponentSettingsView)PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().findView(IComponentSettingsView.ID);
  Element oldComponent=null;
  if (viewer != null) {
    oldComponent=viewer.getElement();
    viewer.cleanDisplay();
  }
  ComponentCompilations.deleteMarkers();
  ComponentsFactoryProvider.getInstance().resetCache();
  CorePlugin.getDefault().getLibrariesService().syncLibraries();
  CodeGeneratorEmittersPoolFactory.initialize();
  IDesignerCoreService designerCoreService=(IDesignerCoreService)GlobalServiceRegister.getDefault().getService(IDesignerCoreService.class);
  designerCoreService.getLastGeneratedJobsDateMap().clear();
  if (oldComponent != null) {
    viewer.setElement(oldComponent);
  }
}
Program: 121169
Project: 121169
Buggy source:
/** 
 * DOC Administrator Comment method "createLauncherFile".
 * @param process
 * @param list
 * @param cmdPrimary
 * @param cmdSecondary
 * @param tmpFold
 */
private void createLauncherFile(ProcessItem process,List<URL> list,String cmdPrimary,String fileName,String tmpFold){
  PrintWriter pw=null;
  try {
    File file=new File(tmpFold,process.getProperty().getLabel() + "String_Node_Str" + fileName);
    file.createNewFile();
    pw=new PrintWriter(new FileOutputStream(file));
    pw.print(cmdPrimary);
    pw.flush();
    list.add(file.toURL());
    pw.close();
  }
 catch (  Exception e) {
    ExceptionHandler.process(e);
  }
 finally {
    try {
      if (pw != null) {
        pw.close();
      }
    }
 catch (    Exception e) {
    }
  }
}

Fixed version (ground truth):
/** 
 * DOC Administrator Comment method "createLauncherFile".
 * @param process
 * @param list
 * @param cmdPrimary
 * @param cmdSecondary
 * @param tmpFold
 */
private void createLauncherFile(ProcessItem process,List<URL> list,String cmdPrimary,String fileName,String tmpFold){
  PrintWriter pw=null;
  try {
    if (cmdPrimary != null && UNIX_LAUNCHER.equals(fileName)) {
      StringBuffer strBuffer=new StringBuffer(cmdPrimary);
      strBuffer.insert(0,"String_Node_Str");
      cmdPrimary=strBuffer.toString();
    }
    File file=new File(tmpFold,process.getProperty().getLabel() + "String_Node_Str" + fileName);
    file.createNewFile();
    pw=new PrintWriter(new FileOutputStream(file));
    pw.print(cmdPrimary);
    pw.flush();
    list.add(file.toURL());
    pw.close();
  }
 catch (  Exception e) {
    ExceptionHandler.process(e);
  }
 finally {
    try {
      if (pw != null) {
        pw.close();
      }
    }
 catch (    Exception e) {
    }
  }
}
Program: 121170
Project: 121170
Buggy source:
private void judegeMultiIsSimple(){
  if (this.rootPath.indexOf("String_Node_Str") >= 0 || this.rootPath.indexOf("String_Node_Str") >= 0) {
    this.isSimpleParse=false;
  }
  for (int i=0; isSimpleParse && i < arrOrigLoopPath.length; i++) {
    if (arrOrigLoopPath[i].indexOf("String_Node_Str") >= 0 || arrOrigLoopPath[i].indexOf("String_Node_Str") >= 0) {
      this.isSimpleParse=false;
      break;
    }
  }
  for (int i=0; isSimpleParse && i < arrNodePaths.length; i++) {
    for (int j=0; j < arrNodePaths[i].length; j++) {
      if (arrNodePaths[i][j].indexOf("String_Node_Str") >= 0 || arrNodePaths[i][j].indexOf("String_Node_Str") >= 0) {
        this.isSimpleParse=false;
        break;
      }
    }
  }
  this.isSimpleParse=false;
  if (this.isSimpleParse) {
    looper=new SimpleSAXLooper(rootPath,arrOrigLoopPath,arrNodePaths);
  }
 else {
    looper=new ComplexSAXLooper(rootPath,arrOrigLoopPath,arrNodePaths);
  }
}

Fixed version (ground truth):
private void judegeMultiIsSimple(){
  isSimpleParse=isSimplePath(rootPath);
  for (  String path : arrOrigLoopPath) {
    if (!isSimpleParse) {
      break;
    }
    isSimpleParse=isSimplePath(path);
  }
  for (  String[] arrNodePath : arrNodePaths) {
    for (    String path : arrNodePath) {
      if (!isSimpleParse) {
        break;
      }
      isSimpleParse=isSimplePath(path);
    }
    if (!isSimpleParse) {
      break;
    }
  }
  if (this.isSimpleParse) {
    looper=new SimpleSAXLooper(rootPath,arrOrigLoopPath,arrNodePaths);
  }
 else {
    looper=new ComplexSAXLooper(rootPath,arrOrigLoopPath,arrNodePaths);
  }
}
Program: 121171
Project: 121171
Buggy source:
public void writeExcel(String fileName,boolean createDir) throws Exception {
  if (createDir) {
    File file=new File(fileName);
    File pFile=file.getParentFile();
    if (pFile != null && !pFile.exists()) {
      pFile.mkdirs();
    }
  }
  FileOutputStream fileOutput=new FileOutputStream(fileName);
  wb.write(fileOutput);
  fileOutput.close();
}

Fixed version (ground truth):
public void writeExcel(String fileName,boolean createDir) throws Exception {
  if (createDir) {
    File file=new File(fileName);
    File pFile=file.getParentFile();
    if (pFile != null && !pFile.exists()) {
      pFile.mkdirs();
    }
  }
  FileOutputStream fileOutput=new FileOutputStream(fileName);
  if (appendWorkbook && appendSheet) {
    evaluateFormulaCell();
  }
  wb.write(fileOutput);
  fileOutput.close();
}
Program: 121172
Project: 121172
Buggy source:
public void prepareXlsxFile(String fileName) throws Exception {
  File xlsxFile=new File(fileName);
  if (xlsxFile.exists()) {
    if (isAbsY && keepCellFormat) {
      initPreXlsx(fileName);
    }
    if (appendWorkbook) {
      InputStream inp=new FileInputStream(fileName);
      wb=WorkbookFactory.create(inp);
      sheet=wb.getSheet(sheetName);
      if (sheet != null) {
        if (appendSheet) {
          if (sheet.getLastRowNum() != 0 || sheet.getRow(0) != null) {
            curY=sheet.getLastRowNum() + 1;
          }
          ((XSSFSheet)sheet).setForceFormulaRecalculation(true);
        }
 else {
          wb.removeSheetAt(wb.getSheetIndex(sheetName));
          sheet=wb.createSheet(sheetName);
        }
      }
 else {
        sheet=wb.createSheet(sheetName);
      }
    }
 else {
      xlsxFile.delete();
      wb=new SXSSFWorkbook(rowAccessWindowSize);
      sheet=wb.createSheet(sheetName);
    }
  }
 else {
    wb=new SXSSFWorkbook(rowAccessWindowSize);
    sheet=wb.createSheet(sheetName);
  }
  if (isAbsY) {
    startX=absX;
    curY=absY;
  }
}

Fixed version (ground truth):
public void prepareXlsxFile(String fileName) throws Exception {
  File xlsxFile=new File(fileName);
  if (xlsxFile.exists()) {
    if (isAbsY && keepCellFormat) {
      initPreXlsx(fileName);
    }
    if (appendWorkbook) {
      InputStream inp=new FileInputStream(fileName);
      wb=WorkbookFactory.create(inp);
      sheet=wb.getSheet(sheetName);
      if (sheet != null) {
        if (appendSheet) {
          if (sheet.getLastRowNum() != 0 || sheet.getRow(0) != null) {
            curY=sheet.getLastRowNum() + 1;
          }
        }
 else {
          wb.removeSheetAt(wb.getSheetIndex(sheetName));
          sheet=wb.createSheet(sheetName);
        }
      }
 else {
        sheet=wb.createSheet(sheetName);
      }
    }
 else {
      xlsxFile.delete();
      wb=new SXSSFWorkbook(rowAccessWindowSize);
      sheet=wb.createSheet(sheetName);
    }
  }
 else {
    wb=new SXSSFWorkbook(rowAccessWindowSize);
    sheet=wb.createSheet(sheetName);
  }
  if (isAbsY) {
    startX=absX;
    curY=absY;
  }
}
Program: 121173
Project: 121173
Buggy source:
private void refreshNodes(){
  boolean isRed=new JobletUtil().isRed(this.jobletContainer);
  Project refProject=ProjectManager.getInstance().getProject(this.jobletContainer.getProcess().getProperty().getItem());
  if (!ProjectManager.getInstance().getCurrentProject().equals(refProject) && refProject.isReference()) {
    if (!this.jobletContainer.isCollapsed()) {
      isRed=true;
    }
  }
  if (lastJobletRedState == isRed) {
    return;
  }
  lastJobletRedState=isRed;
  if (isRed && rectFig != null) {
    rectFig.setBackgroundColor(new Color(Display.getDefault(),red));
  }
 else   if (rectFig != null) {
    rectFig.setBackgroundColor(new Color(Display.getDefault(),green));
  }
  if (isRed && outlineFigure != null) {
    outlineFigure.setBackgroundColor(new Color(Display.getDefault(),red));
  }
 else   if (outlineFigure != null) {
    outlineFigure.setBackgroundColor(new Color(Display.getDefault(),green));
  }
  if (!jobletContainer.isCollapsed()) {
    for (    Object ele : jobletContainer.getElements()) {
      if (ele instanceof Node) {
        ((Node)ele).setReadOnly(isRed);
      }
    }
  }
}

Fixed version (ground truth):
private void refreshNodes(){
  boolean isRed=new JobletUtil().isRed(this.jobletContainer);
  Project refProject=ProjectManager.getInstance().getProject(this.jobletContainer.getProcess().getProperty().getItem());
  if (!ProjectManager.getInstance().isInCurrentMainProject(refProject)) {
    if (!this.jobletContainer.isCollapsed()) {
      isRed=true;
    }
  }
  if (this.jobletContainer.isCollapsed() && lastJobletRedState == isRed) {
    return;
  }
  lastJobletRedState=isRed;
  if (isRed && rectFig != null) {
    rectFig.setBackgroundColor(new Color(Display.getDefault(),red));
  }
 else   if (rectFig != null) {
    rectFig.setBackgroundColor(new Color(Display.getDefault(),green));
  }
  if (isRed && outlineFigure != null) {
    outlineFigure.setBackgroundColor(new Color(Display.getDefault(),red));
  }
 else   if (outlineFigure != null) {
    outlineFigure.setBackgroundColor(new Color(Display.getDefault(),green));
  }
  if (!jobletContainer.isCollapsed()) {
    for (    Object ele : jobletContainer.getElements()) {
      if (ele instanceof Node) {
        ((Node)ele).setReadOnly(isRed);
      }
    }
  }
}
Program: 121175
Project: 121175
Buggy source:
/** 
 * Code Execution, used, when you know where the code stands.
 * @param Perl Absolute Code Path
 * @param Context Name
 * @param Port Statistics
 * @param Port Trace
 * @return Command Process Launched
 * @throws ProcessorException
 */
private Process exec(Level level,int statOption,int traceOption,String... codeOptions) throws ProcessorException {
  String[] cmd=getCommandLine(true,false,statOption,traceOption,codeOptions);
  logCommandLine(cmd,level);
  try {
    return Runtime.getRuntime().exec(filterCommand(cmd));
  }
 catch (  IOException ioe) {
    throw new ProcessorException(Messages.getString("String_Node_Str"),ioe);
  }
}

Fixed version (ground truth):
/** 
 * Code Execution, used, when you know where the code stands.
 * @param Perl Absolute Code Path
 * @param Context Name
 * @param Port Statistics
 * @param Port Trace
 * @return Command Process Launched
 * @throws ProcessorException
 */
private Process exec(Level level,int statOption,int traceOption,String... codeOptions) throws ProcessorException {
  String[] cmd=getCommandLine(true,false,statOption,traceOption,codeOptions);
  logCommandLine(cmd,level);
  try {
    return Runtime.getRuntime().exec(cmd);
  }
 catch (  IOException ioe) {
    throw new ProcessorException(Messages.getString("String_Node_Str"),ioe);
  }
}
Program: 121177
Project: 121177
Buggy source:
public void writeExcel(String fileName,boolean createDir) throws Exception {
  if (createDir) {
    File file=new File(fileName);
    File pFile=file.getParentFile();
    if (pFile != null && !pFile.exists()) {
      pFile.mkdirs();
    }
  }
  FileOutputStream fileOutput=new FileOutputStream(fileName);
  wb.write(fileOutput);
  fileOutput.close();
}

Fixed version (ground truth):
public void writeExcel(String fileName,boolean createDir) throws Exception {
  if (createDir) {
    File file=new File(fileName);
    File pFile=file.getParentFile();
    if (pFile != null && !pFile.exists()) {
      pFile.mkdirs();
    }
  }
  FileOutputStream fileOutput=new FileOutputStream(fileName);
  if (appendWorkbook && appendSheet) {
    evaluateFormulaCell();
  }
  wb.write(fileOutput);
  fileOutput.close();
}
Program: 121178
Project: 121178
Buggy source:
public void prepareXlsxFile(String fileName) throws Exception {
  File xlsxFile=new File(fileName);
  if (xlsxFile.exists()) {
    if (isAbsY && keepCellFormat) {
      initPreXlsx(fileName);
    }
    if (appendWorkbook) {
      InputStream inp=new FileInputStream(fileName);
      wb=WorkbookFactory.create(inp);
      sheet=wb.getSheet(sheetName);
      if (sheet != null) {
        if (appendSheet) {
          if (sheet.getLastRowNum() != 0 || sheet.getRow(0) != null) {
            curY=sheet.getLastRowNum() + 1;
          }
          ((XSSFSheet)sheet).setForceFormulaRecalculation(true);
        }
 else {
          wb.removeSheetAt(wb.getSheetIndex(sheetName));
          sheet=wb.createSheet(sheetName);
        }
      }
 else {
        sheet=wb.createSheet(sheetName);
      }
    }
 else {
      xlsxFile.delete();
      wb=new SXSSFWorkbook(rowAccessWindowSize);
      sheet=wb.createSheet(sheetName);
    }
  }
 else {
    wb=new SXSSFWorkbook(rowAccessWindowSize);
    sheet=wb.createSheet(sheetName);
  }
  if (isAbsY) {
    startX=absX;
    curY=absY;
  }
}

Fixed version (ground truth):
public void prepareXlsxFile(String fileName) throws Exception {
  File xlsxFile=new File(fileName);
  if (xlsxFile.exists()) {
    if (isAbsY && keepCellFormat) {
      initPreXlsx(fileName);
    }
    if (appendWorkbook) {
      InputStream inp=new FileInputStream(fileName);
      wb=WorkbookFactory.create(inp);
      sheet=wb.getSheet(sheetName);
      if (sheet != null) {
        if (appendSheet) {
          if (sheet.getLastRowNum() != 0 || sheet.getRow(0) != null) {
            curY=sheet.getLastRowNum() + 1;
          }
        }
 else {
          wb.removeSheetAt(wb.getSheetIndex(sheetName));
          sheet=wb.createSheet(sheetName);
        }
      }
 else {
        sheet=wb.createSheet(sheetName);
      }
    }
 else {
      xlsxFile.delete();
      wb=new SXSSFWorkbook(rowAccessWindowSize);
      sheet=wb.createSheet(sheetName);
    }
  }
 else {
    wb=new SXSSFWorkbook(rowAccessWindowSize);
    sheet=wb.createSheet(sheetName);
  }
  if (isAbsY) {
    startX=absX;
    curY=absY;
  }
}
Program: 121180
Project: 121180
Buggy source:
public Client(String endpoint,String secretKey,String clientAccessID) throws ServiceException, MalformedURLException {
  MktMktowsApiService service=new MktMktowsApiServiceLocator();
  URL portAddress=new URL(endpoint);
  stub=service.getMktowsApiSoapPort(portAddress);
  stub.setSecretKey(secretKey);
  stub.setClientAccessID(clientAccessID);
}

Fixed version (ground truth):
public Client(String endpoint,String secretKey,String clientAccessID) throws ServiceException, MalformedURLException {
  MktMktowsApiService service=new MktMktowsApiServiceLocator();
  ((MktMktowsApiServiceLocator)service).setMktowsApiSoapPortEndpointAddress(endpoint);
  URL portAddress=new URL(endpoint);
  stub=service.getMktowsApiSoapPort(portAddress);
  stub.setSecretKey(secretKey);
  stub.setClientAccessID(clientAccessID);
}
Program: 121183
Project: 121183
Buggy source:
protected Process execFrom(String path,Level level,int statOption,int traceOption,String... codeOptions) throws ProcessorException {
  String[] cmd=getCommandLine(true,false,statOption,traceOption,codeOptions);
  logCommandLine(cmd,level);
  try {
    return Runtime.getRuntime().exec(filterCommand(cmd),null,new File(path));
  }
 catch (  IOException ioe) {
    throw new ProcessorException(Messages.getString("String_Node_Str"),ioe);
  }
}

Fixed version (ground truth):
protected Process execFrom(String path,Level level,int statOption,int traceOption,String... codeOptions) throws ProcessorException {
  String[] cmd=getCommandLine(true,false,statOption,traceOption,codeOptions);
  logCommandLine(cmd,level);
  try {
    return Runtime.getRuntime().exec(cmd,null,new File(path));
  }
 catch (  IOException ioe) {
    throw new ProcessorException(Messages.getString("String_Node_Str"),ioe);
  }
}
Program: 121184
Project: 121184
Buggy source:
/** 
 * Code Execution, used, when you know where the code stands.
 * @param Perl Absolute Code Path
 * @param Context Name
 * @param Port Statistics
 * @param Port Trace
 * @return Command Process Launched
 * @throws ProcessorException
 */
protected Process exec(Level level,int statOption,int traceOption,String... codeOptions) throws ProcessorException {
  String[] cmd=getCommandLine(true,false,statOption,traceOption,codeOptions);
  logCommandLine(cmd,level);
  try {
    return Runtime.getRuntime().exec(filterCommand(cmd));
  }
 catch (  IOException ioe) {
    throw new ProcessorException(Messages.getString("String_Node_Str"),ioe);
  }
}

Fixed version (ground truth):
/** 
 * Code Execution, used, when you know where the code stands.
 * @param Perl Absolute Code Path
 * @param Context Name
 * @param Port Statistics
 * @param Port Trace
 * @return Command Process Launched
 * @throws ProcessorException
 */
protected Process exec(Level level,int statOption,int traceOption,String... codeOptions) throws ProcessorException {
  String[] cmd=getCommandLine(true,false,statOption,traceOption,codeOptions);
  logCommandLine(cmd,level);
  try {
    return Runtime.getRuntime().exec(cmd);
  }
 catch (  IOException ioe) {
    throw new ProcessorException(Messages.getString("String_Node_Str"),ioe);
  }
}
Program: 121186
Project: 121186
Buggy source:
@Override public boolean performFinish(){
  boolean finish=mainPage.finish();
  if (!finish && !getShell().isDisposed()) {
  }
 else {
    selection=null;
    mainPage=null;
  }
  return finish;
}

Fixed version (ground truth):
@Override public boolean performFinish(){
  boolean finish=mainPage.finish();
  if (finish) {
    selection=null;
    mainPage=null;
  }
  return finish;
}
Program: 121187
Project: 121187
Buggy source:
public void writeExcel(String fileName,boolean createDir) throws Exception {
  if (createDir) {
    File file=new File(fileName);
    File pFile=file.getParentFile();
    if (pFile != null && !pFile.exists()) {
      pFile.mkdirs();
    }
  }
  FileOutputStream fileOutput=new FileOutputStream(fileName);
  wb.write(fileOutput);
  fileOutput.close();
}

Fixed version (ground truth):
public void writeExcel(String fileName,boolean createDir) throws Exception {
  if (createDir) {
    File file=new File(fileName);
    File pFile=file.getParentFile();
    if (pFile != null && !pFile.exists()) {
      pFile.mkdirs();
    }
  }
  FileOutputStream fileOutput=new FileOutputStream(fileName);
  if (appendWorkbook && appendSheet) {
    evaluateFormulaCell();
  }
  wb.write(fileOutput);
  fileOutput.close();
}
Program: 121188
Project: 121188
Buggy source:
public void prepareXlsxFile(String fileName) throws Exception {
  File xlsxFile=new File(fileName);
  if (xlsxFile.exists()) {
    if (isAbsY && keepCellFormat) {
      initPreXlsx(fileName);
    }
    if (appendWorkbook) {
      InputStream inp=new FileInputStream(fileName);
      wb=WorkbookFactory.create(inp);
      sheet=wb.getSheet(sheetName);
      if (sheet != null) {
        if (appendSheet) {
          if (sheet.getLastRowNum() != 0 || sheet.getRow(0) != null) {
            curY=sheet.getLastRowNum() + 1;
          }
          ((XSSFSheet)sheet).setForceFormulaRecalculation(true);
        }
 else {
          wb.removeSheetAt(wb.getSheetIndex(sheetName));
          sheet=wb.createSheet(sheetName);
        }
      }
 else {
        sheet=wb.createSheet(sheetName);
      }
    }
 else {
      xlsxFile.delete();
      wb=new SXSSFWorkbook(rowAccessWindowSize);
      sheet=wb.createSheet(sheetName);
    }
  }
 else {
    wb=new SXSSFWorkbook(rowAccessWindowSize);
    sheet=wb.createSheet(sheetName);
  }
  if (isAbsY) {
    startX=absX;
    curY=absY;
  }
}

Fixed version (ground truth):
public void prepareXlsxFile(String fileName) throws Exception {
  File xlsxFile=new File(fileName);
  if (xlsxFile.exists()) {
    if (isAbsY && keepCellFormat) {
      initPreXlsx(fileName);
    }
    if (appendWorkbook) {
      InputStream inp=new FileInputStream(fileName);
      wb=WorkbookFactory.create(inp);
      sheet=wb.getSheet(sheetName);
      if (sheet != null) {
        if (appendSheet) {
          if (sheet.getLastRowNum() != 0 || sheet.getRow(0) != null) {
            curY=sheet.getLastRowNum() + 1;
          }
        }
 else {
          wb.removeSheetAt(wb.getSheetIndex(sheetName));
          sheet=wb.createSheet(sheetName);
        }
      }
 else {
        sheet=wb.createSheet(sheetName);
      }
    }
 else {
      xlsxFile.delete();
      wb=new SXSSFWorkbook(rowAccessWindowSize);
      sheet=wb.createSheet(sheetName);
    }
  }
 else {
    wb=new SXSSFWorkbook(rowAccessWindowSize);
    sheet=wb.createSheet(sheetName);
  }
  if (isAbsY) {
    startX=absX;
    curY=absY;
  }
}
Program: 121189
Project: 121189
Buggy source:
protected Process execFrom(String path,Level level,int statOption,int traceOption,String... codeOptions) throws ProcessorException {
  String[] cmd=getCommandLine(true,false,statOption,traceOption,codeOptions);
  logCommandLine(cmd,level);
  try {
    return Runtime.getRuntime().exec(cmd,null,new File(path));
  }
 catch (  IOException ioe) {
    throw new ProcessorException(Messages.getString("String_Node_Str"),ioe);
  }
}

Fixed version (ground truth):
protected Process execFrom(String path,Level level,int statOption,int traceOption,String... codeOptions) throws ProcessorException {
  String[] cmd=getCommandLine(true,false,statOption,traceOption,codeOptions);
  logCommandLine(cmd,level);
  try {
    return Runtime.getRuntime().exec(filterCommand(cmd),null,new File(path));
  }
 catch (  IOException ioe) {
    throw new ProcessorException(Messages.getString("String_Node_Str"),ioe);
  }
}
Program: 121190
Project: 121190
Buggy source:
/** 
 * Code Execution, used, when you know where the code stands.
 * @param Perl Absolute Code Path
 * @param Context Name
 * @param Port Statistics
 * @param Port Trace
 * @return Command Process Launched
 * @throws ProcessorException
 */
protected Process exec(Level level,int statOption,int traceOption,String... codeOptions) throws ProcessorException {
  String[] cmd=getCommandLine(true,false,statOption,traceOption,codeOptions);
  logCommandLine(cmd,level);
  try {
    return Runtime.getRuntime().exec(cmd);
  }
 catch (  IOException ioe) {
    throw new ProcessorException(Messages.getString("String_Node_Str"),ioe);
  }
}

Fixed version (ground truth):
/** 
 * Code Execution, used, when you know where the code stands.
 * @param Perl Absolute Code Path
 * @param Context Name
 * @param Port Statistics
 * @param Port Trace
 * @return Command Process Launched
 * @throws ProcessorException
 */
protected Process exec(Level level,int statOption,int traceOption,String... codeOptions) throws ProcessorException {
  String[] cmd=getCommandLine(true,false,statOption,traceOption,codeOptions);
  logCommandLine(cmd,level);
  try {
    return Runtime.getRuntime().exec(filterCommand(cmd));
  }
 catch (  IOException ioe) {
    throw new ProcessorException(Messages.getString("String_Node_Str"),ioe);
  }
}
Program: 121191
Project: 121191
Buggy source:
@Override public boolean performFinish(){
  boolean finish=mainPage.finish();
  if (!finish && !getShell().isDisposed()) {
  }
 else {
    selection=null;
    mainPage=null;
  }
  return finish;
}

Fixed version (ground truth):
@Override public boolean performFinish(){
  boolean finish=mainPage.finish();
  if (finish) {
    selection=null;
    mainPage=null;
  }
  return finish;
}
Program: 121192
Project: 121192
Buggy source:
/** 
 * Code Execution, used, when you know where the code stands.
 * @param Perl Absolute Code Path
 * @param Context Name
 * @param Port Statistics
 * @param Port Trace
 * @return Command Process Launched
 * @throws ProcessorException
 */
private Process exec(Level level,int statOption,int traceOption,String... codeOptions) throws ProcessorException {
  String[] cmd=getCommandLine(true,false,statOption,traceOption,codeOptions);
  logCommandLine(cmd,level);
  try {
    return Runtime.getRuntime().exec(cmd);
  }
 catch (  IOException ioe) {
    throw new ProcessorException(Messages.getString("String_Node_Str"),ioe);
  }
}

Fixed version (ground truth):
/** 
 * Code Execution, used, when you know where the code stands.
 * @param Perl Absolute Code Path
 * @param Context Name
 * @param Port Statistics
 * @param Port Trace
 * @return Command Process Launched
 * @throws ProcessorException
 */
private Process exec(Level level,int statOption,int traceOption,String... codeOptions) throws ProcessorException {
  String[] cmd=getCommandLine(true,false,statOption,traceOption,codeOptions);
  logCommandLine(cmd,level);
  try {
    return Runtime.getRuntime().exec(filterCommand(cmd));
  }
 catch (  IOException ioe) {
    throw new ProcessorException(Messages.getString("String_Node_Str"),ioe);
  }
}
Program: 121196
Project: 121196
Buggy source:
@Override public boolean performFinish(){
  boolean finish=mainPage.finish();
  if (!finish && !getShell().isDisposed()) {
    getShell().close();
  }
 else {
    selection=null;
    mainPage=null;
  }
  return finish;
}

Fixed version (ground truth):
@Override public boolean performFinish(){
  boolean finish=mainPage.finish();
  if (!finish && !getShell().isDisposed()) {
  }
 else {
    selection=null;
    mainPage=null;
  }
  return finish;
}
Program: 121197
Project: 121197
Buggy source:
/** 
 * Returns a boolean indicating whether the passed File handle is is valid and available for use.
 */
protected boolean ensureTargetFileIsValid(File targetFile){
  if (targetFile.exists() && targetFile.isDirectory()) {
    displayErrorDialog(DataTransferMessages.ZipExport_mustBeFile);
    giveFocusToDestination();
    return false;
  }
  if (targetFile.exists()) {
    if (targetFile.canWrite()) {
      if (!queryYesNoQuestion(DataTransferMessages.ZipExport_alreadyExists)) {
        displayErrorDialog("String_Node_Str");
        giveFocusToDestination();
        return false;
      }
    }
 else {
      displayErrorDialog(DataTransferMessages.ZipExport_alreadyExistsError);
      giveFocusToDestination();
      return false;
    }
  }
  return true;
}

Fixed version (ground truth):
/** 
 * Returns a boolean indicating whether the passed File handle is is valid and available for use.
 */
protected boolean ensureTargetFileIsValid(File targetFile){
  if (targetFile.exists() && targetFile.isDirectory()) {
    displayErrorDialog(DataTransferMessages.ZipExport_mustBeFile);
    giveFocusToDestination();
    return false;
  }
  if (targetFile.exists()) {
    if (targetFile.canWrite()) {
      if (!queryYesNoQuestion(DataTransferMessages.ZipExport_alreadyExists)) {
        giveFocusToDestination();
        return false;
      }
    }
 else {
      displayErrorDialog(DataTransferMessages.ZipExport_alreadyExistsError);
      giveFocusToDestination();
      return false;
    }
  }
  return true;
}
Program: 121198
Project: 121198
Buggy source:
public ILaunch getLaunch(ILaunchConfiguration configuration,String mode) throws CoreException {
  return null;
}

Fixed version (ground truth):
@Override public ILaunch getLaunch(ILaunchConfiguration configuration,String mode) throws CoreException {
  return null;
}
Program: 121199
Project: 121199
Buggy source:
public void launch(ILaunchConfiguration configuration,String mode,ILaunch launch,IProgressMonitor monitor) throws CoreException {
  String jobId=configuration.getAttribute(TalendDebugUIConstants.JOB_ID,(String)null);
  String jobName=configuration.getAttribute(TalendDebugUIConstants.JOB_NAME,(String)null);
  String jobVersion=configuration.getAttribute(TalendDebugUIConstants.JOB_VERSION,(String)null);
  IProcess2 process=DesignerUtilities.findProcessFromEditors(jobId,jobVersion);
  if (process == null) {
    process=findProcessFromRepository(jobId,jobVersion);
  }
  if (process == null) {
    ExceptionHandler.log(Messages.getString("String_Node_Str",jobName));
    return;
  }
  final IProcess2 p=process;
  Display.getDefault().asyncExec(new Runnable(){
    public void run(){
      IRunProcessService service=DesignerPlugin.getDefault().getRunProcessService();
      service.setActiveProcess(p);
      service.getRunProcessAction().run();
    }
  }
);
}

Fixed version (ground truth):
@Override public void launch(ILaunchConfiguration configuration,String mode,ILaunch launch,IProgressMonitor monitor) throws CoreException {
  String jobId=configuration.getAttribute(TalendDebugUIConstants.JOB_ID,(String)null);
  String jobName=configuration.getAttribute(TalendDebugUIConstants.JOB_NAME,(String)null);
  String jobVersion=configuration.getAttribute(TalendDebugUIConstants.JOB_VERSION,(String)null);
  IProcess2 process=DesignerUtilities.findProcessFromEditors(jobId,jobVersion);
  if (process == null) {
    process=findProcessFromRepository(jobId,jobVersion);
  }
  if (process == null) {
    ExceptionHandler.log(Messages.getString("String_Node_Str",jobName));
    return;
  }
  final IProcess2 p=process;
  Display.getDefault().asyncExec(new Runnable(){
    @Override public void run(){
      IRunProcessService service=DesignerPlugin.getDefault().getRunProcessService();
      service.setActiveProcess(p);
      service.refreshView();
      service.getRunProcessAction().run();
    }
  }
);
}
Program: 121200
Project: 121200
Buggy source:
public void run(){
  IRunProcessService service=DesignerPlugin.getDefault().getRunProcessService();
  service.setActiveProcess(p);
  service.getRunProcessAction().run();
}

Fixed version (ground truth):
@Override public void run(){
  IRunProcessService service=DesignerPlugin.getDefault().getRunProcessService();
  service.setActiveProcess(p);
  service.refreshView();
  service.getRunProcessAction().run();
}
Program: 121201
Project: 121201
Buggy source:
/** 
 * DOC bqian Comment method "findProcessFromRepository".
 * @param jobName
 * @return
 */
private IProcess2 findProcessFromRepository(String jobId,String version){
  try {
    ItemCacheManager.clearCache();
    ProcessItem processItem=ItemCacheManager.getProcessItem(jobId,version);
    if (processItem != null) {
      ProcessEditorInput fileEditorInput=new ProcessEditorInput((ProcessItem)processItem,true,true,true);
      IProcess2 process=fileEditorInput.getLoadedProcess();
      return process;
    }
  }
 catch (  Exception e) {
    ExceptionHandler.process(e);
  }
  return null;
}

Fixed version (ground truth):
/** 
 * DOC bqian Comment method "findProcessFromRepository".
 * @param jobName
 * @return
 */
private IProcess2 findProcessFromRepository(String jobId,String version){
  try {
    ItemCacheManager.clearCache();
    ProcessItem processItem=ItemCacheManager.getProcessItem(jobId,version);
    if (processItem != null) {
      if (GlobalServiceRegister.getDefault().isServiceRegistered(IDesignerCoreService.class)) {
        IDesignerCoreService service=(IDesignerCoreService)GlobalServiceRegister.getDefault().getService(IDesignerCoreService.class);
        IProcess process=service.getProcessFromItem(processItem);
        if (process instanceof IProcess2) {
          return (IProcess2)process;
        }
      }
      ProcessEditorInput fileEditorInput=new ProcessEditorInput(processItem,true,true,true);
      IProcess2 process=fileEditorInput.getLoadedProcess();
      return process;
    }
  }
 catch (  Exception e) {
    ExceptionHandler.process(e);
  }
  return null;
}
Program: 121204
Project: 121204
Buggy source:
@Override public boolean performFinish(){
  boolean finish=mainPage.finish();
  if (!finish && !getShell().isDisposed()) {
    getShell().close();
  }
 else {
    selection=null;
    mainPage=null;
  }
  return finish;
}

Fixed version (ground truth):
@Override public boolean performFinish(){
  boolean finish=mainPage.finish();
  if (!finish && !getShell().isDisposed()) {
  }
 else {
    selection=null;
    mainPage=null;
  }
  return finish;
}
Program: 121205
Project: 121205
Buggy source:
/** 
 * Returns a boolean indicating whether the passed File handle is is valid and available for use.
 */
protected boolean ensureTargetFileIsValid(File targetFile){
  if (targetFile.exists() && targetFile.isDirectory()) {
    displayErrorDialog(DataTransferMessages.ZipExport_mustBeFile);
    giveFocusToDestination();
    return false;
  }
  if (targetFile.exists()) {
    if (targetFile.canWrite()) {
      if (!queryYesNoQuestion(DataTransferMessages.ZipExport_alreadyExists)) {
        displayErrorDialog("String_Node_Str");
        giveFocusToDestination();
        return false;
      }
    }
 else {
      displayErrorDialog(DataTransferMessages.ZipExport_alreadyExistsError);
      giveFocusToDestination();
      return false;
    }
  }
  return true;
}

Fixed version (ground truth):
/** 
 * Returns a boolean indicating whether the passed File handle is is valid and available for use.
 */
protected boolean ensureTargetFileIsValid(File targetFile){
  if (targetFile.exists() && targetFile.isDirectory()) {
    displayErrorDialog(DataTransferMessages.ZipExport_mustBeFile);
    giveFocusToDestination();
    return false;
  }
  if (targetFile.exists()) {
    if (targetFile.canWrite()) {
      if (!queryYesNoQuestion(DataTransferMessages.ZipExport_alreadyExists)) {
        giveFocusToDestination();
        return false;
      }
    }
 else {
      displayErrorDialog(DataTransferMessages.ZipExport_alreadyExistsError);
      giveFocusToDestination();
      return false;
    }
  }
  return true;
}
Program: 121206
Project: 121206
Buggy source:
public void prepareXlsxFile(String fileName) throws Exception {
  File xlsxFile=new File(fileName);
  if (xlsxFile.exists()) {
    if (isAbsY && keepCellFormat) {
      initPreXlsx(fileName);
    }
    if (appendWorkbook) {
      InputStream inp=new FileInputStream(fileName);
      wb=WorkbookFactory.create(inp);
      sheet=wb.getSheet(sheetName);
      if (sheet != null) {
        if (appendSheet) {
          if (sheet.getLastRowNum() != 0 || sheet.getRow(0) != null) {
            curY=sheet.getLastRowNum() + 1;
          }
        }
 else {
          wb.removeSheetAt(wb.getSheetIndex(sheetName));
          sheet=wb.createSheet(sheetName);
        }
      }
 else {
        sheet=wb.createSheet(sheetName);
      }
    }
 else {
      xlsxFile.delete();
      wb=new SXSSFWorkbook(rowAccessWindowSize);
      sheet=wb.createSheet(sheetName);
    }
  }
 else {
    wb=new SXSSFWorkbook(rowAccessWindowSize);
    sheet=wb.createSheet(sheetName);
  }
  if (isAbsY) {
    startX=absX;
    curY=absY;
  }
}

Fixed version (ground truth):
public void prepareXlsxFile(String fileName) throws Exception {
  File xlsxFile=new File(fileName);
  if (xlsxFile.exists()) {
    if (isAbsY && keepCellFormat) {
      initPreXlsx(fileName);
    }
    if (appendWorkbook) {
      InputStream inp=new FileInputStream(fileName);
      wb=WorkbookFactory.create(inp);
      sheet=wb.getSheet(sheetName);
      if (sheet != null) {
        if (appendSheet) {
          if (sheet.getLastRowNum() != 0 || sheet.getRow(0) != null) {
            curY=sheet.getLastRowNum() + 1;
          }
          ((XSSFSheet)sheet).setForceFormulaRecalculation(true);
        }
 else {
          wb.removeSheetAt(wb.getSheetIndex(sheetName));
          sheet=wb.createSheet(sheetName);
        }
      }
 else {
        sheet=wb.createSheet(sheetName);
      }
    }
 else {
      xlsxFile.delete();
      wb=new SXSSFWorkbook(rowAccessWindowSize);
      sheet=wb.createSheet(sheetName);
    }
  }
 else {
    wb=new SXSSFWorkbook(rowAccessWindowSize);
    sheet=wb.createSheet(sheetName);
  }
  if (isAbsY) {
    startX=absX;
    curY=absY;
  }
}