public static synchronized void rewriteVersion(@NotNull ID<?, ?> indexId, final int version) throws IOException {
    if (FileBasedIndex.USE_IN_MEMORY_INDEX) {
      return;
    }

    Path file = IndexInfrastructure.getVersionFile(indexId);
    if (LOG.isDebugEnabled()) {
      LOG.debug("Rewriting " + file + "," + version);
    }
    IndexVersion newIndexVersion = getIndexVersion(indexId).nextVersion(version, FSRecords.getCreationTimestamp());

    if (Files.exists(file)) {
      FileUtil.deleteWithRenaming(file.toFile());
    }
    else {
      Files.createDirectories(file.getParent());
    }
    try (DataOutputStream os = FileUtilRt.doIOOperation(lastAttempt -> {
      try {
        return new DataOutputStream(new BufferedOutputStream(Files.newOutputStream(file)));
      }
      catch (IOException ex) {
        if (lastAttempt) {
          throw ex;
        }
        return null;
      }
    })) {
      assert os != null;

      newIndexVersion.write(os);
      Int2ObjectMap<IndexVersion> newCopy = new Int2ObjectOpenHashMap<>(ourIndexIdToCreationStamp);
      newCopy.put(indexId.getUniqueId(), newIndexVersion);
      ourIndexIdToCreationStamp = newCopy;
    }
  }
public static synchronized void rewriteVersion(@NotNull ID<?, ?> indexId, final int version)