@Test public void testFactoryExceptionIsPropagated() { NullPointerException exception = mock(NullPointerException.class); when(_factory.create(any(ServiceEndPoint.class))).thenThrow(exception); try { newCache().checkOut(_endPoint); fail(); } catch (Exception caught) { assertSame(exception, caught); } }
@Override public ServiceHandle<S> checkOut(ServiceEndPoint endPoint) throws Exception { checkNotNull(endPoint); checkState(!_isClosed, "cache is closed"); ServiceHandle<S> serviceHandle = _instancesPerEndpoint.get(endPoint); if (serviceHandle == null) { return doRegister(endPoint); } return serviceHandle; }
MultiThreadedClientServiceCache implements ServiceCache<S> { @Override public ServiceHandle<S> checkOut(ServiceEndPoint endPoint) throws Exception { checkNotNull(endPoint); checkState(!_isClosed, "cache is closed"); ServiceHandle<S> serviceHandle = _instancesPerEndpoint.get(endPoint); if (serviceHandle == null) { return doRegister(endPoint); } return serviceHandle; } }
MultiThreadedClientServiceCache implements ServiceCache<S> { @Override public ServiceHandle<S> checkOut(ServiceEndPoint endPoint) throws Exception { checkNotNull(endPoint); checkState(!_isClosed, "cache is closed"); ServiceHandle<S> serviceHandle = _instancesPerEndpoint.get(endPoint); if (serviceHandle == null) { return doRegister(endPoint); } return serviceHandle; } MultiThreadedClientServiceCache(MultiThreadedServiceFactory<S> serviceFactory, MetricRegistry metricRegistry); @VisibleForTesting  MultiThreadedClientServiceCache(MultiThreadedServiceFactory<S> serviceFactory, ScheduledExecutorService executor,
                                    int evictionDelayInSeconds, int cleanUpDelayInSeconds, MetricRegistry metricRegistry); }
MultiThreadedClientServiceCache implements ServiceCache<S> { @Override public ServiceHandle<S> checkOut(ServiceEndPoint endPoint) throws Exception { checkNotNull(endPoint); checkState(!_isClosed, "cache is closed"); ServiceHandle<S> serviceHandle = _instancesPerEndpoint.get(endPoint); if (serviceHandle == null) { return doRegister(endPoint); } return serviceHandle; } MultiThreadedClientServiceCache(MultiThreadedServiceFactory<S> serviceFactory, MetricRegistry metricRegistry); @VisibleForTesting  MultiThreadedClientServiceCache(MultiThreadedServiceFactory<S> serviceFactory, ScheduledExecutorService executor,
                                    int evictionDelayInSeconds, int cleanUpDelayInSeconds, MetricRegistry metricRegistry); @Override void checkIn(ServiceHandle<S> handle); @Override ServiceHandle<S> checkOut(ServiceEndPoint endPoint); @Override void register(ServiceEndPoint endPoint); @Override synchronized void evict(ServiceEndPoint endPoint); @Override synchronized void close(); @Override int getNumIdleInstances(ServiceEndPoint endPoint); @Override int getNumActiveInstances(ServiceEndPoint endPoint); }
MultiThreadedClientServiceCache implements ServiceCache<S> { @Override public ServiceHandle<S> checkOut(ServiceEndPoint endPoint) throws Exception { checkNotNull(endPoint); checkState(!_isClosed, "cache is closed"); ServiceHandle<S> serviceHandle = _instancesPerEndpoint.get(endPoint); if (serviceHandle == null) { return doRegister(endPoint); } return serviceHandle; } MultiThreadedClientServiceCache(MultiThreadedServiceFactory<S> serviceFactory, MetricRegistry metricRegistry); @VisibleForTesting  MultiThreadedClientServiceCache(MultiThreadedServiceFactory<S> serviceFactory, ScheduledExecutorService executor,
                                    int evictionDelayInSeconds, int cleanUpDelayInSeconds, MetricRegistry metricRegistry); @Override void checkIn(ServiceHandle<S> handle); @Override ServiceHandle<S> checkOut(ServiceEndPoint endPoint); @Override void register(ServiceEndPoint endPoint); @Override synchronized void evict(ServiceEndPoint endPoint); @Override synchronized void close(); @Override int getNumIdleInstances(ServiceEndPoint endPoint); @Override int getNumActiveInstances(ServiceEndPoint endPoint);  }