Program: 28989
Project: 28989
Buggy source:
private void initializeGMS() throws GMSException {
  Properties configProps=new Properties();
  int HA_MAX_GMS_MESSAGE_LENGTH=4 * (1024 * 1024) + (2 * 1024);
  configProps.put(ServiceProviderConfigurationKeys.MAX_MESSAGE_LENGTH.toString(),Integer.toString(HA_MAX_GMS_MESSAGE_LENGTH));
  readGMSConfigProps(configProps);
  printProps(configProps);
  String memberType=(String)configProps.get(MEMBERTYPE_STRING);
  gms=(GroupManagementService)GMSFactory.startGMSModule(instanceName,clusterName,GroupManagementService.MemberType.valueOf(memberType),configProps);
  GMSFactory.setGMSEnabledState(clusterName,Boolean.TRUE);
  if (gms != null) {
    try {
      registerJoinedAndReadyNotificationListener(this);
      registerJoinNotificationListener(this);
      registerFailureNotificationListener(this);
      registerPlannedShutdownListener(this);
      registerFailureSuspectedListener(this);
      if (testFailureRecoveryHandler && !env.isDas()) {
        registerFailureRecoveryListener("String_Node_Str",this);
      }
      glassfishEventListener=new org.glassfish.api.event.EventListener(){
        public void event(        Event event){
          if (gms == null) {
            return;
          }
          if (event.is(EventTypes.SERVER_SHUTDOWN)) {
            GMS_LOGGER.log(LogLevel.INFO,GMS_SERVER_SHUTDOWN_RECEIVED,new Object[]{gms.getInstanceName(),gms.getGroupName(),event.name()});
            removeJoinedAndReadyNotificationListener(GMSAdapterImpl.this);
            removeJoinNotificationListener(GMSAdapterImpl.this);
            removeFailureNotificationListener(GMSAdapterImpl.this);
            removeFailureSuspectedListener(GMSAdapterImpl.this);
            gms.shutdown(GMSConstants.shutdownType.INSTANCE_SHUTDOWN);
            removePlannedShutdownListener(GMSAdapterImpl.this);
            events.unregister(glassfishEventListener);
          }
 else           if (event.is(EventTypes.SERVER_READY)) {
            gms.reportJoinedAndReadyState();
          }
        }
      }
;
      events.register(glassfishEventListener);
      gms.join();
      joinTime=System.currentTimeMillis();
      GMS_LOGGER.log(LogLevel.INFO,GMS_JOINED,new Object[]{instanceName,clusterName});
    }
 catch (    GMSException e) {
      events.unregister(glassfishEventListener);
      throw e;
    }
    GMS_LOGGER.log(LogLevel.INFO,GMS_STARTED,new Object[]{instanceName,clusterName});
  }
 else   throw new GMSException("String_Node_Str");
}

Fixed version (ground truth):
private void initializeGMS() throws GMSException {
  Properties configProps=new Properties();
  int HA_MAX_GMS_MESSAGE_LENGTH=4 * (1024 * 1024) + (2 * 1024);
  configProps.put(ServiceProviderConfigurationKeys.MAX_MESSAGE_LENGTH.toString(),Integer.toString(HA_MAX_GMS_MESSAGE_LENGTH));
  readGMSConfigProps(configProps);
  printProps(configProps);
  String memberType=(String)configProps.get(MEMBERTYPE_STRING);
  gms=(GroupManagementService)GMSFactory.startGMSModule(instanceName,clusterName,GroupManagementService.MemberType.valueOf(memberType),configProps);
  GMSFactory.setGMSEnabledState(clusterName,Boolean.TRUE);
  if (gms != null) {
    try {
      registerJoinedAndReadyNotificationListener(this);
      registerJoinNotificationListener(this);
      registerFailureNotificationListener(this);
      registerPlannedShutdownListener(this);
      registerFailureSuspectedListener(this);
      if (testFailureRecoveryHandler && !env.isDas()) {
        registerFailureRecoveryListener("String_Node_Str",this);
      }
      glassfishEventListener=new org.glassfish.api.event.EventListener(){
        public void event(        Event event){
          if (gms == null) {
            return;
          }
          if (event.is(EventTypes.SERVER_SHUTDOWN)) {
            GMS_LOGGER.log(LogLevel.INFO,GMS_SERVER_SHUTDOWN_RECEIVED,new Object[]{gms.getInstanceName(),gms.getGroupName(),event.name()});
            removeJoinedAndReadyNotificationListener(GMSAdapterImpl.this);
            removeJoinNotificationListener(GMSAdapterImpl.this);
            removeFailureNotificationListener(GMSAdapterImpl.this);
            removeFailureSuspectedListener(GMSAdapterImpl.this);
            gms.shutdown(GMSConstants.shutdownType.INSTANCE_SHUTDOWN);
            removePlannedShutdownListener(GMSAdapterImpl.this);
            events.unregister(glassfishEventListener);
          }
 else           if (event.is(EventTypes.SERVER_READY)) {
            gms.reportJoinedAndReadyState();
          }
        }
      }
;
      events.register(glassfishEventListener);
      gms.join();
      GMS_LOGGER.log(LogLevel.INFO,GMS_JOINED,new Object[]{instanceName,clusterName});
    }
 catch (    GMSException e) {
      events.unregister(glassfishEventListener);
      throw e;
    }
    GMS_LOGGER.log(LogLevel.INFO,GMS_STARTED,new Object[]{instanceName,clusterName});
  }
 else   throw new GMSException("String_Node_Str");
}