public V get(K key) {
    Reference<V> ref = referenceCache.get(Objects.requireNonNull(key));
    if (ref != null) {
      V obj = ref.get();
      if (obj != null) {
        return obj;
      }
      referenceCache.remove(key, ref);
    }

    V newObj = objectFactory.createObject(key);
    Reference<V> newRef = createReference(key, newObj);
    while (true) {
      Reference<V> existingRef = referenceCache.putIfAbsent(key, newRef);
      if (existingRef == null) {
        return newObj;
      }

      V existingObject = existingRef.get();
      if (existingObject != null) {
        return existingObject;
      }
      referenceCache.remove(key, existingRef);
    }
  }
Returns a shared object associated with the given {@code key}, which is identified by the
{@code equals} method.
@throws NullPointerException if {@code key} is {@code null}
hbase-common/src/main/java/org/apache/hadoop/hbase/util/ObjectPool.java