Program: 115994
Project: 115994
Buggy source:
/** 
 * Add member object to the topology and publish member created event
 * @param memberContext
 */
public static void handleMemberCreatedEvent(MemberContext memberContext){
  Topology topology=TopologyManager.getTopology();
  Service service=topology.getService(memberContext.getCartridgeType());
  String clusterId=memberContext.getClusterId();
  Cluster cluster=service.getCluster(clusterId);
  String memberId=memberContext.getMemberId();
  String clusterInstanceId=memberContext.getClusterInstanceId();
  String networkPartitionId=memberContext.getNetworkPartitionId();
  String partitionId=memberContext.getPartition().getId();
  String lbClusterId=memberContext.getLbClusterId();
  long initTime=memberContext.getInitTime();
  if (cluster.memberExists(memberId)) {
    log.warn(String.format("String_Node_Str",memberId));
    return;
  }
  try {
    TopologyManager.acquireWriteLock();
    Member member=new Member(service.getServiceName(),clusterId,memberId,clusterInstanceId,networkPartitionId,partitionId,initTime);
    member.setStatus(MemberStatus.Created);
    member.setLbClusterId(lbClusterId);
    member.setProperties(CloudControllerUtil.toJavaUtilProperties(memberContext.getProperties()));
    try {
      Cartridge cartridge=CloudControllerContext.getInstance().getCartridge(service.getServiceName());
      List<PortMapping> portMappings=cartridge.getPortMappings();
      Port port;
      if (cluster.isKubernetesCluster()) {
        ClusterContext clusterContext=CloudControllerContext.getInstance().getClusterContext(clusterId);
        if (clusterContext == null) {
          log.warn("String_Node_Str" + clusterId);
        }
 else {
          List<org.apache.stratos.kubernetes.client.model.Service> services=clusterContext.getKubernetesServices();
          if (services == null) {
            log.warn("String_Node_Str" + "String_Node_Str" + clusterId);
          }
 else {
            for (            PortMapping portMapping : portMappings) {
              port=new Port(portMapping.getProtocol(),findServicePort(clusterId,services,portMapping),Integer.parseInt(portMapping.getProxyPort()));
              member.addPort(port);
            }
          }
        }
      }
 else {
        for (        PortMapping portMapping : portMappings) {
          port=new Port(portMapping.getProtocol(),Integer.parseInt(portMapping.getPort()),Integer.parseInt(portMapping.getProxyPort()));
          member.addPort(port);
        }
      }
    }
 catch (    Exception e) {
      log.error("String_Node_Str" + memberId,e);
    }
    cluster.addMember(member);
    TopologyManager.updateTopology(topology);
  }
  finally {
    TopologyManager.releaseWriteLock();
  }
  TopologyEventPublisher.sendMemberCreatedEvent(memberContext);
}

Fixed version (ground truth):
/** 
 * Add member object to the topology and publish member created event
 * @param memberContext
 */
public static void handleMemberCreatedEvent(MemberContext memberContext){
  Topology topology=TopologyManager.getTopology();
  Service service=topology.getService(memberContext.getCartridgeType());
  String clusterId=memberContext.getClusterId();
  Cluster cluster=service.getCluster(clusterId);
  String memberId=memberContext.getMemberId();
  String clusterInstanceId=memberContext.getClusterInstanceId();
  String networkPartitionId=memberContext.getNetworkPartitionId();
  String partitionId=memberContext.getPartition().getId();
  String lbClusterId=memberContext.getLbClusterId();
  long initTime=memberContext.getInitTime();
  if (cluster.memberExists(memberId)) {
    log.warn(String.format("String_Node_Str",memberId));
    return;
  }
  try {
    TopologyManager.acquireWriteLock();
    Member member=new Member(service.getServiceName(),clusterId,memberId,clusterInstanceId,networkPartitionId,partitionId,initTime);
    member.setStatus(MemberStatus.Created);
    member.setLbClusterId(lbClusterId);
    member.setProperties(CloudControllerUtil.toJavaUtilProperties(memberContext.getProperties()));
    try {
      Cartridge cartridge=CloudControllerContext.getInstance().getCartridge(service.getServiceName());
      List<PortMapping> portMappings=cartridge.getPortMappings();
      Port port;
      if (cluster.isKubernetesCluster()) {
        ClusterContext clusterContext=CloudControllerContext.getInstance().getClusterContext(clusterId);
        if (clusterContext == null) {
          log.warn("String_Node_Str" + clusterId);
        }
 else {
          List<org.apache.stratos.kubernetes.client.model.Service> services=clusterContext.getKubernetesServices();
          if (services == null) {
            log.warn("String_Node_Str" + "String_Node_Str" + clusterId);
          }
 else {
            for (            PortMapping portMapping : portMappings) {
              port=new Port(portMapping.getProtocol(),findServicePort(clusterId,services,portMapping),portMapping.getProxyPort());
              member.addPort(port);
            }
          }
        }
      }
 else {
        for (        PortMapping portMapping : portMappings) {
          port=new Port(portMapping.getProtocol(),portMapping.getPort(),portMapping.getProxyPort());
          member.addPort(port);
        }
      }
    }
 catch (    Exception e) {
      log.error("String_Node_Str" + memberId,e);
    }
    cluster.addMember(member);
    TopologyManager.updateTopology(topology);
  }
  finally {
    TopologyManager.releaseWriteLock();
  }
  TopologyEventPublisher.sendMemberCreatedEvent(memberContext);
}