public static void closeSafely(@Nullable CloseableReference<?> ref) {
    if (ref != null) {
      ref.close();
    }
  }
Closes the reference handling null.

@param ref the reference to close
fbcore/src/main/java/com/facebook/common/references/CloseableReference.java