Program: 115444
Project: 115444
Buggy source:
public static void handleMemberActivated(InstanceActivatedEvent instanceActivatedEvent) throws RegistryException {
  Topology topology=TopologyHolder.getTopology();
  Service service=topology.getService(instanceActivatedEvent.getServiceName());
  if (service == null) {
    throw new RuntimeException(String.format("String_Node_Str",instanceActivatedEvent.getServiceName()));
  }
  Cluster cluster=service.getCluster(instanceActivatedEvent.getClusterId());
  if (cluster == null) {
    throw new RuntimeException(String.format("String_Node_Str",instanceActivatedEvent.getClusterId(),instanceActivatedEvent.getServiceName()));
  }
  String applicationId=service.getCluster(instanceActivatedEvent.getClusterId()).getAppId();
  String clusterAlias=CloudControllerUtil.getAliasFromClusterId(instanceActivatedEvent.getClusterId());
  Member member=cluster.getMember(instanceActivatedEvent.getMemberId());
  if (member == null) {
    throw new RuntimeException(String.format("String_Node_Str",instanceActivatedEvent.getMemberId()));
  }
  MemberActivatedEvent memberActivatedEvent=new MemberActivatedEvent(instanceActivatedEvent.getServiceName(),instanceActivatedEvent.getClusterId(),instanceActivatedEvent.getClusterInstanceId(),instanceActivatedEvent.getMemberId(),instanceActivatedEvent.getNetworkPartitionId(),instanceActivatedEvent.getPartitionId());
  memberActivatedEvent.setApplicationId(null);
  try {
    TopologyHolder.acquireWriteLock();
    if (!member.isStateTransitionValid(MemberStatus.Active)) {
      log.error("String_Node_Str" + member.getStatus() + "String_Node_Str"+ MemberStatus.Active+ "String_Node_Str");
    }
 else {
      member.setStatus(MemberStatus.Active);
      try {
        Cartridge cartridge=CloudControllerContext.getInstance().getCartridge(service.getServiceName());
        if (cartridge == null) {
          throw new RuntimeException(String.format("String_Node_Str",service.getServiceName()));
        }
        Port port;
        int portValue;
        List<PortMapping> portMappings=Arrays.asList(cartridge.getPortMappings());
        String clusterId=cluster.getClusterId();
        ClusterContext clusterContext=CloudControllerContext.getInstance().getClusterContext(clusterId);
        Collection<KubernetesService> kubernetesServices=clusterContext.getKubernetesServices(instanceActivatedEvent.getClusterInstanceId());
        for (        PortMapping portMapping : portMappings) {
          if (!kubernetesServices.isEmpty()) {
            portValue=findKubernetesServicePort(clusterId,kubernetesServices,portMapping);
          }
 else {
            portValue=portMapping.getPort();
          }
          port=new Port(portMapping.getProtocol(),portValue,portMapping.getProxyPort());
          member.addPort(port);
          memberActivatedEvent.addPort(port);
        }
      }
 catch (      Exception e) {
        String message=String.format("String_Node_Str",memberActivatedEvent.getServiceName(),memberActivatedEvent.getMemberId());
        log.error(message,e);
      }
      memberActivatedEvent.setDefaultPrivateIP(member.getDefaultPrivateIP());
      memberActivatedEvent.setMemberPrivateIPs(member.getMemberPrivateIPs());
      memberActivatedEvent.setDefaultPublicIP(member.getDefaultPublicIP());
      memberActivatedEvent.setMemberPublicIPs(member.getMemberPublicIPs());
      TopologyHolder.updateTopology(topology);
      Long timestamp=System.currentTimeMillis();
      TopologyEventPublisher.sendMemberActivatedEvent(memberActivatedEvent);
      MemberStatusPublisher memStatusPublisher=CloudControllerPublisherFactory.createMemberStatusPublisher(StatisticsPublisherType.WSO2DAS);
      if (memStatusPublisher.isEnabled()) {
        if (log.isDebugEnabled()) {
          log.debug("String_Node_Str");
        }
        memStatusPublisher.publish(timestamp,applicationId,memberActivatedEvent.getClusterId(),clusterAlias,memberActivatedEvent.getClusterInstanceId(),memberActivatedEvent.getServiceName(),memberActivatedEvent.getNetworkPartitionId(),memberActivatedEvent.getPartitionId(),memberActivatedEvent.getMemberId(),MemberStatus.Active.toString());
      }
 else {
        log.warn("String_Node_Str");
      }
    }
  }
  finally {
    TopologyHolder.releaseWriteLock();
  }
}

Fixed version (ground truth):
public static void handleMemberActivated(InstanceActivatedEvent instanceActivatedEvent) throws RegistryException {
  Topology topology=TopologyHolder.getTopology();
  Service service=topology.getService(instanceActivatedEvent.getServiceName());
  if (service == null) {
    throw new RuntimeException(String.format("String_Node_Str",instanceActivatedEvent.getServiceName()));
  }
  Cluster cluster=service.getCluster(instanceActivatedEvent.getClusterId());
  if (cluster == null) {
    throw new RuntimeException(String.format("String_Node_Str",instanceActivatedEvent.getClusterId(),instanceActivatedEvent.getServiceName()));
  }
  String applicationId=service.getCluster(instanceActivatedEvent.getClusterId()).getAppId();
  String clusterAlias=CloudControllerUtil.getAliasFromClusterId(instanceActivatedEvent.getClusterId());
  Member member=cluster.getMember(instanceActivatedEvent.getMemberId());
  if (member == null) {
    throw new RuntimeException(String.format("String_Node_Str",instanceActivatedEvent.getMemberId()));
  }
  MemberActivatedEvent memberActivatedEvent=new MemberActivatedEvent(instanceActivatedEvent.getServiceName(),instanceActivatedEvent.getClusterId(),instanceActivatedEvent.getClusterInstanceId(),instanceActivatedEvent.getMemberId(),instanceActivatedEvent.getNetworkPartitionId(),instanceActivatedEvent.getPartitionId());
  memberActivatedEvent.setApplicationId(null);
  try {
    TopologyHolder.acquireWriteLock();
    if (!member.isStateTransitionValid(MemberStatus.Active)) {
      log.error("String_Node_Str" + member.getStatus() + "String_Node_Str"+ MemberStatus.Active+ "String_Node_Str");
    }
 else {
      member.setStatus(MemberStatus.Active);
      try {
        Cartridge cartridge=CloudControllerContext.getInstance().getCartridge(service.getServiceName());
        if (cartridge == null) {
          throw new RuntimeException(String.format("String_Node_Str",service.getServiceName()));
        }
        Port port;
        int portValue;
        List<PortMapping> portMappings=Arrays.asList(cartridge.getPortMappings());
        String clusterId=cluster.getClusterId();
        ClusterContext clusterContext=CloudControllerContext.getInstance().getClusterContext(clusterId);
        Collection<KubernetesService> kubernetesServices=clusterContext.getKubernetesServices(instanceActivatedEvent.getClusterInstanceId());
        for (        PortMapping portMapping : portMappings) {
          if (!kubernetesServices.isEmpty()) {
            portValue=findKubernetesServicePort(clusterId,kubernetesServices,portMapping);
          }
 else {
            portValue=portMapping.getPort();
          }
          port=new Port(portMapping.getProtocol(),portValue,portMapping.getProxyPort());
          member.addPort(port);
          memberActivatedEvent.addPort(port);
        }
      }
 catch (      Exception e) {
        String message=String.format("String_Node_Str",memberActivatedEvent.getServiceName(),memberActivatedEvent.getMemberId());
        log.error(message,e);
      }
      memberActivatedEvent.setDefaultPrivateIP(member.getDefaultPrivateIP());
      memberActivatedEvent.setMemberPrivateIPs(member.getMemberPrivateIPs());
      memberActivatedEvent.setDefaultPublicIP(member.getDefaultPublicIP());
      memberActivatedEvent.setMemberPublicIPs(member.getMemberPublicIPs());
      TopologyHolder.updateTopology(topology);
      Long timestamp=System.currentTimeMillis();
      TopologyEventPublisher.sendMemberActivatedEvent(memberActivatedEvent);
      if (memStatusPublisher.isEnabled()) {
        if (log.isDebugEnabled()) {
          log.debug("String_Node_Str");
        }
        memStatusPublisher.publish(timestamp,applicationId,memberActivatedEvent.getClusterId(),clusterAlias,memberActivatedEvent.getClusterInstanceId(),memberActivatedEvent.getServiceName(),memberActivatedEvent.getNetworkPartitionId(),memberActivatedEvent.getPartitionId(),memberActivatedEvent.getMemberId(),MemberStatus.Active.toString());
      }
    }
  }
  finally {
    TopologyHolder.releaseWriteLock();
  }
}