Program: 79383
Project: 79383
Buggy source:
protected void onServerPoolMemberChanged(final Entity member){
synchronized (mutex) {
    log.trace("String_Node_Str",new Object[]{this,member,member.getLocations()});
    Map<Entity,String> nodes=getAttribute(RIAK_CLUSTER_NODES);
    if (belongsInServerPool(member)) {
      if (nodes == null) {
        nodes=Maps.newLinkedHashMap();
      }
      String riakName=getRiakName(member);
      Preconditions.checkNotNull(riakName);
      Boolean firstNode=getAttribute(IS_FIRST_NODE_SET);
      if (!Boolean.TRUE.equals(firstNode)) {
        setAttribute(IS_FIRST_NODE_SET,Boolean.TRUE);
        nodes.put(member,riakName);
        setAttribute(RIAK_CLUSTER_NODES,nodes);
        ((EntityInternal)member).setAttribute(RiakNode.RIAK_NODE_HAS_JOINED_CLUSTER,Boolean.TRUE);
        log.info("String_Node_Str",new Object[]{this,member,getRiakName(member)});
      }
 else {
        Optional<Entity> anyNodeInCluster=Iterables.tryFind(nodes.keySet(),Predicates.and(Predicates.instanceOf(RiakNode.class),EntityPredicates.attributeEqualTo(RiakNode.RIAK_NODE_HAS_JOINED_CLUSTER,true)));
        if (anyNodeInCluster.isPresent()) {
          if (!nodes.containsKey(member) && member.getAttribute(RiakNode.RIAK_NODE_HAS_JOINED_CLUSTER) == null) {
            String anyNodeName=anyNodeInCluster.get().getAttribute(RiakNode.RIAK_NODE_NAME);
            Entities.invokeEffectorWithArgs(this,member,RiakNode.JOIN_RIAK_CLUSTER,anyNodeName).blockUntilEnded();
            if (getAttribute(IS_CLUSTER_INIT)) {
              Entities.invokeEffector(this,member,RiakNode.COMMIT_RIAK_CLUSTER).blockUntilEnded();
            }
            nodes.put(member,riakName);
            setAttribute(RIAK_CLUSTER_NODES,nodes);
            log.info("String_Node_Str",new Object[]{this,member,getRiakName(member)});
          }
        }
 else {
          log.error("String_Node_Str",member.getId());
        }
      }
    }
 else {
      if (nodes != null && nodes.containsKey(member)) {
        Optional<Entity> anyNodeInCluster=Iterables.tryFind(nodes.keySet(),Predicates.and(Predicates.instanceOf(RiakNode.class),EntityPredicates.attributeEqualTo(RiakNode.RIAK_NODE_HAS_JOINED_CLUSTER,true),Predicates.not(Predicates.equalTo(member))));
        if (anyNodeInCluster.isPresent()) {
          Entities.invokeEffectorWithArgs(this,anyNodeInCluster.get(),RiakNode.LEAVE_RIAK_CLUSTER,getRiakName(member)).blockUntilEnded();
        }
        nodes.remove(member);
        setAttribute(RIAK_CLUSTER_NODES,nodes);
        log.info("String_Node_Str",new Object[]{this,member,getRiakName(member)});
      }
    }
    ServiceNotUpLogic.updateNotUpIndicatorRequiringNonEmptyMap(this,RIAK_CLUSTER_NODES);
    calculateClusterAddresses();
  }
}

Fixed version (ground truth):
protected void onServerPoolMemberChanged(final Entity member){
synchronized (mutex) {
    log.trace("String_Node_Str",new Object[]{this,member,member.getLocations()});
    Map<Entity,String> nodes=getAttribute(RIAK_CLUSTER_NODES);
    if (belongsInServerPool(member)) {
      if (nodes == null) {
        nodes=Maps.newLinkedHashMap();
      }
      String riakName=getRiakName(member);
      Preconditions.checkNotNull(riakName);
      Boolean firstNode=getAttribute(IS_FIRST_NODE_SET);
      if (!Boolean.TRUE.equals(firstNode)) {
        setAttribute(IS_FIRST_NODE_SET,Boolean.TRUE);
        nodes.put(member,riakName);
        setAttribute(RIAK_CLUSTER_NODES,nodes);
        ((EntityInternal)member).setAttribute(RiakNode.RIAK_NODE_HAS_JOINED_CLUSTER,Boolean.TRUE);
        log.info("String_Node_Str",new Object[]{this,member,getRiakName(member)});
      }
 else {
        Optional<Entity> anyNodeInCluster=Iterables.tryFind(nodes.keySet(),Predicates.and(Predicates.instanceOf(RiakNode.class),EntityPredicates.attributeEqualTo(RiakNode.RIAK_NODE_HAS_JOINED_CLUSTER,true)));
        if (anyNodeInCluster.isPresent()) {
          if (!nodes.containsKey(member) && member.getAttribute(RiakNode.RIAK_NODE_HAS_JOINED_CLUSTER) == null) {
            String anyNodeName=anyNodeInCluster.get().getAttribute(RiakNode.RIAK_NODE_NAME);
            Entities.invokeEffectorWithArgs(this,member,RiakNode.JOIN_RIAK_CLUSTER,anyNodeName).blockUntilEnded();
            if (getAttribute(IS_CLUSTER_INIT)) {
              Entities.invokeEffector(this,member,RiakNode.COMMIT_RIAK_CLUSTER).blockUntilEnded();
            }
            nodes.put(member,riakName);
            setAttribute(RIAK_CLUSTER_NODES,nodes);
            log.info("String_Node_Str",new Object[]{this,member,getRiakName(member)});
          }
        }
 else {
          log.error("String_Node_Str",member.getId());
        }
      }
    }
 else {
      if (nodes != null && nodes.containsKey(member)) {
        boolean timeout=DependentConfiguration.attributeWhenReady(member,RiakNode.RIAK_NODE_HAS_JOINED_CLUSTER,Predicates.equalTo(false)).blockUntilEnded(Duration.TWO_MINUTES);
        Optional<Entity> anyNodeInCluster=Iterables.tryFind(nodes.keySet(),Predicates.and(Predicates.instanceOf(RiakNode.class),EntityPredicates.attributeEqualTo(RiakNode.RIAK_NODE_HAS_JOINED_CLUSTER,true),Predicates.not(Predicates.equalTo(member))));
        if (timeout && anyNodeInCluster.isPresent()) {
          Entities.invokeEffectorWithArgs(this,anyNodeInCluster.get(),RiakNode.REMOVE_FROM_CLUSTER,getRiakName(member)).blockUntilEnded();
        }
        nodes.remove(member);
        setAttribute(RIAK_CLUSTER_NODES,nodes);
        log.info("String_Node_Str",new Object[]{this,member,getRiakName(member)});
      }
    }
    ServiceNotUpLogic.updateNotUpIndicatorRequiringNonEmptyMap(this,RIAK_CLUSTER_NODES);
    calculateClusterAddresses();
  }
}