code: public static String getCanonicalPath(String path) {
          if (path == null) return null;
          return getCanonicalPath(
                  path, new Supplier<Boolean>() {
              int retries = 2;
  
              public Boolean get() {
                  if (retries-- == 0) {
                      return false;
                  }
                  try {
                      // if retries not exhausted, sleep 100 milliseconds
                      Thread.sleep(100);
                  } catch (InterruptedException e) {
                      return false;
                  }
                  return true;
              }
          }
          );
      }
docs: Use this function instead of {@link java.io.File#getCanonicalPath()}, as that method
  can fail during symlink changes, and this method will retry up to 3 times with a
  short delay.  Returns null if unsuccessful after retrying.
  
  @param path path to canonicalize
  @return the canonical pathname, or null if unsuccessful