Program: 46080
Project: 46080
Buggy source:
@Test public void testClientConnectionEvents() throws InterruptedException {
  final LinkedList<LifecycleState> list=new LinkedList<LifecycleState>();
  list.offer(LifecycleState.STARTING);
  list.offer(LifecycleState.STARTED);
  list.offer(LifecycleState.CLIENT_CONNECTED);
  list.offer(LifecycleState.CLIENT_DISCONNECTED);
  list.offer(LifecycleState.CLIENT_CONNECTED);
  list.offer(LifecycleState.CLIENT_DISCONNECTED);
  list.offer(LifecycleState.SHUTTING_DOWN);
  list.offer(LifecycleState.SHUTDOWN);
  hazelcastFactory.newHazelcastInstance();
  final CountDownLatch latch=new CountDownLatch(list.size());
  final CountDownLatch connectedLatch=new CountDownLatch(2);
  final CountDownLatch disconnectedLatch=new CountDownLatch(2);
  LifecycleListener listener=new LifecycleListener(){
    public void stateChanged(    LifecycleEvent event){
      Logger.getLogger(getClass()).info("String_Node_Str" + event);
      final LifecycleState state=list.poll();
      LifecycleState eventState=event.getState();
      if (state != null && state.equals(eventState)) {
        latch.countDown();
      }
      if (LifecycleState.CLIENT_CONNECTED.equals(eventState)) {
        connectedLatch.countDown();
      }
      if (LifecycleState.CLIENT_DISCONNECTED.equals(eventState)) {
        disconnectedLatch.countDown();
      }
    }
  }
;
  final ListenerConfig listenerConfig=new ListenerConfig(listener);
  final ClientConfig clientConfig=new ClientConfig();
  clientConfig.addListenerConfig(listenerConfig);
  clientConfig.getNetworkConfig().setConnectionAttemptLimit(100);
  HazelcastInstance hazelcastClient=hazelcastFactory.newHazelcastClient(clientConfig);
  hazelcastFactory.shutdownAllMembers();
  hazelcastFactory.newHazelcastInstance();
  assertOpenEventually("String_Node_Str",connectedLatch);
  hazelcastFactory.shutdownAllMembers();
  assertOpenEventually("String_Node_Str",disconnectedLatch);
  hazelcastClient.shutdown();
  assertOpenEventually("String_Node_Str",latch);
}

Fixed version (ground truth):
@Test public void testClientConnectionEvents(){
  final LinkedList<LifecycleState> list=new LinkedList<LifecycleState>();
  list.offer(LifecycleState.STARTING);
  list.offer(LifecycleState.STARTED);
  list.offer(LifecycleState.CLIENT_CONNECTED);
  list.offer(LifecycleState.CLIENT_DISCONNECTED);
  list.offer(LifecycleState.CLIENT_CONNECTED);
  list.offer(LifecycleState.CLIENT_DISCONNECTED);
  list.offer(LifecycleState.SHUTTING_DOWN);
  list.offer(LifecycleState.SHUTDOWN);
  hazelcastFactory.newHazelcastInstance();
  final CountDownLatch latch=new CountDownLatch(list.size());
  final CountDownLatch connectedLatch=new CountDownLatch(2);
  final CountDownLatch disconnectedLatch=new CountDownLatch(2);
  LifecycleListener listener=new LifecycleListener(){
    public void stateChanged(    LifecycleEvent event){
      Logger.getLogger(getClass()).info("String_Node_Str" + event);
      final LifecycleState state=list.poll();
      LifecycleState eventState=event.getState();
      if (state != null && state.equals(eventState)) {
        latch.countDown();
      }
      if (LifecycleState.CLIENT_CONNECTED.equals(eventState)) {
        connectedLatch.countDown();
      }
      if (LifecycleState.CLIENT_DISCONNECTED.equals(eventState)) {
        disconnectedLatch.countDown();
      }
    }
  }
;
  final ListenerConfig listenerConfig=new ListenerConfig(listener);
  final ClientConfig clientConfig=new ClientConfig();
  clientConfig.addListenerConfig(listenerConfig);
  clientConfig.getNetworkConfig().setConnectionAttemptLimit(100);
  HazelcastInstance hazelcastClient=hazelcastFactory.newHazelcastClient(clientConfig);
  hazelcastFactory.shutdownAllMembers();
  hazelcastFactory.newHazelcastInstance();
  assertOpenEventually("String_Node_Str",connectedLatch);
  hazelcastFactory.shutdownAllMembers();
  assertOpenEventually("String_Node_Str",disconnectedLatch);
  hazelcastClient.shutdown();
  assertOpenEventually("String_Node_Str",latch);
}