public Optional<UfsStatus[]> listFromUfsThenCache(String path, boolean isRecursive)
      throws IOException {
    // Recursive listing results are not cached.
    if (mListStatusCache == null || isRecursive) {
      return listFromUfs(path, isRecursive);
    }
    try {
      ListStatusResult cached = mListStatusCache.get(path, (k) -> {
        try {
          Optional<UfsStatus[]> listResults = listFromUfs(path, false);
          return listResults.map(
                  ufsStatuses -> new ListStatusResult(
                      System.nanoTime(), ufsStatuses,
                      ufsStatuses.length == 1 && ufsStatuses[0].isFile()
                  ))
              // This cache also serves as absent cache, so we persist a NULL (not empty) result,
              // if the path not found or is not a directory.
              .orElseGet(() -> new ListStatusResult(System.nanoTime(), null, false));
        } catch (Exception e) {
          throw new RuntimeException(e);
        }
      });
      if (cached == null) {
        return Optional.empty();
      } else {
        return Optional.ofNullable(cached.mUfsStatuses);
      }
    } catch (RuntimeException e) {
      Throwable cause = e.getCause();
      if (cause instanceof IOException) {
        throw (IOException) cause;
      }
      throw new RuntimeException(e);
    }
  }
@Test
  public void listFromUfsThenCacheWhenGetNull() throws IOException {
    UnderFileSystem system = mock(UnderFileSystem.class);
    when(system.listStatus(anyString())).thenReturn(null);
    when(system.getStatus(anyString())).thenReturn(null);
    doReturn(system).when(mDoraUfsManager).getOrAdd(any(), any());

    Optional<UfsStatus[]> status = mManager.listFromUfsThenCache("/test", false);
    assertEquals(status, Optional.empty());
  }