private static Cache basicGetInstancePart2(DistributedSystem system, boolean closeOk) {
    InternalCache instance = GemFireCacheImpl.getInstance();
    if (instance == null) {
      throw new CacheClosedException(
          "A cache has not yet been created.");
    } else {
      if (instance.isClosed() && !closeOk) {
        throw instance.getCacheClosedException(
            "The cache has been closed.", null);
      }
      if (!instance.getDistributedSystem().equals(system)) {
        throw instance.getCacheClosedException(
            "A cache has not yet been created for the given distributed system.");
      }
      return instance;
    }
  }
@throws CacheClosedException if a cache has not been created or the only created one is
        {@link Cache#isClosed closed}
geode-core/src/main/java/org/apache/geode/internal/cache/CacheFactoryStatics.java