Program: 124639
Project: 124639
Buggy source:
@Override public void setPropertiesForExistContextMode(Connection connection,Set<IConnParamName> paramSet,Map<ContextItem,List<ConectionAdaptContextVariableModel>> adaptMap){
  if (connection == null) {
    return;
  }
  if (connection instanceof NoSQLConnection) {
    NoSQLConnection noSqlConn=(NoSQLConnection)connection;
    ContextItem currentContext=null;
    for (    IConnParamName param : paramSet) {
      if (param instanceof EHadoopParamName) {
        String noSqlVariableName=null;
        EHadoopParamName noSqlParam=(EHadoopParamName)param;
        if (adaptMap != null && adaptMap.size() > 0) {
          for (          Map.Entry<ContextItem,List<ConectionAdaptContextVariableModel>> entry : adaptMap.entrySet()) {
            currentContext=entry.getKey();
            List<ConectionAdaptContextVariableModel> modelList=entry.getValue();
            for (            ConectionAdaptContextVariableModel model : modelList) {
              if (model.getValue().equals(noSqlParam.name())) {
                noSqlVariableName=model.getName();
                break;
              }
            }
          }
        }
        if (noSqlVariableName != null) {
          noSqlVariableName=getCorrectVariableName(currentContext,noSqlVariableName,noSqlParam);
          matchContextForAttribues(noSqlConn,noSqlParam,noSqlVariableName);
        }
      }
    }
  }
}

Fixed version (ground truth):
@Override public void setPropertiesForExistContextMode(Connection connection,Set<IConnParamName> paramSet,Map<ContextItem,List<ConectionAdaptContextVariableModel>> adaptMap){
  if (connection == null) {
    return;
  }
  if (connection instanceof NoSQLConnection) {
    NoSQLConnection noSqlConn=(NoSQLConnection)connection;
    ContextItem currentContext=null;
    for (    IConnParamName param : paramSet) {
      if (param instanceof EHadoopParamName) {
        String noSqlVariableName=null;
        EHadoopParamName noSqlParam=(EHadoopParamName)param;
        if (noSqlParam == EHadoopParamName.ReplicaSets) {
          String replicaSets=noSqlConn.getAttributes().get(IMongoDBAttributes.REPLICA_SET);
          try {
            JSONArray jsa=new JSONArray(replicaSets);
            for (int i=0; i < jsa.length(); i++) {
              JSONObject jso=jsa.getJSONObject(i);
              int paramNum=i + 1;
              String hostParamName=ExtendedNodeConnectionContextUtils.getReplicaParamName(EHadoopParamName.ReplicaHost,paramNum);
              String portParamName=ExtendedNodeConnectionContextUtils.getReplicaParamName(EHadoopParamName.ReplicaPort,paramNum);
              String hostVariableName=null;
              String portVariableName=null;
              if (adaptMap != null && adaptMap.size() > 0) {
                for (                Map.Entry<ContextItem,List<ConectionAdaptContextVariableModel>> entry : adaptMap.entrySet()) {
                  currentContext=entry.getKey();
                  List<ConectionAdaptContextVariableModel> modelList=entry.getValue();
                  for (                  ConectionAdaptContextVariableModel model : modelList) {
                    if (model.getValue().equals(hostParamName)) {
                      hostVariableName=model.getName();
                    }
 else                     if (model.getValue().equals(portParamName)) {
                      portVariableName=model.getName();
                    }
                    if (hostVariableName != null && portVariableName != null) {
                      break;
                    }
                  }
                }
              }
              if (hostVariableName != null && portVariableName != null) {
                hostVariableName=getCorrectVariableName(currentContext,hostVariableName,hostParamName);
                portVariableName=getCorrectVariableName(currentContext,portVariableName,portParamName);
                jso.put(IMongoConstants.REPLICA_HOST_KEY,ContextParameterUtils.getNewScriptCode(hostVariableName,LANGUAGE));
                jso.put(IMongoConstants.REPLICA_PORT_KEY,ContextParameterUtils.getNewScriptCode(portVariableName,LANGUAGE));
              }
            }
            noSqlConn.getAttributes().put(IMongoDBAttributes.REPLICA_SET,jsa.toString());
          }
 catch (          JSONException e) {
            ExceptionHandler.process(e);
          }
        }
 else {
          if (adaptMap != null && adaptMap.size() > 0) {
            for (            Map.Entry<ContextItem,List<ConectionAdaptContextVariableModel>> entry : adaptMap.entrySet()) {
              currentContext=entry.getKey();
              List<ConectionAdaptContextVariableModel> modelList=entry.getValue();
              for (              ConectionAdaptContextVariableModel model : modelList) {
                if (model.getValue().equals(noSqlParam.name())) {
                  noSqlVariableName=model.getName();
                  break;
                }
              }
            }
          }
          if (noSqlVariableName != null) {
            noSqlVariableName=getCorrectVariableName(currentContext,noSqlVariableName,noSqlParam);
            matchContextForAttribues(noSqlConn,noSqlParam,noSqlVariableName);
          }
        }
      }
    }
  }
}