public ObjectT retain(KeyT key) {
    synchronized (pool) {
      RefCounted ref = pool.computeIfAbsent(key, k -> new RefCounted(builder.apply(k)));
      ref.count++;
      return ref.shared;
    }
  }
@Test
  public void shareClientsOfSameConfiguration() {
    String config1 = "config1";
    String config2 = "config2";

    assertThat(pool.retain(config1)).isSameAs(pool.retain(config1));
    assertThat(pool.retain(config1)).isNotSameAs(pool.retain(config2));
    verify(provider, times(2)).apply(anyString());
    verify(provider, times(1)).apply(config1);
    verify(provider, times(1)).apply(config2);
  }