Program: 189098
Project: 189098
Buggy source:
ServicePool(Ticker ticker,HostDiscovery hostDiscovery,boolean closeHostDiscovery,ServiceFactory<S> serviceFactory,ServiceCachingPolicy cachingPolicy,PartitionFilter partitionFilter,LoadBalanceAlgorithm loadBalanceAlgorithm,ScheduledExecutorService healthCheckExecutor,boolean shutdownHealthCheckExecutorOnClose){
  _ticker=checkNotNull(ticker);
  _hostDiscovery=checkNotNull(hostDiscovery);
  _closeHostDiscovery=closeHostDiscovery;
  _serviceFactory=checkNotNull(serviceFactory);
  _healthCheckExecutor=checkNotNull(healthCheckExecutor);
  _shutdownHealthCheckExecutorOnClose=shutdownHealthCheckExecutorOnClose;
  _badEndPoints=Sets.newSetFromMap(Maps.<ServiceEndPoint,Boolean>newConcurrentMap());
  _badEndPointFilter=Predicates.not(Predicates.in(_badEndPoints));
  _recentlyRemovedEndPoints=Sets.newSetFromMap(CacheBuilder.newBuilder().ticker(_ticker).expireAfterWrite(10,TimeUnit.MINUTES).<ServiceEndPoint,Boolean>build().asMap());
  checkNotNull(cachingPolicy);
  _serviceCache=new ServiceCache<S>(cachingPolicy,serviceFactory);
  _partitionFilter=checkNotNull(partitionFilter);
  _loadBalanceAlgorithm=checkNotNull(loadBalanceAlgorithm);
  _servicePoolStatistics=new ServicePoolStatistics(){
    @Override public int getNumIdleCachedInstances(    ServiceEndPoint endPoint){
      return _serviceCache.getNumIdleInstances(endPoint);
    }
    @Override public int getNumActiveInstances(    ServiceEndPoint endPoint){
      return _serviceCache.getNumActiveInstances(endPoint);
    }
  }
;
  _hostDiscoveryListener=new HostDiscovery.EndPointListener(){
    @Override public void onEndPointAdded(    ServiceEndPoint endPoint){
      addEndPoint(endPoint);
    }
    @Override public void onEndPointRemoved(    ServiceEndPoint endPoint){
      removeEndPoint(endPoint);
    }
  }
;
  _hostDiscovery.addListener(_hostDiscoveryListener);
  _batchHealthChecksFuture=_healthCheckExecutor.scheduleAtFixedRate(new BatchHealthChecks(),HEALTH_CHECK_POLL_INTERVAL_IN_SECONDS,HEALTH_CHECK_POLL_INTERVAL_IN_SECONDS,TimeUnit.SECONDS);
  String serviceName=_serviceFactory.getServiceName();
  _metrics=Metrics.forInstance(this,serviceName);
  _callbackExecutionTime=_metrics.newTimer(serviceName,"String_Node_Str",TimeUnit.MILLISECONDS,TimeUnit.SECONDS);
  _healthCheckTime=_metrics.newTimer(serviceName,"String_Node_Str",TimeUnit.MILLISECONDS,TimeUnit.SECONDS);
  _numExecuteSuccesses=_metrics.newMeter(serviceName,"String_Node_Str","String_Node_Str",TimeUnit.SECONDS);
  _numExecuteAttemptFailures=_metrics.newMeter(serviceName,"String_Node_Str","String_Node_Str",TimeUnit.SECONDS);
  _metrics.newGauge(serviceName,"String_Node_Str",new Gauge<Integer>(){
    @Override public Integer value(){
      return getNumValidEndPoints();
    }
  }
);
  _metrics.newGauge(serviceName,"String_Node_Str",new Gauge<Integer>(){
    @Override public Integer value(){
      return getNumBadEndPoints();
    }
  }
);
}

Fixed version (ground truth):
ServicePool(Ticker ticker,HostDiscovery hostDiscovery,boolean cleanupHostDiscoveryOnClose,ServiceFactory<S> serviceFactory,ServiceCachingPolicy cachingPolicy,PartitionFilter partitionFilter,LoadBalanceAlgorithm loadBalanceAlgorithm,ScheduledExecutorService healthCheckExecutor,boolean shutdownHealthCheckExecutorOnClose){
  _ticker=checkNotNull(ticker);
  _hostDiscovery=checkNotNull(hostDiscovery);
  _cleanupHostDiscoveryOnClose=cleanupHostDiscoveryOnClose;
  _serviceFactory=checkNotNull(serviceFactory);
  _healthCheckExecutor=checkNotNull(healthCheckExecutor);
  _shutdownHealthCheckExecutorOnClose=shutdownHealthCheckExecutorOnClose;
  _badEndPoints=Sets.newSetFromMap(Maps.<ServiceEndPoint,Boolean>newConcurrentMap());
  _badEndPointFilter=Predicates.not(Predicates.in(_badEndPoints));
  _recentlyRemovedEndPoints=Sets.newSetFromMap(CacheBuilder.newBuilder().ticker(_ticker).expireAfterWrite(10,TimeUnit.MINUTES).<ServiceEndPoint,Boolean>build().asMap());
  checkNotNull(cachingPolicy);
  _serviceCache=new ServiceCache<S>(cachingPolicy,serviceFactory);
  _partitionFilter=checkNotNull(partitionFilter);
  _loadBalanceAlgorithm=checkNotNull(loadBalanceAlgorithm);
  _servicePoolStatistics=new ServicePoolStatistics(){
    @Override public int getNumIdleCachedInstances(    ServiceEndPoint endPoint){
      return _serviceCache.getNumIdleInstances(endPoint);
    }
    @Override public int getNumActiveInstances(    ServiceEndPoint endPoint){
      return _serviceCache.getNumActiveInstances(endPoint);
    }
  }
;
  _hostDiscoveryListener=new HostDiscovery.EndPointListener(){
    @Override public void onEndPointAdded(    ServiceEndPoint endPoint){
      addEndPoint(endPoint);
    }
    @Override public void onEndPointRemoved(    ServiceEndPoint endPoint){
      removeEndPoint(endPoint);
    }
  }
;
  _hostDiscovery.addListener(_hostDiscoveryListener);
  _batchHealthChecksFuture=_healthCheckExecutor.scheduleAtFixedRate(new BatchHealthChecks(),HEALTH_CHECK_POLL_INTERVAL_IN_SECONDS,HEALTH_CHECK_POLL_INTERVAL_IN_SECONDS,TimeUnit.SECONDS);
  String serviceName=_serviceFactory.getServiceName();
  _metrics=Metrics.forInstance(this,serviceName);
  _callbackExecutionTime=_metrics.newTimer(serviceName,"String_Node_Str",TimeUnit.MILLISECONDS,TimeUnit.SECONDS);
  _healthCheckTime=_metrics.newTimer(serviceName,"String_Node_Str",TimeUnit.MILLISECONDS,TimeUnit.SECONDS);
  _numExecuteSuccesses=_metrics.newMeter(serviceName,"String_Node_Str","String_Node_Str",TimeUnit.SECONDS);
  _numExecuteAttemptFailures=_metrics.newMeter(serviceName,"String_Node_Str","String_Node_Str",TimeUnit.SECONDS);
  _metrics.newGauge(serviceName,"String_Node_Str",new Gauge<Integer>(){
    @Override public Integer value(){
      return getNumValidEndPoints();
    }
  }
);
  _metrics.newGauge(serviceName,"String_Node_Str",new Gauge<Integer>(){
    @Override public Integer value(){
      return getNumBadEndPoints();
    }
  }
);
}