@Test
  public void close_blocksUntilFirstCallToCloseCompletes() throws Exception {
    gemFireCacheImpl = gemFireCacheImpl(false);
    CyclicBarrier cyclicBarrier = new CyclicBarrier(3);

    Future<Boolean> close1 = executorServiceRule.submit(() -> {
      synchronized (GemFireCacheImpl.class) {
        cyclicBarrier.await(getTimeout().toMillis(), MILLISECONDS);
        return gemFireCacheImpl.doClose("test", null, false, false, false);
      }
    });

    await().until(() -> cyclicBarrier.getNumberWaiting() == 1);

    Future<Boolean> close2 = executorServiceRule.submit(() -> {
      cyclicBarrier.await(getTimeout().toMillis(), MILLISECONDS);
      return gemFireCacheImpl.doClose("test", null, false, false, false);
    });

    cyclicBarrier.await(getTimeout().toMillis(), MILLISECONDS);

    boolean closedCache1 = close1.get();
    boolean closedCache2 = close2.get();

    assertThat(closedCache1)
        .as("closedCache1=" + closedCache1 + " and closedCache2=" + closedCache2)
        .isTrue();
    assertThat(closedCache2)
        .as("closedCache1=" + closedCache1 + " and closedCache2=" + closedCache2)
        .isFalse();
  }
InternalDistributed.disconnect is invoked only once despite invoking GemFireCacheImpl.close
more than once.
geode-core/src/test/java/org/apache/geode/internal/cache/GemFireCacheImplCloseTest.java