nus-yam/ex-repair huggingface dataset:
Program: 122040
Project: 122040
Buggy source:
private void getAllKeysNames(SchemasKeyData root){
  if (root != null) {
    if (root.getUniqueRecord() != null) {
      keyNames.add(root.getUniqueRecord());
    }
    if (root.getChildren() != null) {
      List<SchemasKeyData> children=root.getChildren();
      for (      SchemasKeyData child : children) {
        getAllKeysNames(child);
      }
    }
  }
}

Fixed version (ground truth):
private void getAllKeysNames(SchemasKeyData root){
  if (root != null) {
    if (root.getUniqueRecord() != null) {
      keyNames.add(root.getUniqueRecord().toUpperCase());
    }
    if (root.getChildren() != null) {
      List<SchemasKeyData> children=root.getChildren();
      for (      SchemasKeyData child : children) {
        getAllKeysNames(child);
      }
    }
  }
}
Program: 122041
Project: 122041
Buggy source:
private void validate(String currentName){
  boolean enabled=false;
  String msg=null;
  if (!Pattern.matches("String_Node_Str",currentName)) {
    msg="String_Node_Str";
  }
 else   if (!keyNames.contains(currentName)) {
    enabled=true;
    msg=TITLE;
  }
 else {
    msg="String_Node_Str";
  }
  this.OK.setEnabled(enabled);
  this.parentShell.setText(msg);
  this.parentShell.pack();
}

Fixed version (ground truth):
private void validate(String currentName){
  boolean enabled=false;
  String msg=null;
  if (!Pattern.matches("String_Node_Str",currentName)) {
    msg="String_Node_Str";
  }
 else   if (currentName != null && !keyNames.contains(currentName.toUpperCase())) {
    enabled=true;
    msg=TITLE;
  }
 else {
    msg="String_Node_Str";
  }
  this.OK.setEnabled(enabled);
  this.parentShell.setText(msg);
  this.parentShell.pack();
}
Program: 122043
Project: 122043
Buggy source:
public void treeExpanded(TreeExpansionEvent event){
  refreshCheckedTreeView();
}

Fixed version (ground truth):
public void treeExpanded(TreeExpansionEvent event){
}
Program: 122046
Project: 122046
Buggy source:
private void refreshResumingConnections(){
  if (propName.equals(EParameterName.RESUMING_CHECKPOINT.getName()) || this.elem instanceof Connection) {
    if (((Connection)this.elem).getConnectionTrace() != null && !propName.equals(EParameterName.CONDITION))     ((Connection)this.elem).getConnectionTrace().setPropertyValue(EParameterName.RESUMING_CHECKPOINT.getName(),true);
  }
}

Fixed version (ground truth):
private void refreshResumingConnections(){
  if (propName.equals(EParameterName.RESUMING_CHECKPOINT.getName()) || this.elem instanceof Connection) {
    if (((Connection)this.elem).getConnectionTrace() != null && !propName.equals(EParameterName.CONDITION)) {
      ((Connection)this.elem).getConnectionTrace().setPropertyValue(EParameterName.RESUMING_CHECKPOINT.getName(),true);
    }
  }
}
Program: 122048
Project: 122048
Buggy source:
private void refreshTraceConnections(){
  if (propName.equals(EParameterName.TRACES_CONNECTION_ENABLE.getName()) || this.elem instanceof Connection) {
    if (((Connection)this.elem).getConnectionTrace() != null && !propName.equals(EParameterName.CONDITION))     ((Connection)this.elem).getConnectionTrace().setPropertyValue(EParameterName.TRACES_SHOW_ENABLE.getName(),true);
  }
}

Fixed version (ground truth):
private void refreshTraceConnections(){
  if (propName.equals(EParameterName.TRACES_CONNECTION_ENABLE.getName()) || this.elem instanceof Connection) {
    if (((Connection)this.elem).getConnectionTrace() != null && !propName.equals(EParameterName.CONDITION)) {
      ((Connection)this.elem).getConnectionTrace().setPropertyValue(EParameterName.TRACES_SHOW_ENABLE.getName(),true);
    }
  }
}
Program: 122052
Project: 122052
Buggy source:
@Override public void mousePressed(MouseEvent me){
  OutputTreeNode outputTreeNode=(OutputTreeNode)treeNode;
  List<TreeNode> loopNodes=new ArrayList<TreeNode>();
  if (inputMainTable != null && inputMainTable.isMultiLoops()) {
    loopNodes.addAll(XmlMapUtil.getMultiLoopsForInputTree(inputMainTable));
  }
  InputLoopNodesTable inputLoopNodesTable=null;
  if (outputTreeNode.getInputLoopNodesTable() != null) {
    inputLoopNodesTable=outputTreeNode.getInputLoopNodesTable();
  }
 else {
    inputLoopNodesTable=XmlmapFactory.eINSTANCE.createInputLoopNodesTable();
    outputTreeNode.setInputLoopNodesTable(inputLoopNodesTable);
    AbstractInOutTree abstractInOutTree=XmlMapUtil.getAbstractInOutTree(outputTreeNode);
    if (abstractInOutTree != null) {
      ((OutputXmlTree)abstractInOutTree).getInputLoopNodesTables().add(inputLoopNodesTable);
    }
  }
  SetLoopFunctionDialog nsDialog=new SetLoopFunctionDialog(null,outputTreeNode.getInputLoopNodesTable(),loopNodes);
  if (nsDialog.open() == Window.OK) {
    ((XmlMapGraphicViewer)treeNodePart.getViewer()).getMapperManager().getProblemsAnalyser().checkProblems(XmlMapUtil.getAbstractInOutTree(outputTreeNode));
    ((XmlMapGraphicViewer)treeNodePart.getViewer()).getMapperManager().getMapperUI().updateStatusBar();
  }
}

Fixed version (ground truth):
@Override public void mousePressed(MouseEvent me){
  OutputTreeNode outputTreeNode=(OutputTreeNode)treeNode;
  List<TreeNode> loopNodes=new ArrayList<TreeNode>();
  if (inputMainTable != null && inputMainTable.isMultiLoops()) {
    loopNodes.addAll(XmlMapUtil.getMultiLoopsForXmlTree(inputMainTable));
  }
  InputLoopNodesTable inputLoopNodesTable=null;
  if (outputTreeNode.getInputLoopNodesTable() != null) {
    inputLoopNodesTable=outputTreeNode.getInputLoopNodesTable();
  }
 else {
    inputLoopNodesTable=XmlmapFactory.eINSTANCE.createInputLoopNodesTable();
    outputTreeNode.setInputLoopNodesTable(inputLoopNodesTable);
    AbstractInOutTree abstractInOutTree=XmlMapUtil.getAbstractInOutTree(outputTreeNode);
    if (abstractInOutTree != null) {
      ((OutputXmlTree)abstractInOutTree).getInputLoopNodesTables().add(inputLoopNodesTable);
    }
  }
  SetLoopFunctionDialog nsDialog=new SetLoopFunctionDialog(null,outputTreeNode.getInputLoopNodesTable(),loopNodes);
  if (nsDialog.open() == Window.OK) {
    ((XmlMapGraphicViewer)treeNodePart.getViewer()).getMapperManager().getProblemsAnalyser().checkProblems(XmlMapUtil.getAbstractInOutTree(outputTreeNode));
    ((XmlMapGraphicViewer)treeNodePart.getViewer()).getMapperManager().getMapperUI().updateStatusBar();
  }
}
Program: 122059
Project: 122059
Buggy source:
private void showError(){
  MessageDialog.openError(null,"String_Node_Str","String_Node_Str");
}

Fixed version (ground truth):
private void showError(String detailedMessage){
  ErrorDialogWidthDetailArea dialog=new ErrorDialogWidthDetailArea(null,XmlMapPlugin.PLUGIN_ID,"String_Node_Str",detailedMessage,IStatus.ERROR);
}
Program: 122060
Project: 122060
Buggy source:
private String initFileContent(XmlFileConnection connection){
  byte[] bytes=connection.getFileContent();
  Project project=ProjectManager.getInstance().getCurrentProject();
  IProject fsProject=null;
  try {
    fsProject=ResourceUtils.getProject(project.getTechnicalLabel());
  }
 catch (  PersistenceException e2) {
    ExceptionHandler.process(e2);
  }
  if (fsProject == null) {
    return null;
  }
  String temPath=fsProject.getLocationURI().getPath() + File.separator + "String_Node_Str";
  String fileName="String_Node_Str";
  String pathStr=connection.getXmlFilePath();
  if (connection.isContextMode()) {
    ContextType contextType=ConnectionContextHelper.getContextTypeForContextMode(connection,true);
    pathStr=TalendQuoteUtils.removeQuotes(ConnectionContextHelper.getOriginalValue(contextType,pathStr));
  }
  if (pathStr != null && XmlUtil.isXMLFile(pathStr)) {
    fileName=StringUtil.TMP_XML_FILE;
  }
 else   if (pathStr != null && XmlUtil.isXSDFile(pathStr)) {
    fileName=StringUtil.TMP_XSD_FILE;
  }
 else   if (pathStr.contains("String_Node_Str")) {
    fileName=new Path(pathStr).lastSegment();
  }
  File temfile=new File(temPath + File.separator + fileName);
  if (!temfile.exists()) {
    try {
      temfile.createNewFile();
    }
 catch (    IOException e) {
      ExceptionHandler.process(e);
    }
  }
  FileOutputStream outStream;
  try {
    outStream=new FileOutputStream(temfile);
    outStream.write(bytes);
    outStream.close();
  }
 catch (  FileNotFoundException e1) {
    ExceptionHandler.process(e1);
  }
catch (  IOException e) {
    ExceptionHandler.process(e);
  }
  return temfile.getPath();
}

Fixed version (ground truth):
private String initFileContent(XmlFileConnection connection) throws IOException {
  byte[] bytes=connection.getFileContent();
  Project project=ProjectManager.getInstance().getCurrentProject();
  IProject fsProject=null;
  try {
    fsProject=ResourceUtils.getProject(project.getTechnicalLabel());
  }
 catch (  PersistenceException e2) {
    ExceptionHandler.process(e2);
  }
  if (fsProject == null) {
    return null;
  }
  String temPath=fsProject.getLocationURI().getPath() + File.separator + "String_Node_Str";
  String fileName="String_Node_Str";
  String pathStr=connection.getXmlFilePath();
  if (connection.isContextMode()) {
    ContextType contextType=ConnectionContextHelper.getContextTypeForContextMode(connection,true);
    pathStr=TalendQuoteUtils.removeQuotes(ConnectionContextHelper.getOriginalValue(contextType,pathStr));
  }
  if (pathStr != null && XmlUtil.isXMLFile(pathStr)) {
    fileName=StringUtil.TMP_XML_FILE;
  }
 else   if (pathStr != null && XmlUtil.isXSDFile(pathStr)) {
    fileName=StringUtil.TMP_XSD_FILE;
  }
 else   if (pathStr.contains("String_Node_Str")) {
    fileName=new Path(pathStr).lastSegment();
  }
  File temfile=new File(temPath + File.separator + fileName);
  if (!temfile.exists()) {
    temfile.createNewFile();
  }
  FileOutputStream outStream;
  outStream=new FileOutputStream(temfile);
  outStream.write(bytes);
  outStream.close();
  return temfile.getPath();
}
Program: 122062
Project: 122062
Buggy source:
protected void showError(){
  MessageDialog.openError(null,"String_Node_Str","String_Node_Str");
}

Fixed version (ground truth):
private void showError(String detailedMessage){
  ErrorDialogWidthDetailArea dialog=new ErrorDialogWidthDetailArea(null,XmlMapPlugin.PLUGIN_ID,"String_Node_Str",detailedMessage,IStatus.ERROR);
}
Program: 122064
Project: 122064
Buggy source:
protected boolean isSelectionValid(SelectionChangedEvent event){
  boolean highlightOKButton=true;
  IStructuredSelection selection=(IStructuredSelection)event.getSelection();
  if (selection == null || selection.size() != 1) {
    highlightOKButton=false;
  }
 else {
    RepositoryNode node=(RepositoryNode)selection.getFirstElement();
    if (node.getObject() == null || node.getObject().getProperty() == null) {
      return false;
    }
    Item item=node.getObject().getProperty().getItem();
    if (item instanceof XmlFileConnectionItem) {
      ERepositoryObjectType t=(ERepositoryObjectType)node.getProperties(EProperties.CONTENT_TYPE);
      if (node.getType() != ENodeType.REPOSITORY_ELEMENT) {
        highlightOKButton=false;
      }
    }
 else     if (item instanceof MDMConnectionItem) {
      if (node.getObject() instanceof MetadataTable) {
        highlightOKButton=true;
        updateErrorMessage(null);
      }
 else {
        highlightOKButton=false;
        updateErrorMessage(Messages.getString("String_Node_Str"));
      }
    }
  }
  return highlightOKButton;
}

Fixed version (ground truth):
@Override protected boolean isSelectionValid(SelectionChangedEvent event){
  boolean highlightOKButton=true;
  IStructuredSelection selection=(IStructuredSelection)event.getSelection();
  if (selection == null || selection.size() != 1) {
    highlightOKButton=false;
  }
 else {
    RepositoryNode node=(RepositoryNode)selection.getFirstElement();
    if (node.getObject() == null || node.getObject().getProperty() == null) {
      return false;
    }
    if (node.getObject() instanceof Folder) {
      return false;
    }
    Item item=node.getObject().getProperty().getItem();
    if (item instanceof XmlFileConnectionItem) {
      ERepositoryObjectType t=(ERepositoryObjectType)node.getProperties(EProperties.CONTENT_TYPE);
      if (node.getType() != ENodeType.REPOSITORY_ELEMENT) {
        highlightOKButton=false;
      }
    }
 else     if (item instanceof MDMConnectionItem) {
      if (node.getObject() instanceof MetadataTable) {
        highlightOKButton=true;
        updateErrorMessage(null);
      }
 else {
        highlightOKButton=false;
        updateErrorMessage(Messages.getString("String_Node_Str"));
      }
    }
  }
  return highlightOKButton;
}
Program: 122065
Project: 122065
Buggy source:
private boolean checkKeyValue(String oldValue,String newValue){
  String errorMsg=null;
  boolean canModify=true;
  if (!Pattern.matches(SCHEMA_NAME_PATTERN,newValue)) {
    errorMsg="String_Node_Str" + newValue + "String_Node_Str";
  }
 else {
    final Object input=schemaTreeViewer.getInput();
    if (input instanceof SchemasKeyData) {
      List<String> list=new ArrayList<String>();
      final List<SchemasKeyData> children=((SchemasKeyData)input).getChildren();
      for (      SchemasKeyData schema : children) {
        final String name=schema.getUniqueRecord();
        if (!name.equals(oldValue)) {
          list.add(name);
        }
      }
      if (list.contains(newValue)) {
        errorMsg="String_Node_Str" + newValue + "String_Node_Str";
      }
    }
  }
  if (errorMsg != null) {
    MessageDialog.openError(schemaTreeViewer.getTree().getShell(),"String_Node_Str",errorMsg);
    canModify=false;
  }
  return canModify;
}

Fixed version (ground truth):
private boolean checkKeyValue(String oldValue,String newValue){
  String errorMsg=null;
  boolean canModify=true;
  if (!Pattern.matches(SCHEMA_NAME_PATTERN,newValue)) {
    errorMsg="String_Node_Str" + newValue + "String_Node_Str";
  }
 else {
    final Object input=schemaTreeViewer.getInput();
    if (input instanceof SchemasKeyData) {
      List<String> list=new ArrayList<String>();
      final List<SchemasKeyData> children=((SchemasKeyData)input).getChildren();
      for (      SchemasKeyData schema : children) {
        final String name=schema.getUniqueRecord();
        if (!name.equals(oldValue)) {
          list.add(name.toUpperCase());
        }
      }
      if (newValue != null && list.contains(newValue.toUpperCase())) {
        errorMsg="String_Node_Str" + newValue + "String_Node_Str";
      }
    }
  }
  if (errorMsg != null) {
    MessageDialog.openError(schemaTreeViewer.getTree().getShell(),"String_Node_Str",errorMsg);
    canModify=false;
  }
  return canModify;
}
Program: 122066
Project: 122066
Buggy source:
private void getAllKeysNames(SchemasKeyData root){
  if (root != null) {
    if (root.getUniqueRecord() != null) {
      keyNames.add(root.getUniqueRecord());
    }
    if (root.getChildren() != null) {
      List<SchemasKeyData> children=root.getChildren();
      for (      SchemasKeyData child : children) {
        getAllKeysNames(child);
      }
    }
  }
}

Fixed version (ground truth):
private void getAllKeysNames(SchemasKeyData root){
  if (root != null) {
    if (root.getUniqueRecord() != null) {
      keyNames.add(root.getUniqueRecord().toUpperCase());
    }
    if (root.getChildren() != null) {
      List<SchemasKeyData> children=root.getChildren();
      for (      SchemasKeyData child : children) {
        getAllKeysNames(child);
      }
    }
  }
}
Program: 122067
Project: 122067
Buggy source:
private void validate(String currentName){
  boolean enabled=false;
  String msg=null;
  if (!Pattern.matches("String_Node_Str",currentName)) {
    msg="String_Node_Str";
  }
 else   if (!keyNames.contains(currentName)) {
    enabled=true;
    msg=TITLE;
  }
 else {
    msg="String_Node_Str";
  }
  this.OK.setEnabled(enabled);
  this.parentShell.setText(msg);
  this.parentShell.pack();
}

Fixed version (ground truth):
private void validate(String currentName){
  boolean enabled=false;
  String msg=null;
  if (!Pattern.matches("String_Node_Str",currentName)) {
    msg="String_Node_Str";
  }
 else   if (currentName != null && !keyNames.contains(currentName.toUpperCase())) {
    enabled=true;
    msg=TITLE;
  }
 else {
    msg="String_Node_Str";
  }
  this.OK.setEnabled(enabled);
  this.parentShell.setText(msg);
  this.parentShell.pack();
}
Program: 122072
Project: 122072
Buggy source:
@Override public void mousePressed(MouseEvent me){
  OutputTreeNode outputTreeNode=(OutputTreeNode)treeNode;
  List<TreeNode> loopNodes=new ArrayList<TreeNode>();
  if (inputMainTable != null && inputMainTable.isMultiLoops()) {
    loopNodes.addAll(XmlMapUtil.getMultiLoopsForInputTree(inputMainTable));
  }
  InputLoopNodesTable inputLoopNodesTable=null;
  if (outputTreeNode.getInputLoopNodesTable() != null) {
    inputLoopNodesTable=outputTreeNode.getInputLoopNodesTable();
  }
 else {
    inputLoopNodesTable=XmlmapFactory.eINSTANCE.createInputLoopNodesTable();
    outputTreeNode.setInputLoopNodesTable(inputLoopNodesTable);
    AbstractInOutTree abstractInOutTree=XmlMapUtil.getAbstractInOutTree(outputTreeNode);
    if (abstractInOutTree != null) {
      ((OutputXmlTree)abstractInOutTree).getInputLoopNodesTables().add(inputLoopNodesTable);
    }
  }
  SetLoopFunctionDialog nsDialog=new SetLoopFunctionDialog(null,outputTreeNode.getInputLoopNodesTable(),loopNodes);
  if (nsDialog.open() == Window.OK) {
    ((XmlMapGraphicViewer)treeNodePart.getViewer()).getMapperManager().getProblemsAnalyser().checkProblems(XmlMapUtil.getAbstractInOutTree(outputTreeNode));
    ((XmlMapGraphicViewer)treeNodePart.getViewer()).getMapperManager().getMapperUI().updateStatusBar();
  }
}

Fixed version (ground truth):
@Override public void mousePressed(MouseEvent me){
  OutputTreeNode outputTreeNode=(OutputTreeNode)treeNode;
  List<TreeNode> loopNodes=new ArrayList<TreeNode>();
  if (inputMainTable != null && inputMainTable.isMultiLoops()) {
    loopNodes.addAll(XmlMapUtil.getMultiLoopsForXmlTree(inputMainTable));
  }
  InputLoopNodesTable inputLoopNodesTable=null;
  if (outputTreeNode.getInputLoopNodesTable() != null) {
    inputLoopNodesTable=outputTreeNode.getInputLoopNodesTable();
  }
 else {
    inputLoopNodesTable=XmlmapFactory.eINSTANCE.createInputLoopNodesTable();
    outputTreeNode.setInputLoopNodesTable(inputLoopNodesTable);
    AbstractInOutTree abstractInOutTree=XmlMapUtil.getAbstractInOutTree(outputTreeNode);
    if (abstractInOutTree != null) {
      ((OutputXmlTree)abstractInOutTree).getInputLoopNodesTables().add(inputLoopNodesTable);
    }
  }
  SetLoopFunctionDialog nsDialog=new SetLoopFunctionDialog(null,outputTreeNode.getInputLoopNodesTable(),loopNodes);
  if (nsDialog.open() == Window.OK) {
    ((XmlMapGraphicViewer)treeNodePart.getViewer()).getMapperManager().getProblemsAnalyser().checkProblems(XmlMapUtil.getAbstractInOutTree(outputTreeNode));
    ((XmlMapGraphicViewer)treeNodePart.getViewer()).getMapperManager().getMapperUI().updateStatusBar();
  }
}
Program: 122079
Project: 122079
Buggy source:
private void showError(){
  MessageDialog.openError(null,"String_Node_Str","String_Node_Str");
}

Fixed version (ground truth):
private void showError(String detailedMessage){
  ErrorDialogWidthDetailArea dialog=new ErrorDialogWidthDetailArea(null,XmlMapPlugin.PLUGIN_ID,"String_Node_Str",detailedMessage,IStatus.ERROR);
}
Program: 122080
Project: 122080
Buggy source:
private String initFileContent(XmlFileConnection connection){
  byte[] bytes=connection.getFileContent();
  Project project=ProjectManager.getInstance().getCurrentProject();
  IProject fsProject=null;
  try {
    fsProject=ResourceUtils.getProject(project.getTechnicalLabel());
  }
 catch (  PersistenceException e2) {
    ExceptionHandler.process(e2);
  }
  if (fsProject == null) {
    return null;
  }
  String temPath=fsProject.getLocationURI().getPath() + File.separator + "String_Node_Str";
  String fileName="String_Node_Str";
  String pathStr=connection.getXmlFilePath();
  if (connection.isContextMode()) {
    ContextType contextType=ConnectionContextHelper.getContextTypeForContextMode(connection,true);
    pathStr=TalendQuoteUtils.removeQuotes(ConnectionContextHelper.getOriginalValue(contextType,pathStr));
  }
  if (pathStr != null && XmlUtil.isXMLFile(pathStr)) {
    fileName=StringUtil.TMP_XML_FILE;
  }
 else   if (pathStr != null && XmlUtil.isXSDFile(pathStr)) {
    fileName=StringUtil.TMP_XSD_FILE;
  }
 else   if (pathStr.contains("String_Node_Str")) {
    fileName=new Path(pathStr).lastSegment();
  }
  File temfile=new File(temPath + File.separator + fileName);
  if (!temfile.exists()) {
    try {
      temfile.createNewFile();
    }
 catch (    IOException e) {
      ExceptionHandler.process(e);
    }
  }
  FileOutputStream outStream;
  try {
    outStream=new FileOutputStream(temfile);
    outStream.write(bytes);
    outStream.close();
  }
 catch (  FileNotFoundException e1) {
    ExceptionHandler.process(e1);
  }
catch (  IOException e) {
    ExceptionHandler.process(e);
  }
  return temfile.getPath();
}

Fixed version (ground truth):
private String initFileContent(XmlFileConnection connection) throws IOException {
  byte[] bytes=connection.getFileContent();
  Project project=ProjectManager.getInstance().getCurrentProject();
  IProject fsProject=null;
  try {
    fsProject=ResourceUtils.getProject(project.getTechnicalLabel());
  }
 catch (  PersistenceException e2) {
    ExceptionHandler.process(e2);
  }
  if (fsProject == null) {
    return null;
  }
  String temPath=fsProject.getLocationURI().getPath() + File.separator + "String_Node_Str";
  String fileName="String_Node_Str";
  String pathStr=connection.getXmlFilePath();
  if (connection.isContextMode()) {
    ContextType contextType=ConnectionContextHelper.getContextTypeForContextMode(connection,true);
    pathStr=TalendQuoteUtils.removeQuotes(ConnectionContextHelper.getOriginalValue(contextType,pathStr));
  }
  if (pathStr != null && XmlUtil.isXMLFile(pathStr)) {
    fileName=StringUtil.TMP_XML_FILE;
  }
 else   if (pathStr != null && XmlUtil.isXSDFile(pathStr)) {
    fileName=StringUtil.TMP_XSD_FILE;
  }
 else   if (pathStr.contains("String_Node_Str")) {
    fileName=new Path(pathStr).lastSegment();
  }
  File temfile=new File(temPath + File.separator + fileName);
  if (!temfile.exists()) {
    temfile.createNewFile();
  }
  FileOutputStream outStream;
  outStream=new FileOutputStream(temfile);
  outStream.write(bytes);
  outStream.close();
  return temfile.getPath();
}
Program: 122082
Project: 122082
Buggy source:
protected void showError(){
  MessageDialog.openError(null,"String_Node_Str","String_Node_Str");
}

Fixed version (ground truth):
private void showError(String detailedMessage){
  ErrorDialogWidthDetailArea dialog=new ErrorDialogWidthDetailArea(null,XmlMapPlugin.PLUGIN_ID,"String_Node_Str",detailedMessage,IStatus.ERROR);
}
Program: 122084
Project: 122084
Buggy source:
protected boolean isSelectionValid(SelectionChangedEvent event){
  boolean highlightOKButton=true;
  IStructuredSelection selection=(IStructuredSelection)event.getSelection();
  if (selection == null || selection.size() != 1) {
    highlightOKButton=false;
  }
 else {
    RepositoryNode node=(RepositoryNode)selection.getFirstElement();
    if (node.getObject() == null || node.getObject().getProperty() == null) {
      return false;
    }
    Item item=node.getObject().getProperty().getItem();
    if (item instanceof XmlFileConnectionItem) {
      ERepositoryObjectType t=(ERepositoryObjectType)node.getProperties(EProperties.CONTENT_TYPE);
      if (node.getType() != ENodeType.REPOSITORY_ELEMENT) {
        highlightOKButton=false;
      }
    }
 else     if (item instanceof MDMConnectionItem) {
      if (node.getObject() instanceof MetadataTable) {
        highlightOKButton=true;
        updateErrorMessage(null);
      }
 else {
        highlightOKButton=false;
        updateErrorMessage(Messages.getString("String_Node_Str"));
      }
    }
  }
  return highlightOKButton;
}

Fixed version (ground truth):
@Override protected boolean isSelectionValid(SelectionChangedEvent event){
  boolean highlightOKButton=true;
  IStructuredSelection selection=(IStructuredSelection)event.getSelection();
  if (selection == null || selection.size() != 1) {
    highlightOKButton=false;
  }
 else {
    RepositoryNode node=(RepositoryNode)selection.getFirstElement();
    if (node.getObject() == null || node.getObject().getProperty() == null) {
      return false;
    }
    if (node.getObject() instanceof Folder) {
      return false;
    }
    Item item=node.getObject().getProperty().getItem();
    if (item instanceof XmlFileConnectionItem) {
      ERepositoryObjectType t=(ERepositoryObjectType)node.getProperties(EProperties.CONTENT_TYPE);
      if (node.getType() != ENodeType.REPOSITORY_ELEMENT) {
        highlightOKButton=false;
      }
    }
 else     if (item instanceof MDMConnectionItem) {
      if (node.getObject() instanceof MetadataTable) {
        highlightOKButton=true;
        updateErrorMessage(null);
      }
 else {
        highlightOKButton=false;
        updateErrorMessage(Messages.getString("String_Node_Str"));
      }
    }
  }
  return highlightOKButton;
}
Program: 122085
Project: 122085
Buggy source:
public void treeExpanded(TreeExpansionEvent event){
  refreshCheckedTreeView();
}

Fixed version (ground truth):
public void treeExpanded(TreeExpansionEvent event){
}
Program: 122092
Project: 122092
Buggy source:
@Override public void keyDown(org.eclipse.swt.events.KeyEvent keyEvent,EditPartViewer viewer){
  int keyCode=keyEvent.keyCode;
  if (keyEvent.stateMask == SWT.CTRL && (keyCode == SWT.ARROW_UP || keyCode == SWT.ARROW_DOWN || keyCode == SWT.ARROW_LEFT || keyCode == SWT.ARROW_RIGHT)) {
    List<EditPart> parts=viewer.getSelectedEditParts();
    if (parts == null) {
      return;
    }
    for (    EditPart part : parts) {
      if (part instanceof NodePart) {
        Node node=(Node)part.getModel();
        if (node != null) {
          moveShape(keyCode,node,moveOffset);
        }
      }
    }
    moveOffset++;
  }
 else {
    super.keyDown(keyEvent,viewer);
  }
}

Fixed version (ground truth):
@Override public void keyDown(org.eclipse.swt.events.KeyEvent keyEvent,EditPartViewer viewer){
  int keyCode=keyEvent.keyCode;
  if (selectedConnectionPart != null) {
    if (selectedConnectionPart != null) {
      CreateComponentOnLinkHelper.unselectConnection(selectedConnectionPart);
    }
    selectedConnectionPart=null;
  }
 else   if (keyEvent.stateMask == SWT.CTRL && (keyCode == SWT.ARROW_UP || keyCode == SWT.ARROW_DOWN || keyCode == SWT.ARROW_LEFT || keyCode == SWT.ARROW_RIGHT)) {
    List<EditPart> parts=viewer.getSelectedEditParts();
    if (parts == null) {
      return;
    }
    for (    EditPart part : parts) {
      if (part instanceof NodePart) {
        Node node=(Node)part.getModel();
        if (node != null) {
          moveShape(keyCode,node,moveOffset);
        }
      }
    }
    moveOffset++;
  }
 else {
    super.keyDown(keyEvent,viewer);
  }
}
Program: 122093
Project: 122093
Buggy source:
public static void selectConnection(Connection connection,SubjobContainerPart containerPart){
  List children=containerPart.getChildren();
  for (int i=0; i < children.size(); i++) {
    Object object=children.get(i);
    if (object instanceof NodeContainerPart) {
      NodeContainerPart nodeContainerPart=(NodeContainerPart)object;
      Object nodePart=nodeContainerPart.getChildren().get(0);
      if (nodePart instanceof NodePart) {
        List sourceConnections=((NodePart)nodePart).getSourceConnections();
        for (int j=0; j < sourceConnections.size(); j++) {
          Object connectionPart=sourceConnections.get(j);
          if (connectionPart instanceof ConnectionPart) {
            ConnectionPart connPart=(ConnectionPart)connectionPart;
            org.talend.designer.core.ui.editor.connections.Connection conn=(org.talend.designer.core.ui.editor.connections.Connection)connPart.getModel();
            if (conn.equals(connection)) {
              ConnectionFigure fig=(ConnectionFigure)connPart.getFigure();
              if (fig.getLineWidth() != 2) {
                fig.setLineWidth(2);
                connPart.refresh();
                setSelectedConnection(connection);
              }
            }
 else {
              ConnectionFigure fig=(ConnectionFigure)connPart.getFigure();
              if (fig.getLineWidth() != 1) {
                fig.setLineWidth(1);
                connPart.refresh();
              }
            }
          }
        }
      }
    }
  }
}

Fixed version (ground truth):
public static void selectConnection(ConnectionPart connPart){
  ConnectionFigure fig=(ConnectionFigure)connPart.getFigure();
  if (fig.getLineWidth() != 2) {
    fig.setLineWidth(2);
    connPart.refresh();
  }
}
Program: 122094
Project: 122094
Buggy source:
public static void unselectAllConnections(SubjobContainerPart containerPart){
  setSelectedConnection(null);
  List children=((SubjobContainerPart)containerPart).getChildren();
  for (int i=0; i < children.size(); i++) {
    Object object=children.get(i);
    if (object instanceof NodeContainerPart) {
      NodeContainerPart nodeContainerPart=(NodeContainerPart)object;
      Object nodePart=nodeContainerPart.getChildren().get(0);
      if (nodePart instanceof NodePart) {
        List sourceConnections=((NodePart)nodePart).getSourceConnections();
        for (int j=0; j < sourceConnections.size(); j++) {
          Object connectionPart=sourceConnections.get(j);
          if (connectionPart instanceof ConnectionPart) {
            ConnectionPart connPart=(ConnectionPart)connectionPart;
            org.talend.designer.core.ui.editor.connections.Connection conn=(org.talend.designer.core.ui.editor.connections.Connection)connPart.getModel();
            ConnectionFigure fig=(ConnectionFigure)connPart.getFigure();
            if (fig.getLineWidth() != 1) {
              fig.setLineWidth(1);
              connPart.refresh();
            }
          }
        }
      }
    }
  }
}

Fixed version (ground truth):
public static void unselectAllConnections(ProcessPart processPart){
  for (  Object child : processPart.getChildren()) {
    if (child instanceof SubjobContainerPart) {
      SubjobContainerPart subJobPart=(SubjobContainerPart)child;
      for (      Object sChilde : subJobPart.getChildren()) {
        if (sChilde instanceof NodeContainerPart) {
          NodeContainerPart nodeCPart=(NodeContainerPart)sChilde;
          for (          Object nChild : nodeCPart.getChildren()) {
            if (nChild instanceof NodePart) {
              for (              Object conn : ((NodePart)nChild).getTargetConnections()) {
                if (conn instanceof ConnectionPart) {
                  unselectConnection((ConnectionPart)conn);
                }
              }
            }
          }
        }
      }
    }
  }
}
Program: 122097
Project: 122097
Buggy source:
public void dragEnter(final DropTargetEvent event){
}

Fixed version (ground truth):
@Override public void dragEnter(final DropTargetEvent event){
}
Program: 122103
Project: 122103
Buggy source:
public void widgetDisposed(DisposeEvent e){
  if (res != null && !res.isDisposed()) {
    res.dispose();
  }
  parent.removeDisposeListener(this);
}

Fixed version (ground truth):
@Override public void widgetDisposed(DisposeEvent e){
  if (res != null && !res.isDisposed()) {
    res.dispose();
  }
  parent.removeDisposeListener(this);
}
Program: 122104
Project: 122104
Buggy source:
public void focusGained(FocusEvent event){
  focusGainedExecute((Control)event.widget);
}

Fixed version (ground truth):
@Override public void focusGained(FocusEvent event){
  focusGainedExecute((Control)event.widget);
}
Program: 122105
Project: 122105
Buggy source:
public void keyPressed(KeyEvent event){
  Control control=(Control)event.widget;
  resetErrorState(control);
}

Fixed version (ground truth):
@Override public void keyPressed(KeyEvent event){
  Control control=(Control)event.widget;
  resetErrorState(control);
}
Program: 122106
Project: 122106
Buggy source:
private String getParameterValueWithContext(IElement elem,String key,IContext context){
  if (elem == null || key == null)   return "String_Node_Str";
  String actualKey=this.getParaNameFromRepositoryName(key);
  if (actualKey != null) {
    return fetchElementParameterValue(elem,context,actualKey);
  }
 else {
    return fetchElementParameterValue(elem,context,key);
  }
}

Fixed version (ground truth):
private String getParameterValueWithContext(IElement elem,String key,IContext context){
  if (elem == null || key == null) {
    return "String_Node_Str";
  }
  String actualKey=this.getParaNameFromRepositoryName(key);
  if (actualKey != null) {
    return fetchElementParameterValue(elem,context,actualKey);
  }
 else {
    return fetchElementParameterValue(elem,context,key);
  }
}
Program: 122107
Project: 122107
Buggy source:
public void dragLeave(final DropTargetEvent event){
}

Fixed version (ground truth):
@Override public void dragLeave(final DropTargetEvent event){
}
Program: 122108
Project: 122108
Buggy source:
public void drop(final DropTargetEvent event){
  if (propertyName != null) {
    String text;
    if (textControl instanceof StyledText) {
      text=((StyledText)textControl).getText() + (String)event.data;
      ((StyledText)textControl).setText(text);
    }
 else {
      text=((Text)textControl).getText() + (String)event.data;
      ((Text)textControl).setText(text);
    }
    Command cmd=new PropertyChangeCommand(elem,propertyName,text);
    executeCommand(cmd);
  }
}

Fixed version (ground truth):
@Override public void drop(final DropTargetEvent event){
  if (propertyName != null) {
    String text;
    if (textControl instanceof StyledText) {
      text=((StyledText)textControl).getText() + (String)event.data;
      ((StyledText)textControl).setText(text);
    }
 else {
      text=((Text)textControl).getText() + (String)event.data;
      ((Text)textControl).setText(text);
    }
    Command cmd=new PropertyChangeCommand(elem,propertyName,text);
    executeCommand(cmd);
  }
}
Program: 122109
Project: 122109
Buggy source:
public void dropAccept(final DropTargetEvent event){
}

Fixed version (ground truth):
@Override public void dropAccept(final DropTargetEvent event){
}
Program: 122111
Project: 122111
Buggy source:
public void proposalAccepted(IContentProposal proposal){
  if (control instanceof Text) {
    ContextParameterExtractor.saveContext(parameterName,elem,((Text)control).getText(),process);
  }
 else   if (control instanceof StyledText) {
    ContextParameterExtractor.saveContext(parameterName,elem,((StyledText)control).getText(),process);
  }
}

Fixed version (ground truth):
@Override public void proposalAccepted(IContentProposal proposal){
  if (control instanceof Text) {
    ContextParameterExtractor.saveContext(parameterName,elem,((Text)control).getText(),process);
  }
 else   if (control instanceof StyledText) {
    ContextParameterExtractor.saveContext(parameterName,elem,((StyledText)control).getText(),process);
  }
}
Program: 122112
Project: 122112
Buggy source:
public void keyReleased(KeyEvent e){
}

Fixed version (ground truth):
@Override public void keyReleased(KeyEvent e){
}
Program: 122113
Project: 122113
Buggy source:
/** 
 * cli Comment method "addResourceDisposeListener". When dispose the control, dispose resource at the same time. (bug 6916)
 */
protected void addResourceDisposeListener(final Control parent,final Resource res){
  if (parent != null) {
    parent.addDisposeListener(new DisposeListener(){
      public void widgetDisposed(      DisposeEvent e){
        if (res != null && !res.isDisposed()) {
          res.dispose();
        }
        parent.removeDisposeListener(this);
      }
    }
);
  }
}

Fixed version (ground truth):
/** 
 * cli Comment method "addResourceDisposeListener". When dispose the control, dispose resource at the same time. (bug 6916)
 */
protected void addResourceDisposeListener(final Control parent,final Resource res){
  if (parent != null) {
    parent.addDisposeListener(new DisposeListener(){
      @Override public void widgetDisposed(      DisposeEvent e){
        if (res != null && !res.isDisposed()) {
          res.dispose();
        }
        parent.removeDisposeListener(this);
      }
    }
);
  }
}
Program: 122114
Project: 122114
Buggy source:
private void refreshDynamicProperty(){
  if (this.dynamicProperty == null)   return;
  dynamicProperty.refresh();
}

Fixed version (ground truth):
private void refreshDynamicProperty(){
  if (this.dynamicProperty == null) {
    return;
  }
  dynamicProperty.refresh();
}
Program: 122115
Project: 122115
Buggy source:
public void dragOperationChanged(final DropTargetEvent event){
}

Fixed version (ground truth):
@Override public void dragOperationChanged(final DropTargetEvent event){
}
Program: 122116
Project: 122116
Buggy source:
public void dragOver(final DropTargetEvent event){
  if (TextTransfer.getInstance().isSupportedType(event.currentDataType)) {
    propertyName=getParameterName(textControl);
    for (int i=0; i < elem.getElementParameters().size(); i++) {
      IElementParameter param=elem.getElementParameters().get(i);
      if (param.getName().equals(propertyName)) {
        if (param.isReadOnly()) {
          event.detail=DND.ERROR_INVALID_DATA;
        }
      }
    }
  }
}

Fixed version (ground truth):
@Override public void dragOver(final DropTargetEvent event){
  if (TextTransfer.getInstance().isSupportedType(event.currentDataType)) {
    propertyName=getParameterName(textControl);
    for (int i=0; i < elem.getElementParameters().size(); i++) {
      IElementParameter param=elem.getElementParameters().get(i);
      if (param.getName().equals(propertyName)) {
        if (param.isReadOnly()) {
          event.detail=DND.ERROR_INVALID_DATA;
        }
      }
    }
  }
}
Program: 122120
Project: 122120
Buggy source:
/** 
 * DOC amaumont Comment method "createComponents".
 */
private void createComponents(){
  setSimple(false);
  createMetadataEditorTab();
  createExpressionEditorTab();
  createSqlViewerTab();
  tabFolderEditors.addListener(SWT.Selection,new Listener(){
    public void handleEvent(    Event event){
      lastSelectedTab=tabFolderEditors.getSelectionIndex();
      mapperManager.getUiManager().refreshSqlExpression();
    }
  }
);
  tabFolderEditors.setSelection(0);
}

Fixed version (ground truth):
/** 
 * DOC amaumont Comment method "createComponents".
 */
private void createComponents(){
  setSimple(false);
  createMetadataEditorTab();
  createExpressionEditorTab();
  createSqlViewerTab();
  tabFolderEditors.addListener(SWT.Selection,new Listener(){
    @Override public void handleEvent(    Event event){
      lastSelectedTab=tabFolderEditors.getSelectionIndex();
      mapperManager.getUiManager().refreshSqlExpression();
    }
  }
);
  tabFolderEditors.setSelection(0);
}
Program: 122121
Project: 122121
Buggy source:
/** 
 * DOC amaumont Comment method "createMetadataEditor".
 */
private void createMetadataEditorTab(){
  CTabItem item=new CTabItem(tabFolderEditors,SWT.BORDER);
  item.setText(Messages.getString("String_Node_Str"));
  SashForm inOutMetaEditorContainer=new SashForm(tabFolderEditors,SWT.SMOOTH | SWT.HORIZONTAL | SWT.SHADOW_OUT);
  inOutMetaEditorContainer.setLayout(new RowLayout(SWT.HORIZONTAL));
  item.setControl(inOutMetaEditorContainer);
  CommandStack commandStack=mapperManager.getCommandStack();
  inputMetaEditor=new MetadataTableEditorView(inOutMetaEditorContainer,SWT.BORDER);
  inputMetaEditor.setShowDbTypeColumn(true,false,false);
  inputMetaEditor.setShowDbColumnName(false,false);
  inputMetaEditor.setShowPatternColumn(false);
  inputMetaEditor.setShowTalendTypeColumn(false);
  inputMetaEditor.initGraphicComponents();
  inputMetaEditor.getExtendedTableViewer().setCommandStack(commandStack);
  outputMetaEditor=new MetadataTableEditorView(inOutMetaEditorContainer,SWT.BORDER);
  outputMetaEditor.setShowDbTypeColumn(true,false,false);
  outputMetaEditor.setShowDbColumnName(false,false);
  outputMetaEditor.setShowTalendTypeColumn(false);
  outputMetaEditor.setShowPatternColumn(false);
  outputMetaEditor.initGraphicComponents();
  outputMetaEditor.getExtendedTableViewer().setCommandStack(commandStack);
}

Fixed version (ground truth):
/** 
 * DOC amaumont Comment method "createMetadataEditor".
 */
private void createMetadataEditorTab(){
  CTabItem item=new CTabItem(tabFolderEditors,SWT.BORDER);
  item.setText(Messages.getString("String_Node_Str"));
  SashForm inOutMetaEditorContainer=new SashForm(tabFolderEditors,SWT.SMOOTH | SWT.HORIZONTAL | SWT.SHADOW_OUT);
  inOutMetaEditorContainer.setLayout(new RowLayout(SWT.HORIZONTAL));
  item.setControl(inOutMetaEditorContainer);
  CommandStack commandStack=mapperManager.getCommandStack();
  inputMetaEditor=new MetadataTableEditorView(inOutMetaEditorContainer,SWT.BORDER);
  inputMetaEditor.setShowDbTypeColumn(true,false,false);
  inputMetaEditor.setShowDbColumnName(true,false);
  inputMetaEditor.setShowPatternColumn(false);
  inputMetaEditor.setShowTalendTypeColumn(false);
  inputMetaEditor.initGraphicComponents();
  inputMetaEditor.getExtendedTableViewer().setCommandStack(commandStack);
  outputMetaEditor=new MetadataTableEditorView(inOutMetaEditorContainer,SWT.BORDER);
  outputMetaEditor.setShowDbTypeColumn(true,false,false);
  outputMetaEditor.setShowDbColumnName(true,false);
  outputMetaEditor.setShowTalendTypeColumn(false);
  outputMetaEditor.setShowPatternColumn(false);
  outputMetaEditor.initGraphicComponents();
  outputMetaEditor.getExtendedTableViewer().setCommandStack(commandStack);
}
Program: 122122
Project: 122122
Buggy source:
public void handleEvent(Event event){
  lastSelectedTab=tabFolderEditors.getSelectionIndex();
  mapperManager.getUiManager().refreshSqlExpression();
}

Fixed version (ground truth):
@Override public void handleEvent(Event event){
  lastSelectedTab=tabFolderEditors.getSelectionIndex();
  mapperManager.getUiManager().refreshSqlExpression();
}
Program: 122126
Project: 122126
Buggy source:
public String getDialogTitle(){
  return Messages.getString("String_Node_Str");
}

Fixed version (ground truth):
@Override public String getDialogTitle(){
  return Messages.getString("String_Node_Str");
}
Program: 122127
Project: 122127
Buggy source:
protected boolean selectRepositoryNode(Viewer viewer,RepositoryNode parentNode,RepositoryNode node){
  if (super.selectRepositoryNode(viewer,parentNode,node)) {
    IRepositoryViewObject object=node.getObject();
    if (object != null) {
      if (object instanceof Query) {
        return false;
      }
    }
    return true;
  }
  return false;
}

Fixed version (ground truth):
@Override protected boolean selectRepositoryNode(Viewer viewer,RepositoryNode parentNode,RepositoryNode node){
  if (super.selectRepositoryNode(viewer,parentNode,node)) {
    IRepositoryViewObject object=node.getObject();
    if (object != null) {
      if (object instanceof Query) {
        return false;
      }
    }
    return true;
  }
  return false;
}
Program: 122128
Project: 122128
Buggy source:
/** 
 * Added by Marvin Wang on Jun 19, 2012 for filtering the columns, do not show columns in tree. Refer to the subtask TDI-21657.
 * @param node
 * @return
 */
private boolean filterColumnFolderAndColumns(RepositoryNode node){
  if (node.getObject() != null && node.getObject() instanceof MetadataColumnRepositoryObject)   return false;
  if (node.getObject() == null) {
    List<IRepositoryNode> nodes=node.getChildren();
    if (nodes != null && nodes.size() > 0) {
      for (      IRepositoryNode child : nodes) {
        if (child.getObject() instanceof MetadataColumnRepositoryObject) {
          return false;
        }
      }
    }
  }
  return true;
}

Fixed version (ground truth):
/** 
 * Added by Marvin Wang on Jun 19, 2012 for filtering the columns, do not show columns in tree. Refer to the subtask TDI-21657.
 * @param node
 * @return
 */
private boolean filterColumnFolderAndColumns(RepositoryNode node){
  if (node.getObject() != null && node.getObject() instanceof MetadataColumnRepositoryObject) {
    return false;
  }
  if (node.getObject() == null) {
    List<IRepositoryNode> nodes=node.getChildren();
    if (nodes != null && nodes.size() > 0) {
      for (      IRepositoryNode child : nodes) {
        if (child.getObject() instanceof MetadataColumnRepositoryObject) {
          return false;
        }
      }
    }
  }
  return true;
}
Program: 122129
Project: 122129
Buggy source:
public boolean isSelectionValid(RepositoryNode node){
  if (node.getObject() instanceof Query) {
    return true;
  }
  return false;
}

Fixed version (ground truth):
@Override public boolean isSelectionValid(RepositoryNode node){
  if (node.getObject() instanceof Query) {
    return true;
  }
  return false;
}
Program: 122130
Project: 122130
Buggy source:
@Override protected List<ERepositoryObjectType> getTypes(){
  List<ERepositoryObjectType> types=new ArrayList<ERepositoryObjectType>();
  String[] repositoryTypes=getRepositoryTypes();
  if (repositoryTypes != null) {
    for (int i=0; i < repositoryTypes.length; i++) {
      if (ERepositoryCategoryType.XML.getName().equals(repositoryTypes[i])) {
        types.add(ERepositoryObjectType.METADATA_FILE_XML);
      }
 else       if (ERepositoryCategoryType.MDM.getName().equals(repositoryTypes[i])) {
        types.add(ERepositoryObjectType.METADATA_MDMCONNECTION);
      }
    }
  }
  return types;
}

Fixed version (ground truth):
@Override protected List<ERepositoryObjectType> getTypes(){
  List<ERepositoryObjectType> types=new ArrayList<ERepositoryObjectType>();
  String[] repositoryTypes=getRepositoryTypes();
  if (repositoryTypes != null) {
    for (    String repositoryType : repositoryTypes) {
      if (ERepositoryCategoryType.XML.getName().equals(repositoryType)) {
        types.add(ERepositoryObjectType.METADATA_FILE_XML);
      }
 else       if (ERepositoryCategoryType.MDM.getName().equals(repositoryType)) {
        types.add(ERepositoryObjectType.METADATA_MDMCONNECTION);
      }
    }
  }
  return types;
}
Program: 122133
Project: 122133
Buggy source:
@Override public void undo(){
  if (connection == null) {
    return;
  }
  connection.disconnect();
  INodeConnector nodeConnectorSource, nodeConnectorTarget;
  nodeConnectorSource=connection.getSourceNodeConnector();
  if (nodeConnectorSource != null) {
    nodeConnectorSource.setCurLinkNbOutput(nodeConnectorSource.getCurLinkNbOutput() - 1);
  }
  nodeConnectorTarget=connection.getTargetNodeConnector();
  if (nodeConnectorTarget != null) {
    nodeConnectorTarget.setCurLinkNbInput(nodeConnectorTarget.getCurLinkNbInput() - 1);
  }
  if (newMetadata != null) {
    source.getMetadataList().remove(newMetadata);
  }
  ((Process)source.getProcess()).checkStartNodes();
  source.checkAndRefreshNode();
  target.checkAndRefreshNode();
  connection=null;
}

Fixed version (ground truth):
@Override public void undo(){
  if (connection == null) {
    return;
  }
  connection.disconnect();
  INodeConnector nodeConnectorSource, nodeConnectorTarget;
  nodeConnectorSource=connection.getSourceNodeConnector();
  if (nodeConnectorSource != null) {
    nodeConnectorSource.setCurLinkNbOutput(nodeConnectorSource.getCurLinkNbOutput() - 1);
  }
  nodeConnectorTarget=connection.getTargetNodeConnector();
  if (nodeConnectorTarget != null) {
    nodeConnectorTarget.setCurLinkNbInput(nodeConnectorTarget.getCurLinkNbInput() - 1);
  }
  if (newMetadata != null) {
    source.getMetadataList().remove(newMetadata);
  }
  ((Process)source.getProcess()).checkStartNodes();
  source.checkAndRefreshNode();
  target.checkAndRefreshNode();
}