Program: 8102
Project: 8102
Buggy source:
public MetaMessageSessionFactory(final MetaClientConfig metaClientConfig) throws MetaClientException {
  super();
  this.checkConfig(metaClientConfig);
  this.metaClientConfig=metaClientConfig;
  final ClientConfig clientConfig=new ClientConfig();
  clientConfig.setTcpNoDelay(TCP_NO_DELAY);
  clientConfig.setMaxReconnectTimes(MAX_RECONNECT_TIMES);
  clientConfig.setWireFormatType(new MetamorphosisWireFormatType());
  clientConfig.setMaxScheduleWrittenBytes(MAX_SCHEDULE_WRITTEN_BYTES);
  try {
    this.remotingClient=new RemotingClientWrapper(RemotingFactory.connect(clientConfig));
  }
 catch (  final NotifyRemotingException e) {
    throw new NetworkException("String_Node_Str",e);
  }
  if (this.metaClientConfig.getServerUrl() != null) {
    this.connectServer(this.metaClientConfig);
  }
 else {
    this.initZooKeeper();
  }
  this.producerZooKeeper=new ProducerZooKeeper(this.metaZookeeper,this.remotingClient,this.zkClient,metaClientConfig);
  this.sessionIdGenerator=new IdGenerator();
  this.consumerZooKeeper=this.initConsumerZooKeeper(this.remotingClient,this.zkClient,this.zkConfig);
  this.zkClientChangedListeners.add(this.producerZooKeeper);
  this.zkClientChangedListeners.add(this.consumerZooKeeper);
  this.subscribeInfoManager=new SubscribeInfoManager();
  this.recoverManager=new RecoverStorageManager(this.metaClientConfig,this.subscribeInfoManager);
  this.shutdownHook=new Thread(){
    @Override public void run(){
      try {
        MetaMessageSessionFactory.this.isHutdownHookCalled=true;
        MetaMessageSessionFactory.this.shutdown();
      }
 catch (      final MetaClientException e) {
        log.error("String_Node_Str",e);
      }
    }
  }
;
  Runtime.getRuntime().addShutdownHook(this.shutdownHook);
}

Fixed version (ground truth):
public MetaMessageSessionFactory(final MetaClientConfig metaClientConfig) throws MetaClientException {
  super();
  try {
    this.checkConfig(metaClientConfig);
    this.metaClientConfig=metaClientConfig;
    final ClientConfig clientConfig=new ClientConfig();
    clientConfig.setTcpNoDelay(TCP_NO_DELAY);
    clientConfig.setMaxReconnectTimes(MAX_RECONNECT_TIMES);
    clientConfig.setWireFormatType(new MetamorphosisWireFormatType());
    clientConfig.setMaxScheduleWrittenBytes(MAX_SCHEDULE_WRITTEN_BYTES);
    try {
      this.remotingClient=new RemotingClientWrapper(RemotingFactory.connect(clientConfig));
    }
 catch (    final NotifyRemotingException e) {
      throw new NetworkException("String_Node_Str",e);
    }
    if (this.metaClientConfig.getServerUrl() != null) {
      this.connectServer(this.metaClientConfig);
    }
 else {
      this.initZooKeeper();
    }
    this.producerZooKeeper=new ProducerZooKeeper(this.metaZookeeper,this.remotingClient,this.zkClient,metaClientConfig);
    this.sessionIdGenerator=new IdGenerator();
    this.consumerZooKeeper=this.initConsumerZooKeeper(this.remotingClient,this.zkClient,this.zkConfig);
    this.zkClientChangedListeners.add(this.producerZooKeeper);
    this.zkClientChangedListeners.add(this.consumerZooKeeper);
    this.subscribeInfoManager=new SubscribeInfoManager();
    this.recoverManager=new RecoverStorageManager(this.metaClientConfig,this.subscribeInfoManager);
    this.shutdownHook=new Thread(){
      @Override public void run(){
        try {
          MetaMessageSessionFactory.this.isHutdownHookCalled=true;
          MetaMessageSessionFactory.this.shutdown();
        }
 catch (        final MetaClientException e) {
          log.error("String_Node_Str",e);
        }
      }
    }
;
    Runtime.getRuntime().addShutdownHook(this.shutdownHook);
  }
 catch (  MetaClientException e) {
    this.shutdown();
    throw e;
  }
catch (  Exception e) {
    this.shutdown();
    throw new MetaClientException("String_Node_Str",e);
  }
}