Program: 49891
Project: 49891
Buggy source:
@Test(timeout=120000L) public void testRestartClusterTwice() throws Exception {
  HazelcastInstance h1=Hazelcast.newHazelcastInstance(new Config());
  final ClientProperties clientProperties=ClientProperties.crateBaseClientProperties(GroupConfig.DEFAULT_GROUP_NAME,GroupConfig.DEFAULT_GROUP_PASSWORD);
  clientProperties.setPropertyValue(ClientPropertyName.INIT_CONNECTION_ATTEMPTS_LIMIT,"String_Node_Str");
  clientProperties.setPropertyValue(ClientPropertyName.RECONNECTION_ATTEMPTS_LIMIT,"String_Node_Str");
  clientProperties.setPropertyValue(ClientPropertyName.RECONNECTION_TIMEOUT,"String_Node_Str");
  HazelcastClient client=newHazelcastClient(clientProperties,h1);
  final IMap<String,String> map=client.getMap("String_Node_Str");
  final List<String> values=new ArrayList<String>();
  map.addEntryListener(new EntryAdapter<String,String>(){
    @Override public void entryAdded(    EntryEvent<String,String> event){
      values.add(event.getValue());
    }
    @Override public void entryUpdated(    EntryEvent<String,String> event){
      values.add(event.getValue());
    }
  }
,true);
  final BlockingQueue<LifecycleState> states=new LinkedBlockingQueue<LifecycleState>();
  client.getLifecycleService().addLifecycleListener(new LifecycleListener(){
    public void stateChanged(    LifecycleEvent event){
      states.add(event.getState());
    }
  }
);
  map.put("String_Node_Str","String_Node_Str");
  for (int i=0; i < 2; i++) {
    h1.getLifecycleService().shutdown();
    assertEquals(LifecycleState.CLIENT_CONNECTION_LOST,states.poll(500L,TimeUnit.MILLISECONDS));
    try {
      map.put("String_Node_Str","String_Node_Str" + i);
      fail();
    }
 catch (    NoMemberAvailableException e) {
    }
    Thread.sleep(50L);
    try {
      map.put("String_Node_Str","String_Node_Str" + i);
      fail();
    }
 catch (    NoMemberAvailableException e) {
    }
    Thread.sleep(50L);
    h1=Hazelcast.newHazelcastInstance(new Config());
    assertEquals(LifecycleState.CLIENT_CONNECTION_OPENING,states.poll(500L,TimeUnit.MILLISECONDS));
    assertEquals(LifecycleState.CLIENT_CONNECTION_OPENED,states.poll(1000L,TimeUnit.MILLISECONDS));
    map.put("String_Node_Str","String_Node_Str" + i);
    Thread.sleep(50L);
  }
  assertArrayEquals(values.toString(),new String[]{"String_Node_Str","String_Node_Str","String_Node_Str"},values.toArray(new String[0]));
}

Fixed version (ground truth):
@Test(timeout=120000L) public void testRestartClusterTwice() throws Exception {
  HazelcastInstance h1=Hazelcast.newHazelcastInstance(new Config());
  final ClientProperties clientProperties=ClientProperties.createBaseClientProperties(GroupConfig.DEFAULT_GROUP_NAME,GroupConfig.DEFAULT_GROUP_PASSWORD);
  clientProperties.setPropertyValue(ClientPropertyName.INIT_CONNECTION_ATTEMPTS_LIMIT,"String_Node_Str");
  clientProperties.setPropertyValue(ClientPropertyName.RECONNECTION_ATTEMPTS_LIMIT,"String_Node_Str");
  clientProperties.setPropertyValue(ClientPropertyName.RECONNECTION_TIMEOUT,"String_Node_Str");
  HazelcastClient client=newHazelcastClient(clientProperties,h1);
  final IMap<String,String> map=client.getMap("String_Node_Str");
  final List<String> values=new ArrayList<String>();
  map.addEntryListener(new EntryAdapter<String,String>(){
    @Override public void entryAdded(    EntryEvent<String,String> event){
      values.add(event.getValue());
    }
    @Override public void entryUpdated(    EntryEvent<String,String> event){
      values.add(event.getValue());
    }
  }
,true);
  final BlockingQueue<LifecycleState> states=new LinkedBlockingQueue<LifecycleState>();
  client.getLifecycleService().addLifecycleListener(new LifecycleListener(){
    public void stateChanged(    LifecycleEvent event){
      states.add(event.getState());
    }
  }
);
  map.put("String_Node_Str","String_Node_Str");
  for (int i=0; i < 2; i++) {
    h1.getLifecycleService().shutdown();
    assertEquals(LifecycleState.CLIENT_CONNECTION_LOST,states.poll(500L,TimeUnit.MILLISECONDS));
    try {
      map.put("String_Node_Str","String_Node_Str" + i);
      fail();
    }
 catch (    NoMemberAvailableException e) {
    }
    Thread.sleep(50L);
    try {
      map.put("String_Node_Str","String_Node_Str" + i);
      fail();
    }
 catch (    NoMemberAvailableException e) {
    }
    Thread.sleep(50L);
    h1=Hazelcast.newHazelcastInstance(new Config());
    assertEquals(LifecycleState.CLIENT_CONNECTION_OPENING,states.poll(500L,TimeUnit.MILLISECONDS));
    assertEquals(LifecycleState.CLIENT_CONNECTION_OPENED,states.poll(1000L,TimeUnit.MILLISECONDS));
    map.put("String_Node_Str","String_Node_Str" + i);
    Thread.sleep(50L);
  }
  assertArrayEquals(values.toString(),new String[]{"String_Node_Str","String_Node_Str","String_Node_Str"},values.toArray(new String[0]));
}