public static <T> CloseableReference<T> of(
      @PropagatesNullable T t,
      ResourceReleaser<T> resourceReleaser,
      LeakHandler leakHandler,
      @Nullable Throwable stacktrace) {
    if (t == null) {
      return null;
    } else {
      if (t instanceof Bitmap || t instanceof HasBitmap) {
        switch (sBitmapCloseableRefType) {
          case REF_TYPE_FINALIZER:
            return new FinalizerCloseableReference<>(t, resourceReleaser, leakHandler, stacktrace);
          case REF_TYPE_REF_COUNT:
            return new RefCountCloseableReference<>(t, resourceReleaser, leakHandler, stacktrace);
          case REF_TYPE_NOOP:
            return new NoOpCloseableReference<>(t);
          case REF_TYPE_DEFAULT:
            // return default
        }
      }

      return new DefaultCloseableReference<>(t, resourceReleaser, leakHandler, stacktrace);
    }
  }
Constructs a CloseableReference (wrapping a SharedReference) of T with provided
ResourceReleaser<T> and a custom handler that's run if a leak is detected in the finalizer. If
t is null, this will just return null.
fbcore/src/main/java/com/facebook/common/references/CloseableReference.java