I found a test that closes the cache and then recreates the cache multiple times with 2 second sleep between each. I tried to remove the Thread.sleep and found that recreating the cache throws DistributedSystemDisconnectedException (see below).
This seems like a usability nightmare. Anyone have any ideas WHY it's this way? Personally, I want Cache.close() to block until both Cache and DistributedSystem are closed and the API is ready to create a new Cache. org.apache.geode.distributed.DistributedSystemDisconnectedException: This connection to a distributed system has been disconnected. at org.apache.geode.distributed.internal.InternalDistributedSystem.checkConnected(InternalDistributedSystem.java:945) at org.apache.geode.distributed.internal.InternalDistributedSystem.getDistributionManager(InternalDistributedSystem.java:1665) at org.apache.geode.internal.cache.GemFireCacheImpl.<init>(GemFireCacheImpl.java:791) at org.apache.geode.internal.cache.InternalCacheBuilder.create(InternalCacheBuilder.java:187) at org.apache.geode.internal.cache.InternalCacheBuilder.create(InternalCacheBuilder.java:158) at org.apache.geode.cache.CacheFactory.create(CacheFactory.java:142)