Program: 47784
Project: 47784
Buggy source:
@Test public void testOutOfSyncMemberListTwoMasters() throws Exception {
  Config c1=buildConfig(false);
  Config c2=buildConfig(false);
  Config c3=buildConfig(false);
  c1.getNetworkConfig().setPort(35701);
  c2.getNetworkConfig().setPort(35702);
  c3.getNetworkConfig().setPort(35703);
  List<String> allMembers=Arrays.asList("String_Node_Str");
  c1.getNetworkConfig().getJoin().getTcpIpConfig().setMembers(allMembers);
  c2.getNetworkConfig().getJoin().getTcpIpConfig().setMembers(allMembers);
  c3.getNetworkConfig().getJoin().getTcpIpConfig().setMembers(allMembers);
  final HazelcastInstance h1=Hazelcast.newHazelcastInstance(c1);
  final HazelcastInstance h2=Hazelcast.newHazelcastInstance(c2);
  final HazelcastInstance h3=Hazelcast.newHazelcastInstance(c3);
  final MemberImpl m1=(MemberImpl)h1.getCluster().getLocalMember();
  final MemberImpl m2=(MemberImpl)h2.getCluster().getLocalMember();
  final MemberImpl m3=(MemberImpl)h3.getCluster().getLocalMember();
  assertEquals(3,h1.getCluster().getMembers().size());
  assertEquals(3,h2.getCluster().getMembers().size());
  assertEquals(3,h3.getCluster().getMembers().size());
  final Node n2=TestUtil.getNode(h2);
  List<MemberInfo> members=new ArrayList<MemberInfo>();
  members.add(new MemberInfo(m2.getAddress(),m2.getUuid(),Collections.<String,Object>emptyMap()));
  members.add(new MemberInfo(m3.getAddress(),m3.getUuid(),Collections.<String,Object>emptyMap()));
  members.add(new MemberInfo(m1.getAddress(),m1.getUuid(),Collections.<String,Object>emptyMap()));
  n2.clusterService.updateMembers(members);
  n2.setMasterAddress(m2.getAddress());
  Thread.sleep(30 * 1000);
  assertEquals(m1,h1.getCluster().getMembers().iterator().next());
  assertEquals(m1,h2.getCluster().getMembers().iterator().next());
  assertEquals(m1,h3.getCluster().getMembers().iterator().next());
  assertEquals(3,h1.getCluster().getMembers().size());
  assertEquals(3,h2.getCluster().getMembers().size());
  assertEquals(3,h3.getCluster().getMembers().size());
}

Fixed version (ground truth):
@Test public void testOutOfSyncMemberListTwoMasters() throws Exception {
  List<HazelcastInstance> instanceList=buildInstances(3,35701);
  final HazelcastInstance h1=instanceList.get(0);
  final HazelcastInstance h2=instanceList.get(1);
  final HazelcastInstance h3=instanceList.get(2);
  final MemberImpl m1=(MemberImpl)h1.getCluster().getLocalMember();
  final MemberImpl m2=(MemberImpl)h2.getCluster().getLocalMember();
  final MemberImpl m3=(MemberImpl)h3.getCluster().getLocalMember();
  assertEquals(3,h1.getCluster().getMembers().size());
  assertEquals(3,h2.getCluster().getMembers().size());
  assertEquals(3,h3.getCluster().getMembers().size());
  final Node n2=TestUtil.getNode(h2);
  List<MemberInfo> members=new ArrayList<MemberInfo>();
  members.add(new MemberInfo(m2.getAddress(),m2.getUuid(),Collections.<String,Object>emptyMap()));
  members.add(new MemberInfo(m3.getAddress(),m3.getUuid(),Collections.<String,Object>emptyMap()));
  members.add(new MemberInfo(m1.getAddress(),m1.getUuid(),Collections.<String,Object>emptyMap()));
  n2.clusterService.updateMembers(members);
  n2.setMasterAddress(m2.getAddress());
  Thread.sleep(30 * 1000);
  assertEquals(m1,h1.getCluster().getMembers().iterator().next());
  assertEquals(m1,h2.getCluster().getMembers().iterator().next());
  assertEquals(m1,h3.getCluster().getMembers().iterator().next());
  assertEquals(3,h1.getCluster().getMembers().size());
  assertEquals(3,h2.getCluster().getMembers().size());
  assertEquals(3,h3.getCluster().getMembers().size());
}