From 4e43fedd3a68cb5e5ad871966b881c20493d23cc Mon Sep 17 00:00:00 2001 From: Matthew Biscocho Date: Mon, 16 Dec 2024 16:07:10 -0500 Subject: [PATCH] Remove sync in FileUtils --- .../org/apache/solr/handler/IndexFetcher.java | 2 +- .../java/org/apache/solr/util/FileUtils.java | 35 ------------------- 2 files changed, 1 insertion(+), 36 deletions(-) diff --git a/solr/core/src/java/org/apache/solr/handler/IndexFetcher.java b/solr/core/src/java/org/apache/solr/handler/IndexFetcher.java index 0e8f360fe25..e6025b9b127 100644 --- a/solr/core/src/java/org/apache/solr/handler/IndexFetcher.java +++ b/solr/core/src/java/org/apache/solr/handler/IndexFetcher.java @@ -1989,7 +1989,7 @@ private static class LocalFsFile implements FileInterface { Path file; LocalFsFile(Path dir, String saveAs) throws IOException { - this.file = dir.resolve(saveAs); + this.file = dir.resolve(saveAs); Path parentDir = this.file.getParent(); if (Files.notExists(parentDir)) { diff --git a/solr/core/src/java/org/apache/solr/util/FileUtils.java b/solr/core/src/java/org/apache/solr/util/FileUtils.java index a76dab57af7..0b221aae025 100644 --- a/solr/core/src/java/org/apache/solr/util/FileUtils.java +++ b/solr/core/src/java/org/apache/solr/util/FileUtils.java @@ -16,9 +16,7 @@ */ package org.apache.solr.util; -import java.io.FileNotFoundException; import java.io.IOException; -import java.io.RandomAccessFile; import java.nio.file.Files; import java.nio.file.Path; import org.apache.commons.io.FileExistsException; @@ -26,39 +24,6 @@ /** */ public class FileUtils { - /** - * Copied from Lucene's FSDirectory.fsync(String) - * - * @param fullFile the File to be synced to disk - * @throws IOException if the file could not be synced - */ - public static void sync(Path fullFile) throws IOException { - if (fullFile == null || Files.notExists(fullFile)) - throw new FileNotFoundException("File does not exist " + fullFile); - - boolean success = false; - int retryCount = 0; - IOException exc = null; - while (!success && retryCount < 5) { - retryCount++; - try (RandomAccessFile file = new RandomAccessFile(fullFile.toFile(), "rw")) { - file.getFD().sync(); - success = true; - } catch (IOException ioe) { - if (exc == null) exc = ioe; - try { - // Pause 5 msec - Thread.sleep(5); - } catch (InterruptedException ie) { - Thread.currentThread().interrupt(); - } - } - } - if (!success) - // Throw original exception - throw exc; - } - public static boolean fileExists(String filePathString) { return Files.exists(Path.of(filePathString)); }