nus-yam/ex-repair huggingface dataset:
Program: 128708
Project: 128708
Buggy source:
private void lockObject(){
  if (GlobalServiceRegister.getDefault().isServiceRegistered(IProxyRepositoryService.class)) {
    IProxyRepositoryService service=(IProxyRepositoryService)GlobalServiceRegister.getDefault().getService(IProxyRepositoryService.class);
    IProxyRepositoryFactory repositoryFactory=service.getProxyRepositoryFactory();
    try {
      boolean isOpened=false;
      if (GlobalServiceRegister.getDefault().isServiceRegistered(ICoreService.class)) {
        ICoreService coreService=(ICoreService)GlobalServiceRegister.getDefault().getService(ICoreService.class);
        isOpened=coreService.isOpenedItemInEditor(object);
      }
      if (repositoryFactory.getStatus(object).equals(ERepositoryStatus.LOCK_BY_USER)) {
        isLock=true;
      }
      if (repositoryFactory.getStatus(object).equals(ERepositoryStatus.LOCK_BY_USER) && isOpened) {
        alreadyEditedByUser=true;
      }
 else {
        repositoryFactory.lock(object);
      }
    }
 catch (    PersistenceException e) {
      ExceptionHandler.process(e);
    }
catch (    BusinessException e) {
    }
  }
}

Fixed version (ground truth):
private void lockObject(){
  if (GlobalServiceRegister.getDefault().isServiceRegistered(IProxyRepositoryService.class)) {
    IProxyRepositoryService service=(IProxyRepositoryService)GlobalServiceRegister.getDefault().getService(IProxyRepositoryService.class);
    IProxyRepositoryFactory repositoryFactory=service.getProxyRepositoryFactory();
    try {
      boolean isOpened=false;
      if (GlobalServiceRegister.getDefault().isServiceRegistered(ICoreService.class)) {
        ICoreService coreService=(ICoreService)GlobalServiceRegister.getDefault().getService(ICoreService.class);
        isOpened=coreService.isOpenedItemInEditor(object);
      }
      if (repositoryFactory.getStatus(object).equals(ERepositoryStatus.LOCK_BY_USER) && isOpened) {
        alreadyEditedByUser=true;
      }
 else {
        repositoryFactory.lock(object);
      }
    }
 catch (    PersistenceException e) {
      ExceptionHandler.process(e);
    }
catch (    BusinessException e) {
    }
  }
}
Program: 128709
Project: 128709
Buggy source:
@Override public void addPages(){
  mainPage=new PropertiesWizardPage("String_Node_Str",object.getProperty(),path,isReadOnly(),false,lastVersionFound){
    @Override public void createControl(    Composite parent){
      Composite container=new Composite(parent,SWT.NONE);
      GridLayout layout=new GridLayout(2,false);
      container.setLayout(layout);
      if (alreadyEditedByUser && isLock) {
        Label label=new Label(container,SWT.NONE);
        label.setForeground(ColorConstants.red);
        label.setText(Messages.getString("String_Node_Str"));
        GridData gridData=new GridData();
        gridData.horizontalSpan=2;
        label.setLayoutData(gridData);
      }
      super.createControl(container);
      setControl(container);
      updateContent();
      addListeners();
      setPageComplete(false);
    }
    @Override protected void evaluateTextField(){
      super.evaluateTextField();
      if (nameStatus.getSeverity() == IStatus.OK) {
        ERepositoryObjectType type=getRepositoryObjectType();
        if (type == ERepositoryObjectType.PROCESS) {
          evaluateNameInRoutine();
        }
 else         if (type == ERepositoryObjectType.ROUTINES || type == ERepositoryObjectType.METADATA_FILE_RULES) {
          evaluateNameInJob();
        }
      }
    }
    @Override public ERepositoryObjectType getRepositoryObjectType(){
      return object.getRepositoryObjectType();
    }
  }
;
  addPage(mainPage);
  setWindowTitle(Messages.getString("String_Node_Str"));
}

Fixed version (ground truth):
@Override public void addPages(){
  mainPage=new PropertiesWizardPage("String_Node_Str",object.getProperty(),path,isReadOnly(),false,lastVersionFound){
    @Override public void createControl(    Composite parent){
      Composite container=new Composite(parent,SWT.NONE);
      GridLayout layout=new GridLayout(2,false);
      container.setLayout(layout);
      if (alreadyEditedByUser) {
        Label label=new Label(container,SWT.NONE);
        label.setForeground(ColorConstants.red);
        label.setText(Messages.getString("String_Node_Str"));
        GridData gridData=new GridData();
        gridData.horizontalSpan=2;
        label.setLayoutData(gridData);
      }
      super.createControl(container);
      setControl(container);
      updateContent();
      addListeners();
      setPageComplete(false);
    }
    @Override protected void evaluateTextField(){
      super.evaluateTextField();
      if (nameStatus.getSeverity() == IStatus.OK) {
        ERepositoryObjectType type=getRepositoryObjectType();
        if (type == ERepositoryObjectType.PROCESS) {
          evaluateNameInRoutine();
        }
 else         if (type == ERepositoryObjectType.ROUTINES || type == ERepositoryObjectType.METADATA_FILE_RULES) {
          evaluateNameInJob();
        }
      }
    }
    @Override public ERepositoryObjectType getRepositoryObjectType(){
      return object.getRepositoryObjectType();
    }
  }
;
  addPage(mainPage);
  setWindowTitle(Messages.getString("String_Node_Str"));
}
Program: 128710
Project: 128710
Buggy source:
@Override public void dispose(){
  if (!isLock) {
    unlockObject();
  }
  super.dispose();
}

Fixed version (ground truth):
@Override public void dispose(){
  unlockObject();
  super.dispose();
}
Program: 128711
Project: 128711
Buggy source:
@Override public void createControl(Composite parent){
  Composite container=new Composite(parent,SWT.NONE);
  GridLayout layout=new GridLayout(2,false);
  container.setLayout(layout);
  if (alreadyEditedByUser && isLock) {
    Label label=new Label(container,SWT.NONE);
    label.setForeground(ColorConstants.red);
    label.setText(Messages.getString("String_Node_Str"));
    GridData gridData=new GridData();
    gridData.horizontalSpan=2;
    label.setLayoutData(gridData);
  }
  super.createControl(container);
  setControl(container);
  updateContent();
  addListeners();
  setPageComplete(false);
}

Fixed version (ground truth):
@Override public void createControl(Composite parent){
  Composite container=new Composite(parent,SWT.NONE);
  GridLayout layout=new GridLayout(2,false);
  container.setLayout(layout);
  if (alreadyEditedByUser) {
    Label label=new Label(container,SWT.NONE);
    label.setForeground(ColorConstants.red);
    label.setText(Messages.getString("String_Node_Str"));
    GridData gridData=new GridData();
    gridData.horizontalSpan=2;
    label.setLayoutData(gridData);
  }
  super.createControl(container);
  setControl(container);
  updateContent();
  addListeners();
  setPageComplete(false);
}
Program: 128712
Project: 128712
Buggy source:
@Override public boolean performFinish(){
  if (alreadyEditedByUser || isLock) {
    return false;
  }
  IWorkspaceRunnable runnable=new IWorkspaceRunnable(){
    public void run(    final IProgressMonitor monitor) throws CoreException {
      try {
        IProxyRepositoryFactory proxyRepositoryFactory=CoreRuntimePlugin.getInstance().getProxyRepositoryFactory();
        object.getProperty().setLabel(object.getProperty().getDisplayName());
        proxyRepositoryFactory.save(object.getProperty(),originaleObjectLabel,originalVersion);
        ExpressionPersistance.getInstance().jobNameChanged(originaleObjectLabel,object.getLabel());
        proxyRepositoryFactory.saveProject(ProjectManager.getInstance().getCurrentProject());
        if (GlobalServiceRegister.getDefault().isServiceRegistered(IESBService.class)) {
          IESBService service=(IESBService)GlobalServiceRegister.getDefault().getService(IESBService.class);
          service.editJobName(originaleObjectLabel,object.getLabel());
        }
      }
 catch (      PersistenceException pe) {
        throw new CoreException(new Status(IStatus.ERROR,FrameworkUtil.getBundle(this.getClass()).getSymbolicName(),"String_Node_Str",pe));
      }
    }
  }
;
  IWorkspace workspace=ResourcesPlugin.getWorkspace();
  try {
    ISchedulingRule schedulingRule=workspace.getRoot();
    workspace.run(runnable,schedulingRule,IWorkspace.AVOID_UPDATE,null);
    return true;
  }
 catch (  CoreException e) {
    MessageBoxExceptionHandler.process(e.getCause());
    return false;
  }
}

Fixed version (ground truth):
@Override public boolean performFinish(){
  if (alreadyEditedByUser) {
    return false;
  }
  IWorkspaceRunnable runnable=new IWorkspaceRunnable(){
    public void run(    final IProgressMonitor monitor) throws CoreException {
      try {
        IProxyRepositoryFactory proxyRepositoryFactory=CoreRuntimePlugin.getInstance().getProxyRepositoryFactory();
        object.getProperty().setLabel(object.getProperty().getDisplayName());
        proxyRepositoryFactory.save(object.getProperty(),originaleObjectLabel,originalVersion);
        ExpressionPersistance.getInstance().jobNameChanged(originaleObjectLabel,object.getLabel());
        proxyRepositoryFactory.saveProject(ProjectManager.getInstance().getCurrentProject());
        if (GlobalServiceRegister.getDefault().isServiceRegistered(IESBService.class)) {
          IESBService service=(IESBService)GlobalServiceRegister.getDefault().getService(IESBService.class);
          service.editJobName(originaleObjectLabel,object.getLabel());
        }
      }
 catch (      PersistenceException pe) {
        throw new CoreException(new Status(IStatus.ERROR,FrameworkUtil.getBundle(this.getClass()).getSymbolicName(),"String_Node_Str",pe));
      }
    }
  }
;
  IWorkspace workspace=ResourcesPlugin.getWorkspace();
  try {
    ISchedulingRule schedulingRule=workspace.getRoot();
    workspace.run(runnable,schedulingRule,IWorkspace.AVOID_UPDATE,null);
    return true;
  }
 catch (  CoreException e) {
    MessageBoxExceptionHandler.process(e.getCause());
    return false;
  }
}
Program: 128713
Project: 128713
Buggy source:
/** 
 * We will accept the selection in the workbench to see if we can initialize from it.
 * @see IWorkbenchWizard#init(IWorkbench,IStructuredSelection)
 */
public void init(final IWorkbench workbench,final IStructuredSelection selection2){
  this.selection=selection2;
}

Fixed version (ground truth):
/** 
 * We will accept the selection in the workbench to see if we can initialize from it.
 * @see IWorkbenchWizard#init(IWorkbench,IStructuredSelection)
 */
@Override public void init(final IWorkbench workbench,final IStructuredSelection selection2){
  this.selection=selection2;
}
Program: 128714
Project: 128714
Buggy source:
private void generateOriginalColumnsMap(Collection<? extends Package> dataPackageFromOrignalConnection){
  for (  orgomg.cwm.objectmodel.core.Package pkg : dataPackageFromOrignalConnection) {
    for (    ModelElement mol : pkg.getOwnedElement()) {
      if (mol instanceof MetadataTable) {
        MetadataTable table=(MetadataTable)mol;
        String oldTableUuid=ResourceHelper.getUUID(table);
        originalTablesMap.put(generateKey(table),oldTableUuid);
        for (        ModelElement col : table.getFeature()) {
          if (col instanceof MetadataColumn) {
            MetadataColumn column=(MetadataColumn)col;
            String oldColumnUuid=ResourceHelper.getUUID(column);
            originalColumnsMap.put(generateKey(column),oldColumnUuid);
          }
        }
      }
      if (mol instanceof Catalog) {
        Catalog catlog=(Catalog)mol;
        List<Schema> subschemas=CatalogHelper.getSchemas(catlog);
        if (!subschemas.isEmpty()) {
          generateOriginalColumnsMap(subschemas);
        }
      }
    }
  }
}

Fixed version (ground truth):
private void generateOriginalColumnsMap(Collection<? extends Package> dataPackageFromOrignalConnection){
  for (  orgomg.cwm.objectmodel.core.Package pkg : dataPackageFromOrignalConnection) {
    for (    ModelElement mol : pkg.getOwnedElement()) {
      if (mol instanceof MetadataTable) {
        MetadataTable table=(MetadataTable)mol;
        String oldTableUuid=ResourceHelper.getUUID(table);
        originalTablesMap.put(generateKey(table),oldTableUuid);
        for (        ModelElement col : table.getFeature()) {
          if (col instanceof MetadataColumn) {
            MetadataColumn column=(MetadataColumn)col;
            String oldColumnUuid=ResourceHelper.getUUID(column);
            originalColumnsMap.put(generateKey(column),oldColumnUuid);
          }
        }
      }
 else       if (mol instanceof Schema) {
        List<Schema> subschemas=new ArrayList<Schema>();
        subschemas.add((Schema)mol);
        generateOriginalColumnsMap(subschemas);
      }
      if (mol instanceof Catalog) {
        Catalog catlog=(Catalog)mol;
        List<Schema> subschemas=CatalogHelper.getSchemas(catlog);
        if (!subschemas.isEmpty()) {
          generateOriginalColumnsMap(subschemas);
        }
      }
    }
  }
}
Program: 128716
Project: 128716
Buggy source:
/** 
 * clone a new DB connection
 */
private void cloneBaseDataBaseConnection(DatabaseConnection connection){
  temConnection=(DatabaseConnection)EcoreUtil.copy(connection);
  EList<Package> dataPackage=connection.getDataPackage();
  Collection<Package> newDataPackage=EcoreUtil.copyAll(dataPackage);
  ConnectionHelper.addPackages(newDataPackage,temConnection);
}

Fixed version (ground truth):
/** 
 * clone a new DB connection
 */
private void cloneBaseDataBaseConnection(DatabaseConnection connection){
  temConnection=EcoreUtil.copy(connection);
  EList<Package> dataPackage=connection.getDataPackage();
  Collection<Package> newDataPackage=EcoreUtil.copyAll(dataPackage);
  ConnectionHelper.addPackages(newDataPackage,temConnection);
}
Program: 128717
Project: 128717
Buggy source:
private void replaceUUidsForColumnsAndTables(Collection<? extends Package> copyDataPackage){
  for (  orgomg.cwm.objectmodel.core.Package pkg : copyDataPackage) {
    for (    ModelElement mol : pkg.getOwnedElement()) {
      if (mol instanceof MetadataTable) {
        MetadataTable table=(MetadataTable)mol;
        String tableKey=generateKey(table);
        String oldTableID=originalTablesMap.get(tableKey);
        if (oldTableID != null) {
          setUUid(table,oldTableID);
        }
        for (        ModelElement col : table.getFeature()) {
          if (col instanceof MetadataColumn) {
            MetadataColumn column=(MetadataColumn)col;
            String columnKey=generateKey(column);
            String oldColumnID=originalColumnsMap.get(columnKey);
            if (oldColumnID != null) {
              setUUid(column,oldColumnID);
            }
          }
        }
      }
      if (mol instanceof Catalog) {
        Catalog catlog=(Catalog)mol;
        List<Schema> subschemas=CatalogHelper.getSchemas(catlog);
        if (!subschemas.isEmpty()) {
          replaceUUidsForColumnsAndTables(subschemas);
        }
      }
    }
  }
}

Fixed version (ground truth):
private void replaceUUidsForColumnsAndTables(Collection<? extends Package> copyDataPackage){
  for (  orgomg.cwm.objectmodel.core.Package pkg : copyDataPackage) {
    for (    ModelElement mol : pkg.getOwnedElement()) {
      if (mol instanceof MetadataTable) {
        MetadataTable table=(MetadataTable)mol;
        String tableKey=generateKey(table);
        String oldTableID=originalTablesMap.get(tableKey);
        if (oldTableID != null) {
          setUUid(table,oldTableID);
        }
        for (        ModelElement col : table.getFeature()) {
          if (col instanceof MetadataColumn) {
            MetadataColumn column=(MetadataColumn)col;
            String columnKey=generateKey(column);
            String oldColumnID=originalColumnsMap.get(columnKey);
            if (oldColumnID != null) {
              setUUid(column,oldColumnID);
            }
          }
        }
      }
 else       if (mol instanceof Schema) {
        List<Schema> subschemas=new ArrayList<Schema>();
        subschemas.add((Schema)mol);
        replaceUUidsForColumnsAndTables(subschemas);
      }
      if (mol instanceof Catalog) {
        Catalog catlog=(Catalog)mol;
        List<Schema> subschemas=CatalogHelper.getSchemas(catlog);
        if (!subschemas.isEmpty()) {
          replaceUUidsForColumnsAndTables(subschemas);
        }
      }
    }
  }
}
Program: 128719
Project: 128719
Buggy source:
protected boolean isReadOnly(){
  if (GlobalServiceRegister.getDefault().isServiceRegistered(IProxyRepositoryService.class)) {
    IProxyRepositoryService service=(IProxyRepositoryService)GlobalServiceRegister.getDefault().getService(IProxyRepositoryService.class);
    IProxyRepositoryFactory repositoryFactory=service.getProxyRepositoryFactory();
    return !repositoryFactory.getStatus(object).isEditable() || alreadyEditedByUser || isLock;
  }
  return true;
}

Fixed version (ground truth):
protected boolean isReadOnly(){
  if (GlobalServiceRegister.getDefault().isServiceRegistered(IProxyRepositoryService.class)) {
    IProxyRepositoryService service=(IProxyRepositoryService)GlobalServiceRegister.getDefault().getService(IProxyRepositoryService.class);
    IProxyRepositoryFactory repositoryFactory=service.getProxyRepositoryFactory();
    return !repositoryFactory.getStatus(object).isEditable() || alreadyEditedByUser;
  }
  return true;
}
Program: 128720
Project: 128720
Buggy source:
private void lockObject(){
  if (GlobalServiceRegister.getDefault().isServiceRegistered(IProxyRepositoryService.class)) {
    IProxyRepositoryService service=(IProxyRepositoryService)GlobalServiceRegister.getDefault().getService(IProxyRepositoryService.class);
    IProxyRepositoryFactory repositoryFactory=service.getProxyRepositoryFactory();
    try {
      boolean isOpened=false;
      if (GlobalServiceRegister.getDefault().isServiceRegistered(ICoreService.class)) {
        ICoreService coreService=(ICoreService)GlobalServiceRegister.getDefault().getService(ICoreService.class);
        isOpened=coreService.isOpenedItemInEditor(object);
      }
      if (repositoryFactory.getStatus(object).equals(ERepositoryStatus.LOCK_BY_USER)) {
        isLock=true;
      }
      if (repositoryFactory.getStatus(object).equals(ERepositoryStatus.LOCK_BY_USER) && isOpened) {
        alreadyEditedByUser=true;
      }
 else {
        repositoryFactory.lock(object);
      }
    }
 catch (    PersistenceException e) {
      ExceptionHandler.process(e);
    }
catch (    BusinessException e) {
    }
  }
}

Fixed version (ground truth):
private void lockObject(){
  if (GlobalServiceRegister.getDefault().isServiceRegistered(IProxyRepositoryService.class)) {
    IProxyRepositoryService service=(IProxyRepositoryService)GlobalServiceRegister.getDefault().getService(IProxyRepositoryService.class);
    IProxyRepositoryFactory repositoryFactory=service.getProxyRepositoryFactory();
    try {
      boolean isOpened=false;
      if (GlobalServiceRegister.getDefault().isServiceRegistered(ICoreService.class)) {
        ICoreService coreService=(ICoreService)GlobalServiceRegister.getDefault().getService(ICoreService.class);
        isOpened=coreService.isOpenedItemInEditor(object);
      }
      if (repositoryFactory.getStatus(object).equals(ERepositoryStatus.LOCK_BY_USER) && isOpened) {
        alreadyEditedByUser=true;
      }
 else {
        repositoryFactory.lock(object);
      }
    }
 catch (    PersistenceException e) {
      ExceptionHandler.process(e);
    }
catch (    BusinessException e) {
    }
  }
}
Program: 128722
Project: 128722
Buggy source:
@Override public void dispose(){
  if (!isLock) {
    unlockObject();
  }
  super.dispose();
}

Fixed version (ground truth):
@Override public void dispose(){
  unlockObject();
  super.dispose();
}
Program: 128723
Project: 128723
Buggy source:
@Override public void createControl(Composite parent){
  Composite container=new Composite(parent,SWT.NONE);
  GridLayout layout=new GridLayout(2,false);
  container.setLayout(layout);
  if (alreadyEditedByUser && isLock) {
    Label label=new Label(container,SWT.NONE);
    label.setForeground(ColorConstants.red);
    label.setText(Messages.getString("String_Node_Str"));
    GridData gridData=new GridData();
    gridData.horizontalSpan=2;
    label.setLayoutData(gridData);
  }
  super.createControl(container);
  setControl(container);
  updateContent();
  addListeners();
  setPageComplete(false);
}

Fixed version (ground truth):
@Override public void createControl(Composite parent){
  Composite container=new Composite(parent,SWT.NONE);
  GridLayout layout=new GridLayout(2,false);
  container.setLayout(layout);
  if (alreadyEditedByUser) {
    Label label=new Label(container,SWT.NONE);
    label.setForeground(ColorConstants.red);
    label.setText(Messages.getString("String_Node_Str"));
    GridData gridData=new GridData();
    gridData.horizontalSpan=2;
    label.setLayoutData(gridData);
  }
  super.createControl(container);
  setControl(container);
  updateContent();
  addListeners();
  setPageComplete(false);
}
Program: 128724
Project: 128724
Buggy source:
@Override public boolean performFinish(){
  if (alreadyEditedByUser || isLock) {
    return false;
  }
  IWorkspaceRunnable runnable=new IWorkspaceRunnable(){
    public void run(    final IProgressMonitor monitor) throws CoreException {
      try {
        IProxyRepositoryFactory proxyRepositoryFactory=CoreRuntimePlugin.getInstance().getProxyRepositoryFactory();
        object.getProperty().setLabel(object.getProperty().getDisplayName());
        proxyRepositoryFactory.save(object.getProperty(),originaleObjectLabel,originalVersion);
        ExpressionPersistance.getInstance().jobNameChanged(originaleObjectLabel,object.getLabel());
        proxyRepositoryFactory.saveProject(ProjectManager.getInstance().getCurrentProject());
        if (GlobalServiceRegister.getDefault().isServiceRegistered(IESBService.class)) {
          IESBService service=(IESBService)GlobalServiceRegister.getDefault().getService(IESBService.class);
          service.editJobName(originaleObjectLabel,object.getLabel());
        }
      }
 catch (      PersistenceException pe) {
        throw new CoreException(new Status(IStatus.ERROR,FrameworkUtil.getBundle(this.getClass()).getSymbolicName(),"String_Node_Str",pe));
      }
    }
  }
;
  IWorkspace workspace=ResourcesPlugin.getWorkspace();
  try {
    ISchedulingRule schedulingRule=workspace.getRoot();
    workspace.run(runnable,schedulingRule,IWorkspace.AVOID_UPDATE,null);
    return true;
  }
 catch (  CoreException e) {
    MessageBoxExceptionHandler.process(e.getCause());
    return false;
  }
}

Fixed version (ground truth):
@Override public boolean performFinish(){
  if (alreadyEditedByUser) {
    return false;
  }
  IWorkspaceRunnable runnable=new IWorkspaceRunnable(){
    public void run(    final IProgressMonitor monitor) throws CoreException {
      try {
        IProxyRepositoryFactory proxyRepositoryFactory=CoreRuntimePlugin.getInstance().getProxyRepositoryFactory();
        object.getProperty().setLabel(object.getProperty().getDisplayName());
        proxyRepositoryFactory.save(object.getProperty(),originaleObjectLabel,originalVersion);
        ExpressionPersistance.getInstance().jobNameChanged(originaleObjectLabel,object.getLabel());
        proxyRepositoryFactory.saveProject(ProjectManager.getInstance().getCurrentProject());
        if (GlobalServiceRegister.getDefault().isServiceRegistered(IESBService.class)) {
          IESBService service=(IESBService)GlobalServiceRegister.getDefault().getService(IESBService.class);
          service.editJobName(originaleObjectLabel,object.getLabel());
        }
      }
 catch (      PersistenceException pe) {
        throw new CoreException(new Status(IStatus.ERROR,FrameworkUtil.getBundle(this.getClass()).getSymbolicName(),"String_Node_Str",pe));
      }
    }
  }
;
  IWorkspace workspace=ResourcesPlugin.getWorkspace();
  try {
    ISchedulingRule schedulingRule=workspace.getRoot();
    workspace.run(runnable,schedulingRule,IWorkspace.AVOID_UPDATE,null);
    return true;
  }
 catch (  CoreException e) {
    MessageBoxExceptionHandler.process(e.getCause());
    return false;
  }
}
Program: 128725
Project: 128725
Buggy source:
/** 
 * ignore regex
 */
public static String replaceAllStrictly(String src,String search,String replacement,boolean entirelyMatch,boolean caseSensitive){
  if (search == null) {
    if (src == null) {
      return replacement;
    }
 else {
      return src;
    }
  }
 else {
    if (src == null) {
      return null;
    }
 else {
      if (replacement == null) {
        if (src.equals(search)) {
          return replacement;
        }
 else {
          return src;
        }
      }
 else {
        if (entirelyMatch) {
          String upperSrc=caseSensitive ? src : src.toUpperCase();
          String upperSearch=caseSensitive ? search : search.toUpperCase();
          return upperSrc.equals(upperSearch) ? replacement : src;
        }
 else {
          int flag=caseSensitive ? Pattern.LITERAL : Pattern.LITERAL | Pattern.CASE_INSENSITIVE;
          return Pattern.compile(search,flag).matcher(src).replaceAll(Matcher.quoteReplacement(replacement));
        }
      }
    }
  }
}

Fixed version (ground truth):
/** 
 * ignore regex
 */
public static String replaceAllStrictly(String src,String search,String replacement,boolean entirelyMatch,boolean caseSensitive){
  if (search == null) {
    if (src == null) {
      return replacement;
    }
 else {
      return src;
    }
  }
 else {
    if (src == null) {
      return null;
    }
 else {
      if (replacement == null) {
        if ((caseSensitive && src.equals(search)) || (!caseSensitive && src.equalsIgnoreCase(search))) {
          return replacement;
        }
 else {
          return src;
        }
      }
 else {
        if (entirelyMatch) {
          String upperSrc=caseSensitive ? src : src.toUpperCase();
          String upperSearch=caseSensitive ? search : search.toUpperCase();
          return upperSrc.equals(upperSearch) ? replacement : src;
        }
 else {
          int flag=caseSensitive ? Pattern.LITERAL : Pattern.LITERAL | Pattern.CASE_INSENSITIVE;
          return Pattern.compile(search,flag).matcher(src).replaceAll(Matcher.quoteReplacement(replacement));
        }
      }
    }
  }
}
Program: 128727
Project: 128727
Buggy source:
/** 
 * ignore regex
 */
public static String replaceAllStrictly(String src,String search,String replacement,boolean entirelyMatch,boolean caseSensitive){
  if (search == null) {
    if (src == null) {
      return replacement;
    }
 else {
      return src;
    }
  }
 else {
    if (src == null) {
      return null;
    }
 else {
      if (replacement == null) {
        if (src.equals(search)) {
          return replacement;
        }
 else {
          return src;
        }
      }
 else {
        if (entirelyMatch) {
          String upperSrc=caseSensitive ? src : src.toUpperCase();
          String upperSearch=caseSensitive ? search : search.toUpperCase();
          return upperSrc.equals(upperSearch) ? replacement : src;
        }
 else {
          int flag=caseSensitive ? Pattern.LITERAL : Pattern.LITERAL | Pattern.CASE_INSENSITIVE;
          return Pattern.compile(search,flag).matcher(src).replaceAll(Matcher.quoteReplacement(replacement));
        }
      }
    }
  }
}

Fixed version (ground truth):
/** 
 * ignore regex
 */
public static String replaceAllStrictly(String src,String search,String replacement,boolean entirelyMatch,boolean caseSensitive){
  if (search == null) {
    if (src == null) {
      return replacement;
    }
 else {
      return src;
    }
  }
 else {
    if (src == null) {
      return null;
    }
 else {
      if (replacement == null) {
        if ((caseSensitive && src.equals(search)) || (!caseSensitive && src.equalsIgnoreCase(search))) {
          return replacement;
        }
 else {
          return src;
        }
      }
 else {
        if (entirelyMatch) {
          String upperSrc=caseSensitive ? src : src.toUpperCase();
          String upperSearch=caseSensitive ? search : search.toUpperCase();
          return upperSrc.equals(upperSearch) ? replacement : src;
        }
 else {
          int flag=caseSensitive ? Pattern.LITERAL : Pattern.LITERAL | Pattern.CASE_INSENSITIVE;
          return Pattern.compile(search,flag).matcher(src).replaceAll(Matcher.quoteReplacement(replacement));
        }
      }
    }
  }
}
Program: 128728
Project: 128728
Buggy source:
/** 
 * ignore regex
 */
public static String replaceAllStrictly(String src,String search,String replacement,boolean entirelyMatch,boolean caseSensitive){
  if (search == null) {
    if (src == null) {
      return replacement;
    }
 else {
      return src;
    }
  }
 else {
    if (src == null) {
      return null;
    }
 else {
      if (replacement == null) {
        if (src.equals(search)) {
          return replacement;
        }
 else {
          return src;
        }
      }
 else {
        if (entirelyMatch) {
          String upperSrc=caseSensitive ? src : src.toUpperCase();
          String upperSearch=caseSensitive ? search : search.toUpperCase();
          return upperSrc.equals(upperSearch) ? replacement : src;
        }
 else {
          int flag=caseSensitive ? Pattern.LITERAL : Pattern.LITERAL | Pattern.CASE_INSENSITIVE;
          return Pattern.compile(search,flag).matcher(src).replaceAll(Matcher.quoteReplacement(replacement));
        }
      }
    }
  }
}

Fixed version (ground truth):
/** 
 * ignore regex
 */
public static String replaceAllStrictly(String src,String search,String replacement,boolean entirelyMatch,boolean caseSensitive){
  if (search == null) {
    if (src == null) {
      return replacement;
    }
 else {
      return src;
    }
  }
 else {
    if (src == null) {
      return null;
    }
 else {
      if (replacement == null) {
        if ((caseSensitive && src.equals(search)) || (!caseSensitive && src.equalsIgnoreCase(search))) {
          return replacement;
        }
 else {
          return src;
        }
      }
 else {
        if (entirelyMatch) {
          String upperSrc=caseSensitive ? src : src.toUpperCase();
          String upperSearch=caseSensitive ? search : search.toUpperCase();
          return upperSrc.equals(upperSearch) ? replacement : src;
        }
 else {
          int flag=caseSensitive ? Pattern.LITERAL : Pattern.LITERAL | Pattern.CASE_INSENSITIVE;
          return Pattern.compile(search,flag).matcher(src).replaceAll(Matcher.quoteReplacement(replacement));
        }
      }
    }
  }
}
Program: 128731
Project: 128731
Buggy source:
/** 
 * DOC ycbai Comment method "invokeMethod". Returns the value of a method.
 * @param owner
 * @param methodName
 * @param args
 * @return
 */
public static Object invokeMethod(Object owner,String methodName,Object[] args){
  Thread.currentThread().getContextClassLoader();
  Object returnValue=null;
  Class ownerClass=owner.getClass();
  Class[] argsClass=new Class[args.length];
  for (int i=0, j=args.length; i < j; i++) {
    argsClass[i]=args[i].getClass();
  }
  try {
    Method method=ownerClass.getMethod(methodName,argsClass);
    returnValue=method.invoke(owner,args);
  }
 catch (  Exception e) {
    log.error(e);
    e.printStackTrace();
  }
  return returnValue;
}

Fixed version (ground truth):
/** 
 * DOC ycbai Comment method "invokeMethod". Returns the value of a method.
 * @param owner
 * @param methodName
 * @param args
 * @return
 */
public static Object invokeMethod(Object owner,String methodName,Object[] args){
  Object returnValue=null;
  Class ownerClass=owner.getClass();
  Class[] argsClass=new Class[args.length];
  for (int i=0, j=args.length; i < j; i++) {
    argsClass[i]=args[i].getClass();
  }
  try {
    Method method=ownerClass.getMethod(methodName,argsClass);
    returnValue=method.invoke(owner,args);
  }
 catch (  Exception e) {
    log.error(e);
    e.printStackTrace();
  }
  return returnValue;
}
Program: 128732
Project: 128732
Buggy source:
/** 
 * DOC ggu Comment method "setMainProjectBranch". When use this method to set the branch value, make sure that have set the RepositoryContext object in context "ctx.putProperty(Context.REPOSITORY_CONTEXT_KEY, repositoryContext)"
 * @param technicalLabel
 * @param branchValue
 */
public void setMainProjectBranch(String technicalLabel,String branchValue){
  Map<String,String> fields=getRepositoryContextFields();
  if (fields == null || technicalLabel == null) {
    return;
  }
  String key=IProxyRepositoryFactory.BRANCH_SELECTION + SVNConstant.UNDER_LINE_CHAR + technicalLabel;
  if (branchValue == null) {
    fields.put(key,"String_Node_Str");
  }
 else {
    fields.put(key,branchValue);
  }
}

Fixed version (ground truth):
/** 
 * DOC ggu Comment method "setMainProjectBranch". When use this method to set the branch value, make sure that have set the RepositoryContext object in context "ctx.putProperty(Context.REPOSITORY_CONTEXT_KEY, repositoryContext)"
 * @param technicalLabel
 * @param branchValue
 */
public void setMainProjectBranch(String technicalLabel,String branchValue){
  Map<String,String> fields=getRepositoryContextFields();
  if (fields == null || technicalLabel == null) {
    return;
  }
  String key=IProxyRepositoryFactory.BRANCH_SELECTION + SVNConstant.UNDER_LINE_CHAR + technicalLabel;
  if (branchValue != null) {
    fields.put(key,branchValue);
  }
}
Program: 128734
Project: 128734
Buggy source:
/** 
 * Formats a Date into a date/time string.
 * @param pattern the pattern to format.
 * @param date the time value to be formatted into a time string.
 * @return the formatted time string.{talendTypes} String {Category} TalendDate {param} string("yyyy-MM-dd HH:mm:ss") pattern : the pattern to format {param} date(myDate) date : the time value to be formatted into a time string {example} formatDate("yyyy-MM-dd", new Date()) #
 */
public synchronized static String formatDate(String pattern,java.util.Date date){
  if (date instanceof TalendTimestampWithTZ) {
    DateFormat format=FastDateParser.getInstance(pattern);
    format.setTimeZone(((TalendTimestampWithTZ)date).getTimeZone());
    return format.format(date.getTime());
  }
 else {
    return FastDateParser.getInstance(pattern).format(date);
  }
}

Fixed version (ground truth):
/** 
 * Formats a Date into a date/time string.
 * @param pattern the pattern to format.
 * @param date the time value to be formatted into a time string.
 * @return the formatted time string.{talendTypes} String {Category} TalendDate {param} string("yyyy-MM-dd HH:mm:ss") pattern : the pattern to format {param} date(myDate) date : the time value to be formatted into a time string {example} formatDate("yyyy-MM-dd", new Date()) #
 */
public synchronized static String formatDate(String pattern,java.util.Date date){
  DateFormat format=FastDateParser.getInstance(pattern);
  if (date instanceof TalendTimestampWithTZ) {
    format.setTimeZone(((TalendTimestampWithTZ)date).getTimeZone());
  }
 else {
    format.setTimeZone(TimeZone.getDefault());
  }
  return format.format(date);
}
Program: 128736
Project: 128736
Buggy source:
public void init(TreeViewer viewer,IStructuredSelection selection){
  boolean canWork=!selection.isEmpty() && selection.size() == 1;
  IProxyRepositoryFactory factory=ProxyRepositoryFactory.getInstance();
  if (factory.isUserReadOnlyOnCurrentProject()) {
    canWork=false;
  }
  if (canWork) {
    Object o=selection.getFirstElement();
    RepositoryNode node=(RepositoryNode)o;
switch (node.getType()) {
case STABLE_SYSTEM_FOLDER:
      if (!node.isBin() || !node.hasChildren()) {
        canWork=false;
      }
    break;
default :
  canWork=false;
break;
}
if (canWork && !ProjectManager.getInstance().isInCurrentMainProject(node)) {
canWork=false;
}
}
setEnabled(canWork);
}

Fixed version (ground truth):
public void init(TreeViewer viewer,IStructuredSelection selection){
  boolean canWork=!selection.isEmpty() && selection.size() == 1;
  IProxyRepositoryFactory factory=ProxyRepositoryFactory.getInstance();
  if (factory.isUserReadOnlyOnCurrentProject()) {
    canWork=false;
  }
  if (!factory.getRepositoryContext().isOffline() && factory.getRepositoryContext().isEditableAsReadOnly()) {
    canWork=false;
  }
  if (canWork) {
    Object o=selection.getFirstElement();
    RepositoryNode node=(RepositoryNode)o;
switch (node.getType()) {
case STABLE_SYSTEM_FOLDER:
      if (!node.isBin() || !node.hasChildren()) {
        canWork=false;
      }
    break;
default :
  canWork=false;
break;
}
if (canWork && !ProjectManager.getInstance().isInCurrentMainProject(node)) {
canWork=false;
}
}
setEnabled(canWork);
}
Program: 128737
Project: 128737
Buggy source:
public ExternalModulesInstallDialog(Shell shell,String text,String title){
  super(shell);
  setShellStyle(SWT.CLOSE | SWT.MAX | SWT.TITLE| SWT.BORDER| SWT.APPLICATION_MODAL| SWT.RESIZE| getDefaultOrientation());
  if (osName.contains("String_Node_Str")) {
    font=fontMac;
  }
  this.text=text;
  this.title=title;
}

Fixed version (ground truth):
public ExternalModulesInstallDialog(Shell shell,String text,String title){
  super(shell);
  setShellStyle(SWT.CLOSE | SWT.MIN | SWT.MAX| SWT.TITLE| SWT.BORDER| SWT.RESIZE| getDefaultOrientation());
  if (osName.contains("String_Node_Str")) {
    font=fontMac;
  }
  this.text=text;
  this.title=title;
}
Program: 128738
Project: 128738
Buggy source:
/** 
 * Formats a Date into a date/time string.
 * @param pattern the pattern to format.
 * @param date the time value to be formatted into a time string.
 * @return the formatted time string.{talendTypes} String {Category} TalendDate {param} string("yyyy-MM-dd HH:mm:ss") pattern : the pattern to format {param} date(myDate) date : the time value to be formatted into a time string {example} formatDate("yyyy-MM-dd", new Date()) #
 */
public synchronized static String formatDate(String pattern,java.util.Date date){
  if (date instanceof TalendTimestampWithTZ) {
    DateFormat format=FastDateParser.getInstance(pattern);
    format.setTimeZone(((TalendTimestampWithTZ)date).getTimeZone());
    return format.format(date.getTime());
  }
 else {
    return FastDateParser.getInstance(pattern).format(date);
  }
}

Fixed version (ground truth):
/** 
 * Formats a Date into a date/time string.
 * @param pattern the pattern to format.
 * @param date the time value to be formatted into a time string.
 * @return the formatted time string.{talendTypes} String {Category} TalendDate {param} string("yyyy-MM-dd HH:mm:ss") pattern : the pattern to format {param} date(myDate) date : the time value to be formatted into a time string {example} formatDate("yyyy-MM-dd", new Date()) #
 */
public synchronized static String formatDate(String pattern,java.util.Date date){
  DateFormat format=FastDateParser.getInstance(pattern);
  if (date instanceof TalendTimestampWithTZ) {
    format.setTimeZone(((TalendTimestampWithTZ)date).getTimeZone());
  }
 else {
    format.setTimeZone(TimeZone.getDefault());
  }
  return format.format(date);
}
Program: 128740
Project: 128740
Buggy source:
/** 
 * Formats a Date into a date/time string.
 * @param pattern the pattern to format.
 * @param date the time value to be formatted into a time string.
 * @return the formatted time string.{talendTypes} String {Category} TalendDate {param} string("yyyy-MM-dd HH:mm:ss") pattern : the pattern to format {param} date(myDate) date : the time value to be formatted into a time string {example} formatDate("yyyy-MM-dd", new Date()) #
 */
public synchronized static String formatDate(String pattern,java.util.Date date){
  if (date instanceof TalendTimestampWithTZ) {
    DateFormat format=FastDateParser.getInstance(pattern);
    format.setTimeZone(((TalendTimestampWithTZ)date).getTimeZone());
    return format.format(date.getTime());
  }
 else {
    return FastDateParser.getInstance(pattern).format(date);
  }
}

Fixed version (ground truth):
/** 
 * Formats a Date into a date/time string.
 * @param pattern the pattern to format.
 * @param date the time value to be formatted into a time string.
 * @return the formatted time string.{talendTypes} String {Category} TalendDate {param} string("yyyy-MM-dd HH:mm:ss") pattern : the pattern to format {param} date(myDate) date : the time value to be formatted into a time string {example} formatDate("yyyy-MM-dd", new Date()) #
 */
public synchronized static String formatDate(String pattern,java.util.Date date){
  DateFormat format=FastDateParser.getInstance(pattern);
  if (date instanceof TalendTimestampWithTZ) {
    format.setTimeZone(((TalendTimestampWithTZ)date).getTimeZone());
  }
 else {
    format.setTimeZone(TimeZone.getDefault());
  }
  return format.format(date);
}
Program: 128742
Project: 128742
Buggy source:
@Override protected void run() throws LoginException, PersistenceException {
  try {
    Item newItem=factory.copy(item,path,true);
    if (newItem instanceof RoutineItem) {
      synDuplicatedRoutine((RoutineItem)newItem);
    }
    ICamelDesignerCoreService service=null;
    if (GlobalServiceRegister.getDefault().isServiceRegistered(ICamelDesignerCoreService.class)) {
      service=(ICamelDesignerCoreService)GlobalServiceRegister.getDefault().getService(ICamelDesignerCoreService.class);
    }
    if (service != null && service.isInstanceofCamelBeans(item)) {
      synDuplicatedBean(newItem);
    }
    if (newItem instanceof ProcessItem || newItem instanceof JobletProcessItem) {
      RelationshipItemBuilder.getInstance().addOrUpdateItem(newItem);
    }
    if (newItem instanceof ConnectionItem) {
      ConnectionItem connectionItem=(ConnectionItem)newItem;
      connectionItem.getConnection().getSupplierDependency().clear();
    }
    factory.save(newItem);
  }
 catch (  Exception e) {
    ExceptionHandler.process(e);
  }
}

Fixed version (ground truth):
public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
  IWorkspace workspace=ResourcesPlugin.getWorkspace();
  try {
    ISchedulingRule schedulingRule=workspace.getRoot();
    workspace.run(op,schedulingRule,IWorkspace.AVOID_UPDATE,monitor);
  }
 catch (  CoreException e) {
    throw new InvocationTargetException(e);
  }
}
Program: 128745
Project: 128745
Buggy source:
/** 
 * Test method for studio have all the lib for the system of db connection .
 */
@Test public void testMissingJar() throws MalformedURLException {
  Set<String> names=new HashSet<String>();
  List<File> jarFiles=FilesUtils.getJarFilesFromFolder(getStorageDirectory(),null);
  if (jarFiles.size() > 0) {
    for (    File file : jarFiles) {
      names.add(file.getName());
    }
  }
  LibrariesIndexManager.getInstance().loadResource();
  EMap<String,String> jarsToRelative=LibrariesIndexManager.getInstance().getIndex().getJarsToRelativePath();
  names.addAll(jarsToRelative.keySet());
  List<String> allJars=new ArrayList<String>();
  EDatabaseVersion4Drivers[] values=EDatabaseVersion4Drivers.values();
  for (  EDatabaseVersion4Drivers driver : values) {
    Set<String> providerDrivers=driver.getProviderDrivers();
    allJars.addAll(providerDrivers);
  }
  List<String> missJars=new ArrayList<String>();
  for (  String jar : allJars) {
    boolean hadInstalled=false;
    for (    String installJar : names) {
      if (jar.equals(installJar)) {
        hadInstalled=true;
      }
    }
    if (!hadInstalled) {
      missJars.add(jar);
    }
  }
  if (missJars.size() > 0) {
    System.out.println("String_Node_Str");
    for (    String missJar : missJars) {
      System.out.println(missJar);
    }
    System.out.println("String_Node_Str");
  }
  assertTrue(missJars.size() == 0);
}

Fixed version (ground truth):
/** 
 * Test method for studio have all the lib for the system of db connection .
 */
@Test public void testMissingJar() throws MalformedURLException {
  Set<String> names=new HashSet<String>();
  List<File> jarFiles=FilesUtils.getJarFilesFromFolder(getStorageDirectory(),null);
  if (jarFiles.size() > 0) {
    for (    File file : jarFiles) {
      names.add(file.getName());
    }
  }
  LibrariesIndexManager.getInstance().loadResource();
  EMap<String,String> jarsToRelative=LibrariesIndexManager.getInstance().getIndex().getJarsToRelativePath();
  names.addAll(jarsToRelative.keySet());
  List<String> allJars=new ArrayList<String>();
  EDatabaseVersion4Drivers[] values=EDatabaseVersion4Drivers.values();
  for (  EDatabaseVersion4Drivers driver : values) {
    Set<String> providerDrivers=driver.getProviderDrivers();
    allJars.addAll(providerDrivers);
  }
  List<String> missJars=new ArrayList<String>();
  for (  String jar : allJars) {
    boolean hadInstalled=false;
    for (    String installJar : names) {
      if (jar.equals(installJar)) {
        hadInstalled=true;
      }
    }
    if (!hadInstalled) {
      missJars.add(jar);
    }
  }
  if (missJars.size() > 0) {
    StringBuffer buffer=new StringBuffer();
    buffer.append("String_Node_Str");
    for (    String missJar : missJars) {
      buffer.append(missJar + "String_Node_Str");
    }
    throw new RuntimeException(buffer.toString());
  }
}
Program: 128747
Project: 128747
Buggy source:
private TableEditor addTableEditor(TableViewerCreatorColumnNotModifiable column,TableEditorContentNotModifiable tableEditorContent,String idProperty,TableItem tableItem){
  if (tableItem.getData() == null) {
    return null;
  }
  tableEditorContent.setLayoutEnabled(true);
  TableEditor tableEditor=tableEditorContent.createTableEditor(tableItem.getParent());
  tableEditorList.add(tableEditor);
  dataToMultipleDataEditor.put(tableItem.getData(),tableEditor);
  Object currentRowObject=tableItem.getData();
  Object value=column.getBeanPropertyAccessors().get(tableItem.getData());
  Control control=tableEditorContent.initialize(tableItem.getParent(),tableEditor,column,currentRowObject,value);
  if (tableItem != null && !tableItem.isDisposed()) {
    tableEditor.setEditor(control,tableItem,column.getIndex());
    fireEvent(new TableEditorManagerEvent(EVENT_TYPE.CONTROL_CREATED,tableEditor));
  }
  return tableEditor;
}

Fixed version (ground truth):
private TableEditor addTableEditor(TableViewerCreatorColumnNotModifiable column,TableEditorContentNotModifiable tableEditorContent,String idProperty,TableItem tableItem){
  if (tableItem.getData() == null) {
    return null;
  }
  tableEditorContent.setLayoutEnabled(true);
  TableEditor tableEditor=tableEditorContent.createTableEditor(tableItem.getParent());
  tableEditorList.add(tableEditor);
  dataToMultipleDataEditor.put(tableItem.getData(),tableEditor);
  Object currentRowObject=tableItem.getData();
  Object value=null;
  if (column.getBeanPropertyAccessors() != null) {
    value=column.getBeanPropertyAccessors().get(tableItem.getData());
  }
 else {
    value=tableViewerCreator.getCellModifier().getValue(currentRowObject,idProperty);
  }
  Control control=tableEditorContent.initialize(tableItem.getParent(),tableEditor,column,currentRowObject,value);
  if (tableItem != null && !tableItem.isDisposed()) {
    tableEditor.setEditor(control,tableItem,column.getIndex());
    fireEvent(new TableEditorManagerEvent(EVENT_TYPE.CONTROL_CREATED,tableEditor));
  }
  return tableEditor;
}