Program: 7215
Project: 7215
Buggy source:
/** 
 * Configures the AppFabricService pre-start.
 */
@Override protected void startUp() throws Exception {
  LoggingContextAccessor.setLoggingContext(new ServiceLoggingContext(Constants.SYSTEM_NAMESPACE,Constants.Logging.COMPONENT_NAME,Constants.Service.APP_FABRIC_HTTP));
  File tmpDir=new File(configuration.get(Constants.CFG_LOCAL_DATA_DIR),configuration.get(Constants.AppFabric.TEMP_DIR)).getAbsoluteFile();
  FileUtils.deleteDirectory(tmpDir);
  notificationService.start();
  schedulerService.start();
  adapterService.start();
  programRuntimeService.start();
  ImmutableList.Builder<HandlerHook> builder=ImmutableList.builder();
  for (  String hook : handlerHookNames) {
    builder.add(new MetricsReporterHook(metricsCollectionService,hook));
  }
  httpService=new CommonNettyHttpServiceBuilder(configuration).setHost(hostname.getCanonicalHostName()).setHandlerHooks(builder.build()).addHttpHandlers(handlers).setConnectionBacklog(configuration.getInt(Constants.AppFabric.BACKLOG_CONNECTIONS,Constants.AppFabric.DEFAULT_BACKLOG)).setExecThreadPoolSize(configuration.getInt(Constants.AppFabric.EXEC_THREADS,Constants.AppFabric.DEFAULT_EXEC_THREADS)).setBossThreadPoolSize(configuration.getInt(Constants.AppFabric.BOSS_THREADS,Constants.AppFabric.DEFAULT_BOSS_THREADS)).setWorkerThreadPoolSize(configuration.getInt(Constants.AppFabric.WORKER_THREADS,Constants.AppFabric.DEFAULT_WORKER_THREADS)).build();
  httpService.addListener(new ServiceListenerAdapter(){
    private List<Cancellable> cancellables=Lists.newArrayList();
    @Override public void running(){
      final InetSocketAddress socketAddress=httpService.getBindAddress();
      LOG.info("String_Node_Str",socketAddress);
      for (      final String serviceName : servicesNames) {
        cancellables.add(discoveryService.register(new Discoverable(){
          @Override public String getName(){
            return serviceName;
          }
          @Override public InetSocketAddress getSocketAddress(){
            return socketAddress;
          }
        }
));
      }
    }
    @Override public void terminated(    State from){
      LOG.info("String_Node_Str");
      for (      Cancellable cancellable : cancellables) {
        if (cancellable != null) {
          cancellable.cancel();
        }
      }
    }
    @Override public void failed(    State from,    Throwable failure){
      LOG.info("String_Node_Str",failure);
      for (      Cancellable cancellable : cancellables) {
        if (cancellable != null) {
          cancellable.cancel();
        }
      }
    }
  }
,Threads.SAME_THREAD_EXECUTOR);
  httpService.startAndWait();
  Thread defaultNamespaceEnsurer=new Thread(new DefaultNamespaceEnsurer(namespaceAdmin,1,TimeUnit.SECONDS));
  defaultNamespaceEnsurer.start();
}

Fixed version (ground truth):
/** 
 * Configures the AppFabricService pre-start.
 */
@Override protected void startUp() throws Exception {
  LoggingContextAccessor.setLoggingContext(new ServiceLoggingContext(Constants.SYSTEM_NAMESPACE,Constants.Logging.COMPONENT_NAME,Constants.Service.APP_FABRIC_HTTP));
  File tmpDir=new File(configuration.get(Constants.CFG_LOCAL_DATA_DIR),configuration.get(Constants.AppFabric.TEMP_DIR)).getAbsoluteFile();
  FileUtils.deleteDirectory(tmpDir);
  notificationService.start();
  schedulerService.start();
  adapterService.start();
  programRuntimeService.start();
  streamCoordinatorClient.start();
  ImmutableList.Builder<HandlerHook> builder=ImmutableList.builder();
  for (  String hook : handlerHookNames) {
    builder.add(new MetricsReporterHook(metricsCollectionService,hook));
  }
  httpService=new CommonNettyHttpServiceBuilder(configuration).setHost(hostname.getCanonicalHostName()).setHandlerHooks(builder.build()).addHttpHandlers(handlers).setConnectionBacklog(configuration.getInt(Constants.AppFabric.BACKLOG_CONNECTIONS,Constants.AppFabric.DEFAULT_BACKLOG)).setExecThreadPoolSize(configuration.getInt(Constants.AppFabric.EXEC_THREADS,Constants.AppFabric.DEFAULT_EXEC_THREADS)).setBossThreadPoolSize(configuration.getInt(Constants.AppFabric.BOSS_THREADS,Constants.AppFabric.DEFAULT_BOSS_THREADS)).setWorkerThreadPoolSize(configuration.getInt(Constants.AppFabric.WORKER_THREADS,Constants.AppFabric.DEFAULT_WORKER_THREADS)).build();
  httpService.addListener(new ServiceListenerAdapter(){
    private List<Cancellable> cancellables=Lists.newArrayList();
    @Override public void running(){
      final InetSocketAddress socketAddress=httpService.getBindAddress();
      LOG.info("String_Node_Str",socketAddress);
      for (      final String serviceName : servicesNames) {
        cancellables.add(discoveryService.register(new Discoverable(){
          @Override public String getName(){
            return serviceName;
          }
          @Override public InetSocketAddress getSocketAddress(){
            return socketAddress;
          }
        }
));
      }
    }
    @Override public void terminated(    State from){
      LOG.info("String_Node_Str");
      for (      Cancellable cancellable : cancellables) {
        if (cancellable != null) {
          cancellable.cancel();
        }
      }
    }
    @Override public void failed(    State from,    Throwable failure){
      LOG.info("String_Node_Str",failure);
      for (      Cancellable cancellable : cancellables) {
        if (cancellable != null) {
          cancellable.cancel();
        }
      }
    }
  }
,Threads.SAME_THREAD_EXECUTOR);
  httpService.startAndWait();
  Thread defaultNamespaceEnsurer=new Thread(new DefaultNamespaceEnsurer(namespaceAdmin,1,TimeUnit.SECONDS));
  defaultNamespaceEnsurer.start();
}