private PathChildrenCache ensureCache() {
		if (cacheRef.get() == null) {
			synchronized (cacheRef) {
				if (cacheRef.get() == null) {
					CuratorFramework client = zkConnection.getClient();
					PathChildrenCache cache = new PathChildrenCache(client, Paths.CONTAINERS,
							true, ThreadUtils.newThreadFactory("ContainerCache"));
					cache.getListenable().addListener(new PathChildrenCacheListener() {

						@Override
						public void childEvent(CuratorFramework client, PathChildrenCacheEvent event) {
							// shut down the cache if ZooKeeper connection goes away
							ZooKeeperUtils.logCacheEvent(logger, event);
							if (event.getType() == PathChildrenCacheEvent.Type.CONNECTION_SUSPENDED ||
									event.getType() == PathChildrenCacheEvent.Type.CONNECTION_LOST) {
								closeCache();
							}
						}
					});
					try {
						Paths.ensurePath(client, Paths.CONTAINERS);
						cacheRef.set(cache);
						cache.start(PathChildrenCache.StartMode.BUILD_INITIAL_CACHE);
					}
					catch (Exception e) {
						try {
							cache.close();
						}
						catch (Exception ce) {
							// ignore exception on close
						}
						finally {
							cacheRef.compareAndSet(cache, null);
						}
						throw ZooKeeperUtils.wrapThrowable(e);
					}
				}
			}
		}

		PathChildrenCache cache = cacheRef.get();
		Assert.state(cache != null, "Container cache not initialized " +
				"(likely as a result of a ZooKeeper connection error)");
		return cache;
	}
Return a {@link PathChildrenCache} for containers, creating and
initializing a new instance if necessary.

@return a {@code PathChildrenCache} for containers
@throws java.lang.IllegalStateException if the cache could not be initialized
       (likely due to a ZooKeeper connection error)
spring-xd-dirt/src/main/java/org/springframework/xd/dirt/container/store/ZooKeeperContainerRepository.java