private static boolean refresh(@NotNull VirtualFile file) throws IOException {
    Pair<Long, Long> loadedTimeModificationStamp = file.getUserData(TIME_MODIFICATION_STAMP_KEY);
    Pair<Long, Long> actualTimeModificationStamp = Pair.create(file.getTimeStamp(), file.getModificationStamp());
    SoftReference<ScaledImageProvider> imageProviderRef = file.getUserData(IMAGE_PROVIDER_REF_KEY);
    if (!actualTimeModificationStamp.equals(loadedTimeModificationStamp) || dereference(imageProviderRef) == null) {
      try {
        final byte[] content = file.contentsToByteArray();
        file.putUserData(IMAGE_PROVIDER_REF_KEY, null);

        if (ICO_FORMAT.equalsIgnoreCase(file.getExtension())) {
          try {
            final BufferedImage image = ICO_IMAGE_PARSER.getBufferedImage(new ByteSourceArray(content), null);
            file.putUserData(FORMAT_KEY, ICO_FORMAT);
            file.putUserData(IMAGE_PROVIDER_REF_KEY, new SoftReference<>((scale, ancestor) -> image));
            return true;
          }
          catch (ImageReadException ignore) { }
        }

        if (isSVG(file)) {
          final Ref<URL> url = Ref.create();
          try {
            url.set(new File(file.getPath()).toURI().toURL());
          }
          catch (MalformedURLException ex) {
            LOG.warn(ex.getMessage());
          }

          try {
            // ensure svg can be displayed
            SVGLoader.INSTANCE.load(url.get(), new ByteArrayInputStream(content), 1.0f);
          }
          catch (Throwable t) {
            LOG.warn(url.get() + " " + t.getMessage());
            return false;
          }

          file.putUserData(FORMAT_KEY, SVG_FORMAT);
          file.putUserData(IMAGE_PROVIDER_REF_KEY, new SoftReference<>(new ImageDocument.CachedScaledImageProvider() {
            final ScaleContextCache<Image> cache = new ScaleContextCache<>((ctx) -> {
              try {
                return SVGLoader.loadHiDPI(url.get(), new ByteArrayInputStream(content), ctx);
              }
              catch (Throwable t) {
                LOG.warn(url.get() + " " + t.getMessage());
                return null;
              }
            });
            @Override
            public void clearCache() {
              cache.clear();
            }

            @Override
            public BufferedImage apply(Double zoom, Component ancestor) {
              ScaleContext ctx = ScaleContext.create(ancestor);
              ctx.setScale(OBJ_SCALE.of(zoom));
              return (BufferedImage)cache.getOrProvide(ctx);
            }
          }));
          return true;
        }

        InputStream inputStream = new ByteArrayInputStream(content, 0, content.length);
        try (ImageInputStream imageInputStream = ImageIO.createImageInputStream(inputStream)) {
          Iterator<ImageReader> imageReaders = ImageIO.getImageReaders(imageInputStream);
          if (imageReaders.hasNext()) {
            ImageReader imageReader = imageReaders.next();
            try {
              file.putUserData(FORMAT_KEY, imageReader.getFormatName());
              ImageReadParam param = imageReader.getDefaultReadParam();
              imageReader.setInput(imageInputStream, true, true);
              int minIndex = imageReader.getMinIndex();
              BufferedImage image = imageReader.read(minIndex, param);
              file.putUserData(IMAGE_PROVIDER_REF_KEY, new SoftReference<>((zoom, ancestor) -> image));
              return true;
            }
            finally {
              imageReader.dispose();
            }
          }
        }
      } finally {
        // We perform loading no more needed
        file.putUserData(TIME_MODIFICATION_STAMP_KEY, actualTimeModificationStamp);
      }
    }
    return false;
  }
private static boolean refresh(@NotNull VirtualFile file)