Program: 118100
Project: 118100
Buggy source:
public void checkLinks(){
  boolean isJoblet=false;
  if (PluginChecker.isJobLetPluginLoaded()) {
    IJobletProviderService service=(IJobletProviderService)GlobalServiceRegister.getDefault().getService(IJobletProviderService.class);
    if (service != null && service.isJobletComponent(this)) {
      isJoblet=true;
    }
  }
  if (!(Boolean)getPropertyValue(EParameterName.STARTABLE.getName())) {
    if ((getCurrentActiveLinksNbInput(EConnectionType.FLOW_MAIN) == 0) && (getConnectorFromType(EConnectionType.FLOW_MAIN).getMinLinkInput() == 0) & (getConnectorFromType(EConnectionType.FLOW_MAIN).getMaxLinkInput() != 0)) {
      String errorMessage=Messages.getString("String_Node_Str");
      Problems.add(ProblemStatus.WARNING,this,errorMessage);
    }
    if ((getCurrentActiveLinksNbInput(EConnectionType.FLOW_MAIN) == 0) && (getCurrentActiveLinksNbInput(EConnectionType.FLOW_REF) > 0)) {
      String errorMessage=Messages.getString("String_Node_Str");
      Problems.add(ProblemStatus.WARNING,this,errorMessage);
    }
  }
  if ((getConnectorFromType(EConnectionType.FLOW_MAIN).getMaxLinkInput() == 0) && (getConnectorFromType(EConnectionType.FLOW_MAIN).getMaxLinkOutput() != 0)) {
    if ((getCurrentActiveLinksNbOutput(EConnectionType.FLOW_MAIN) == 0) && (getCurrentActiveLinksNbOutput(EConnectionType.FLOW_MERGE) == 0) && (getCurrentActiveLinksNbOutput(EConnectionType.FLOW_REF) == 0)&& (getCurrentActiveLinksNbOutput(EConnectionType.ITERATE) == 0)) {
      String errorMessage=Messages.getString("String_Node_Str");
      Problems.add(ProblemStatus.WARNING,this,errorMessage);
    }
  }
  if (!isJoblet) {
    if (!isSubProcessStart() || (!(Boolean)getPropertyValue(EParameterName.STARTABLE.getName()))) {
      if ((getCurrentActiveLinksNbOutput(EConnectionType.ON_SUBJOB_OK) > 0) || getCurrentActiveLinksNbOutput(EConnectionType.ON_SUBJOB_ERROR) > 0) {
        String errorMessage=Messages.getString("String_Node_Str");
        Problems.add(ProblemStatus.ERROR,this,errorMessage);
      }
    }
    if ((!isELTComponent() && !isSubProcessStart()) || (!(Boolean)getPropertyValue(EParameterName.STARTABLE.getName()))) {
      if ((getCurrentActiveLinksNbInput(EConnectionType.ON_SUBJOB_OK) > 0) || (getCurrentActiveLinksNbInput(EConnectionType.RUN_IF) > 0) || (getCurrentActiveLinksNbInput(EConnectionType.ON_COMPONENT_OK) > 0)|| (getCurrentActiveLinksNbInput(EConnectionType.ON_COMPONENT_ERROR) > 0)|| (getCurrentActiveLinksNbInput(EConnectionType.STARTS) > 0)) {
        String errorMessage=Messages.getString("String_Node_Str");
        Problems.add(ProblemStatus.ERROR,this,errorMessage);
      }
    }
    if (isHL7Output()) {
      if (getIncomingConnections(EConnectionType.FLOW_MERGE).size() <= 0) {
        String errorMessage=Messages.getString("String_Node_Str");
        Problems.add(ProblemStatus.ERROR,this,errorMessage);
      }
 else {
        List<Map<String,String>> maps=(List<Map<String,String>>)ElementParameterParser.getObjectValue(this,"String_Node_Str");
        List<IMetadataTable> tables=this.getMetadataList();
        for (        IConnection connection : getIncomingConnections(EConnectionType.FLOW_MERGE)) {
          IMetadataTable metadataTable=connection.getMetadataTable();
          String rowName=connection.getUniqueName();
          String schemaName=null;
          for (          Map<String,String> map : maps) {
            if (map.containsValue(rowName)) {
              if (map.get("String_Node_Str") != null && map.get("String_Node_Str").equals(rowName)) {
                schemaName=map.get("String_Node_Str");
                break;
              }
            }
          }
          for (          IMetadataTable nodeTable : tables) {
            if (nodeTable.getTableName() != null && nodeTable.getTableName().equals(schemaName)) {
              if (!metadataTable.sameMetadataAs(nodeTable,IMetadataColumn.OPTIONS_NONE)) {
                String errorMessage=Messages.getString("String_Node_Str");
                Problems.add(ProblemStatus.ERROR,this,errorMessage);
              }
            }
          }
        }
      }
    }
    if (checkNodeCircle(this)) {
      String errorMessage=Messages.getString("String_Node_Str");
      Problems.add(ProblemStatus.ERROR,this,errorMessage);
    }
  }
  int tableOutLinkNum=0;
  int tableRefOutLinkNum=0;
  List<? extends IConnection> tableOutLinks=this.getOutgoingConnections(EConnectionType.TABLE);
  if (null != tableOutLinks) {
    tableOutLinkNum=tableOutLinks.size();
  }
  List<? extends IConnection> tableRefOutLinks=this.getOutgoingConnections(EConnectionType.TABLE_REF);
  if (null != tableRefOutLinks) {
    tableRefOutLinkNum=tableRefOutLinks.size();
  }
  int tableInLinkNum=0;
  int tableRefInLinkNum=0;
  List<? extends IConnection> tableInLinks=this.getIncomingConnections(EConnectionType.TABLE);
  if (null != tableInLinks) {
    tableInLinkNum=tableInLinks.size();
  }
  List<? extends IConnection> tableRefInLinks=this.getIncomingConnections(EConnectionType.TABLE_REF);
  if (null != tableRefInLinks) {
    tableRefInLinkNum=tableRefInLinks.size();
  }
  int jobletBuildConnectorNum=0;
  boolean subQueryMode=true;
  INodeConnector tableRefConnector=getConnectorFromType(EConnectionType.TABLE_REF);
  if (null != tableRefConnector) {
    if (tableRefConnector.getMaxLinkOutput() == 0) {
      subQueryMode=false;
    }
  }
  for (  INodeConnector nodeConnector : listConnector) {
    if (!nodeConnector.getDefaultConnectionType().hasConnectionCategory(IConnectionCategory.USE_HASH) && nodeConnector.getDefaultConnectionType() != EConnectionType.FLOW_MERGE) {
      boolean needCheckOutput=true;
      boolean needCheckInput=true;
      int nbMaxOut;
      nbMaxOut=nodeConnector.getMaxLinkOutput();
      int nbMaxIn;
      nbMaxIn=nodeConnector.getMaxLinkInput();
      int nbMinOut;
      nbMinOut=nodeConnector.getMinLinkOutput();
      int nbMinIn;
      nbMinIn=nodeConnector.getMinLinkInput();
      int curLinkOut;
      curLinkOut=nodeConnector.getCurLinkNbOutput();
      int curLinkIn;
      curLinkIn=nodeConnector.getCurLinkNbInput();
      String typeName=nodeConnector.getMenuName();
      boolean isCheckingTableLink=false;
      if (subQueryMode) {
        if (nodeConnector.getDefaultConnectionType() == EConnectionType.TABLE) {
          if (0 < tableRefOutLinkNum) {
            needCheckOutput=false;
            if (0 < tableOutLinkNum) {
              Object[] errorParams=new String[]{EConnectionType.TABLE.getDefaultMenuName(),EConnectionType.TABLE_REF.getDefaultMenuName()};
              String errorMessage=Messages.getString("String_Node_Str",errorParams);
              Problems.add(ProblemStatus.ERROR,this,errorMessage);
            }
          }
          if (0 < tableRefInLinkNum) {
            needCheckInput=false;
          }
          isCheckingTableLink=true;
          if (this.getComponent().getName().endsWith("String_Node_Str") && tableOutLinks != null) {
            for (            IConnection iconn : tableOutLinks) {
              INode newTarget=iconn.getTarget();
              if (newTarget.isELTComponent() && newTarget.getComponent().getName().endsWith("String_Node_Str")) {
                Object[] errorParams=new String[]{this.getLabel(),newTarget.getLabel(),EConnectionType.TABLE_REF.getDefaultMenuName()};
                String errorMessage=Messages.getString("String_Node_Str",errorParams);
                Problems.add(ProblemStatus.ERROR,this,errorMessage);
              }
            }
          }
        }
 else         if (nodeConnector.getDefaultConnectionType() == EConnectionType.TABLE_REF) {
          if (0 < tableOutLinkNum) {
            needCheckOutput=false;
            if (0 < tableRefOutLinkNum) {
              Object[] errorParams=new String[]{EConnectionType.TABLE.getDefaultMenuName(),EConnectionType.TABLE_REF.getDefaultMenuName()};
              String errorMessage=Messages.getString("String_Node_Str",errorParams);
              Problems.add(ProblemStatus.ERROR,this,errorMessage);
            }
          }
          if (0 < tableInLinkNum) {
            needCheckInput=false;
          }
          isCheckingTableLink=true;
        }
      }
      if (isCheckingTableLink) {
        typeName=EConnectionType.TABLE.getDefaultMenuName() + "String_Node_Str" + EConnectionType.TABLE_REF.getDefaultMenuName();
      }
      if (nodeConnector.getDefaultConnectionType() == EConnectionType.FLOW_MAIN) {
        typeName="String_Node_Str";
        if (isJoblet) {
          if (nodeConnector.isBuiltIn()) {
            jobletBuildConnectorNum++;
          }
          continue;
        }
      }
      if (needCheckOutput) {
        if (nbMaxOut != -1) {
          if (curLinkOut > nbMaxOut) {
            String errorMessage=Messages.getString("String_Node_Str",typeName);
            Problems.add(ProblemStatus.WARNING,this,errorMessage);
          }
        }
        if (nbMinOut != 0) {
          if (curLinkOut < nbMinOut) {
            String errorMessage=Messages.getString("String_Node_Str",typeName);
            Problems.add(ProblemStatus.WARNING,this,errorMessage);
          }
        }
      }
      if (!isJoblet) {
        if (nbMaxIn != -1) {
          if (curLinkIn > nbMaxIn) {
            String errorMessage=Messages.getString("String_Node_Str",typeName);
            Problems.add(ProblemStatus.WARNING,this,errorMessage);
          }
        }
        if (needCheckInput) {
          if (nbMinIn != 0) {
            if (curLinkIn < nbMinIn) {
              String errorMessage=Messages.getString("String_Node_Str",typeName);
              Problems.add(ProblemStatus.WARNING,this,errorMessage);
            }
          }
        }
      }
    }
  }
  if (isJoblet) {
    List<? extends IConnection> outgoingConnections=this.getOutgoingConnections(EConnectionType.FLOW_MAIN);
    for (    IConnection con : outgoingConnections) {
      INodeConnector connector=this.getConnectorFromName(con.getConnectorName());
      if (connector == null && con instanceof Connection) {
        ((Connection)con).disconnect();
      }
    }
    String typeName="String_Node_Str";
    outgoingConnections=this.getOutgoingConnections(EConnectionType.FLOW_MAIN);
    if (outgoingConnections.size() > jobletBuildConnectorNum) {
      String errorMessage=Messages.getString("String_Node_Str",typeName);
      Problems.add(ProblemStatus.WARNING,this,errorMessage);
    }
 else     if (outgoingConnections.size() < jobletBuildConnectorNum) {
      String errorMessage=Messages.getString("String_Node_Str",typeName);
      Problems.add(ProblemStatus.WARNING,this,errorMessage);
    }
  }
}

Fixed version (ground truth):
public void checkLinks(){
  boolean isJoblet=false;
  if (PluginChecker.isJobLetPluginLoaded()) {
    IJobletProviderService service=(IJobletProviderService)GlobalServiceRegister.getDefault().getService(IJobletProviderService.class);
    if (service != null && service.isJobletComponent(this)) {
      isJoblet=true;
    }
  }
  if (!(Boolean)getPropertyValue(EParameterName.STARTABLE.getName())) {
    if ((getCurrentActiveLinksNbInput(EConnectionType.FLOW_MAIN) == 0) && (getConnectorFromType(EConnectionType.FLOW_MAIN).getMinLinkInput() == 0) & (getConnectorFromType(EConnectionType.FLOW_MAIN).getMaxLinkInput() != 0)) {
      String errorMessage=Messages.getString("String_Node_Str");
      Problems.add(ProblemStatus.WARNING,this,errorMessage);
    }
    if ((getCurrentActiveLinksNbInput(EConnectionType.FLOW_MAIN) == 0) && (getCurrentActiveLinksNbInput(EConnectionType.FLOW_REF) > 0)) {
      String errorMessage=Messages.getString("String_Node_Str");
      Problems.add(ProblemStatus.WARNING,this,errorMessage);
    }
  }
  if ((getConnectorFromType(EConnectionType.FLOW_MAIN).getMaxLinkInput() == 0) && (getConnectorFromType(EConnectionType.FLOW_MAIN).getMaxLinkOutput() != 0)) {
    if ((getCurrentActiveLinksNbOutput(EConnectionType.FLOW_MAIN) == 0) && (getCurrentActiveLinksNbOutput(EConnectionType.FLOW_MERGE) == 0) && (getCurrentActiveLinksNbOutput(EConnectionType.FLOW_REF) == 0)&& (getCurrentActiveLinksNbOutput(EConnectionType.ITERATE) == 0)) {
      String errorMessage=Messages.getString("String_Node_Str");
      Problems.add(ProblemStatus.WARNING,this,errorMessage);
    }
  }
  if (!isJoblet) {
    if (!isSubProcessStart() || (!(Boolean)getPropertyValue(EParameterName.STARTABLE.getName()))) {
      if ((getCurrentActiveLinksNbOutput(EConnectionType.ON_SUBJOB_OK) > 0) || getCurrentActiveLinksNbOutput(EConnectionType.ON_SUBJOB_ERROR) > 0) {
        String errorMessage=Messages.getString("String_Node_Str");
        Problems.add(ProblemStatus.ERROR,this,errorMessage);
      }
    }
    if ((!isELTComponent() && !isSubProcessStart()) || (!(Boolean)getPropertyValue(EParameterName.STARTABLE.getName()))) {
      if ((getCurrentActiveLinksNbInput(EConnectionType.ON_SUBJOB_OK) > 0) || (getCurrentActiveLinksNbInput(EConnectionType.RUN_IF) > 0) || (getCurrentActiveLinksNbInput(EConnectionType.ON_COMPONENT_OK) > 0)|| (getCurrentActiveLinksNbInput(EConnectionType.ON_COMPONENT_ERROR) > 0)|| (getCurrentActiveLinksNbInput(EConnectionType.STARTS) > 0)) {
        String errorMessage=Messages.getString("String_Node_Str");
        Problems.add(ProblemStatus.ERROR,this,errorMessage);
      }
    }
    if (isHL7Output()) {
      if (getIncomingConnections(EConnectionType.FLOW_MERGE).size() <= 0) {
        String errorMessage=Messages.getString("String_Node_Str");
        Problems.add(ProblemStatus.ERROR,this,errorMessage);
      }
 else {
        List<Map<String,String>> maps=(List<Map<String,String>>)ElementParameterParser.getObjectValue(this,"String_Node_Str");
        List<IMetadataTable> tables=this.getMetadataList();
        for (        IConnection connection : getIncomingConnections(EConnectionType.FLOW_MERGE)) {
          IMetadataTable metadataTable=connection.getMetadataTable();
          String rowName=connection.getUniqueName();
          String schemaName=null;
          for (          Map<String,String> map : maps) {
            if (map.containsValue(rowName)) {
              if (map.get("String_Node_Str") != null && map.get("String_Node_Str").equals(rowName)) {
                schemaName=map.get("String_Node_Str");
                break;
              }
            }
          }
          for (          IMetadataTable nodeTable : tables) {
            if (nodeTable.getTableName() != null && nodeTable.getTableName().equals(schemaName)) {
              if (!metadataTable.sameMetadataAs(nodeTable,IMetadataColumn.OPTIONS_NONE)) {
                String errorMessage=Messages.getString("String_Node_Str");
                Problems.add(ProblemStatus.ERROR,this,errorMessage);
              }
            }
          }
        }
      }
    }
    if (checkNodeCircle(this)) {
      String errorMessage=Messages.getString("String_Node_Str");
      Problems.add(ProblemStatus.WARNING,this,errorMessage);
    }
  }
  int tableOutLinkNum=0;
  int tableRefOutLinkNum=0;
  List<? extends IConnection> tableOutLinks=this.getOutgoingConnections(EConnectionType.TABLE);
  if (null != tableOutLinks) {
    tableOutLinkNum=tableOutLinks.size();
  }
  List<? extends IConnection> tableRefOutLinks=this.getOutgoingConnections(EConnectionType.TABLE_REF);
  if (null != tableRefOutLinks) {
    tableRefOutLinkNum=tableRefOutLinks.size();
  }
  int tableInLinkNum=0;
  int tableRefInLinkNum=0;
  List<? extends IConnection> tableInLinks=this.getIncomingConnections(EConnectionType.TABLE);
  if (null != tableInLinks) {
    tableInLinkNum=tableInLinks.size();
  }
  List<? extends IConnection> tableRefInLinks=this.getIncomingConnections(EConnectionType.TABLE_REF);
  if (null != tableRefInLinks) {
    tableRefInLinkNum=tableRefInLinks.size();
  }
  int jobletBuildConnectorNum=0;
  boolean subQueryMode=true;
  INodeConnector tableRefConnector=getConnectorFromType(EConnectionType.TABLE_REF);
  if (null != tableRefConnector) {
    if (tableRefConnector.getMaxLinkOutput() == 0) {
      subQueryMode=false;
    }
  }
  for (  INodeConnector nodeConnector : listConnector) {
    if (!nodeConnector.getDefaultConnectionType().hasConnectionCategory(IConnectionCategory.USE_HASH) && nodeConnector.getDefaultConnectionType() != EConnectionType.FLOW_MERGE) {
      boolean needCheckOutput=true;
      boolean needCheckInput=true;
      int nbMaxOut;
      nbMaxOut=nodeConnector.getMaxLinkOutput();
      int nbMaxIn;
      nbMaxIn=nodeConnector.getMaxLinkInput();
      int nbMinOut;
      nbMinOut=nodeConnector.getMinLinkOutput();
      int nbMinIn;
      nbMinIn=nodeConnector.getMinLinkInput();
      int curLinkOut;
      curLinkOut=nodeConnector.getCurLinkNbOutput();
      int curLinkIn;
      curLinkIn=nodeConnector.getCurLinkNbInput();
      String typeName=nodeConnector.getMenuName();
      boolean isCheckingTableLink=false;
      if (subQueryMode) {
        if (nodeConnector.getDefaultConnectionType() == EConnectionType.TABLE) {
          if (0 < tableRefOutLinkNum) {
            needCheckOutput=false;
            if (0 < tableOutLinkNum) {
              Object[] errorParams=new String[]{EConnectionType.TABLE.getDefaultMenuName(),EConnectionType.TABLE_REF.getDefaultMenuName()};
              String errorMessage=Messages.getString("String_Node_Str",errorParams);
              Problems.add(ProblemStatus.ERROR,this,errorMessage);
            }
          }
          if (0 < tableRefInLinkNum) {
            needCheckInput=false;
          }
          isCheckingTableLink=true;
          if (this.getComponent().getName().endsWith("String_Node_Str") && tableOutLinks != null) {
            for (            IConnection iconn : tableOutLinks) {
              INode newTarget=iconn.getTarget();
              if (newTarget.isELTComponent() && newTarget.getComponent().getName().endsWith("String_Node_Str")) {
                Object[] errorParams=new String[]{this.getLabel(),newTarget.getLabel(),EConnectionType.TABLE_REF.getDefaultMenuName()};
                String errorMessage=Messages.getString("String_Node_Str",errorParams);
                Problems.add(ProblemStatus.ERROR,this,errorMessage);
              }
            }
          }
        }
 else         if (nodeConnector.getDefaultConnectionType() == EConnectionType.TABLE_REF) {
          if (0 < tableOutLinkNum) {
            needCheckOutput=false;
            if (0 < tableRefOutLinkNum) {
              Object[] errorParams=new String[]{EConnectionType.TABLE.getDefaultMenuName(),EConnectionType.TABLE_REF.getDefaultMenuName()};
              String errorMessage=Messages.getString("String_Node_Str",errorParams);
              Problems.add(ProblemStatus.ERROR,this,errorMessage);
            }
          }
          if (0 < tableInLinkNum) {
            needCheckInput=false;
          }
          isCheckingTableLink=true;
        }
      }
      if (isCheckingTableLink) {
        typeName=EConnectionType.TABLE.getDefaultMenuName() + "String_Node_Str" + EConnectionType.TABLE_REF.getDefaultMenuName();
      }
      if (nodeConnector.getDefaultConnectionType() == EConnectionType.FLOW_MAIN) {
        typeName="String_Node_Str";
        if (isJoblet) {
          if (nodeConnector.isBuiltIn()) {
            jobletBuildConnectorNum++;
          }
          continue;
        }
      }
      if (needCheckOutput) {
        if (nbMaxOut != -1) {
          if (curLinkOut > nbMaxOut) {
            String errorMessage=Messages.getString("String_Node_Str",typeName);
            Problems.add(ProblemStatus.WARNING,this,errorMessage);
          }
        }
        if (nbMinOut != 0) {
          if (curLinkOut < nbMinOut) {
            String errorMessage=Messages.getString("String_Node_Str",typeName);
            Problems.add(ProblemStatus.WARNING,this,errorMessage);
          }
        }
      }
      if (!isJoblet) {
        if (nbMaxIn != -1) {
          if (curLinkIn > nbMaxIn) {
            String errorMessage=Messages.getString("String_Node_Str",typeName);
            Problems.add(ProblemStatus.WARNING,this,errorMessage);
          }
        }
        if (needCheckInput) {
          if (nbMinIn != 0) {
            if (curLinkIn < nbMinIn) {
              String errorMessage=Messages.getString("String_Node_Str",typeName);
              Problems.add(ProblemStatus.WARNING,this,errorMessage);
            }
          }
        }
      }
    }
  }
  if (isJoblet) {
    List<? extends IConnection> outgoingConnections=this.getOutgoingConnections(EConnectionType.FLOW_MAIN);
    for (    IConnection con : outgoingConnections) {
      INodeConnector connector=this.getConnectorFromName(con.getConnectorName());
      if (connector == null && con instanceof Connection) {
        ((Connection)con).disconnect();
      }
    }
    String typeName="String_Node_Str";
    outgoingConnections=this.getOutgoingConnections(EConnectionType.FLOW_MAIN);
    if (outgoingConnections.size() > jobletBuildConnectorNum) {
      String errorMessage=Messages.getString("String_Node_Str",typeName);
      Problems.add(ProblemStatus.WARNING,this,errorMessage);
    }
 else     if (outgoingConnections.size() < jobletBuildConnectorNum) {
      String errorMessage=Messages.getString("String_Node_Str",typeName);
      Problems.add(ProblemStatus.WARNING,this,errorMessage);
    }
  }
}