@Override
  public byte @NotNull [] contentsToByteArray(boolean cacheContent) throws IOException {
    checkNotTooLarge(null);
    byte[] preloadedContent = getUserData(ourPreloadedContentKey);
    if (preloadedContent != null) {
      return preloadedContent;
    }

    byte[] bytes = owningPersistentFS().contentsToByteArray(this, cacheContent);
    if (isCharsetSet()) {
      return bytes;
    }

    // optimization: take the opportunity to not load bytes again in getCharset()
    // use getFileTypeByFile(..., bytes) to not fall into a recursive trap from vfile.getFileType()
    // which would try to load contents again to detect charset
    FileType fileType = FileTypeManagerEx.getInstanceEx().getFileTypeByFile(this, bytes);

    if (fileType != UnknownFileType.INSTANCE && !fileType.isBinary() && bytes.length != 0) {
      try {
        // execute in impatient mode
        // to not deadlock when the indexing process waits under a write action for the queue to load contents in other threads
        // and that another thread asks JspManager for encoding which requires read action for PSI
        ((ApplicationEx)ApplicationManager.getApplication())
          .executeByImpatientReader(() -> LoadTextUtil.detectCharsetAndSetBOM(this, bytes, fileType));
      }
      catch (ProcessCanceledException ignored) {
      }
    }
    return bytes;
  }
@Override
  public byte @NotNull [] contentsToByteArray(boolean cacheContent)