Skip to content

Commit 595b334

Browse files
committed
OAK-11420: Remove usage of Guava Files.move()
1 parent cc7e6ef commit 595b334

File tree

2 files changed

+10
-8
lines changed
  • oak-blob-plugins/src/main/java/org/apache/jackrabbit/oak/plugins/blob/datastore
  • oak-commons/src/main/java/org/apache/jackrabbit/oak/commons

2 files changed

+10
-8
lines changed

oak-blob-plugins/src/main/java/org/apache/jackrabbit/oak/plugins/blob/datastore/BlobIdTracker.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@
2525
import java.io.IOException;
2626
import java.io.InputStream;
2727
import java.nio.charset.StandardCharsets;
28+
import java.nio.file.Files;
29+
import java.nio.file.StandardCopyOption;
2830
import java.util.ArrayList;
2931
import java.util.Arrays;
3032
import java.util.Iterator;
@@ -35,7 +37,6 @@
3537
import java.util.function.Predicate;
3638

3739
import org.apache.jackrabbit.guava.common.base.Stopwatch;
38-
import org.apache.jackrabbit.guava.common.io.Files;
3940
import org.apache.jackrabbit.core.data.DataRecord;
4041
import org.apache.jackrabbit.oak.commons.collections.ListUtils;
4142
import org.apache.jackrabbit.oak.commons.concurrent.ExecutorCloser;
@@ -49,7 +50,6 @@
4950
import org.slf4j.LoggerFactory;
5051

5152
import static org.apache.jackrabbit.guava.common.collect.Iterables.transform;
52-
import static org.apache.jackrabbit.guava.common.io.Files.move;
5353
import static java.io.File.createTempFile;
5454
import static java.lang.System.currentTimeMillis;
5555
import static java.util.Collections.emptyIterator;
@@ -449,7 +449,7 @@ public void reconcile(File recs) throws IOException {
449449
}
450450
}
451451

452-
move(removed, delFile);
452+
Files.move(removed.toPath(), delFile.toPath(), StandardCopyOption.REPLACE_EXISTING);
453453
LOG.trace("removed active delete records");
454454
} finally {
455455
lock.unlock();
@@ -652,7 +652,7 @@ protected void removeRecords(File recs) throws IOException {
652652
}
653653

654654
File blobRecs = getBlobRecordsFile();
655-
move(temp, blobRecs);
655+
Files.move(temp.toPath(), blobRecs.toPath(), StandardCopyOption.REPLACE_EXISTING);
656656
LOG.trace("removed records");
657657
} finally {
658658
refLock.unlock();
@@ -736,7 +736,7 @@ public synchronized void close() {
736736
LOG.trace("Trying a copy file operation");
737737
try {
738738
if (renamed.createNewFile()) {
739-
Files.copy(processFile, renamed);
739+
org.apache.jackrabbit.guava.common.io.Files.copy(processFile, renamed);
740740
generations.add(renamed);
741741
LOG.info("{} File copied to {}", processFile.getAbsolutePath(),
742742
renamed.getAbsolutePath());

oak-commons/src/main/java/org/apache/jackrabbit/oak/commons/FileIOUtils.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
import static org.apache.commons.io.FileUtils.forceDelete;
2222
import static org.apache.commons.io.IOUtils.copyLarge;
2323
import static org.apache.jackrabbit.guava.common.io.Closeables.close;
24-
import static org.apache.jackrabbit.guava.common.io.Files.move;
2524
import static org.apache.jackrabbit.oak.commons.sort.EscapeUtils.escapeLineBreak;
2625
import static org.apache.jackrabbit.oak.commons.sort.EscapeUtils.unescapeLineBreaks;
2726
import static org.apache.jackrabbit.oak.commons.sort.ExternalSort.mergeSortedFiles;
@@ -38,6 +37,8 @@
3837
import java.io.InputStream;
3938
import java.io.InputStreamReader;
4039
import java.io.OutputStream;
40+
import java.nio.file.Files;
41+
import java.nio.file.StandardCopyOption;
4142
import java.util.Comparator;
4243
import java.util.HashSet;
4344
import java.util.Iterator;
@@ -73,7 +74,7 @@ private FileIOUtils() {
7374
public static void sort(File file) throws IOException {
7475
File sorted = createTempFile("fleioutilssort", null);
7576
merge(sortInBatch(file, lexComparator, true), sorted);
76-
move(sorted, file);
77+
Files.move(sorted.toPath(), file.toPath(), StandardCopyOption.REPLACE_EXISTING);
7778
}
7879

7980
/**
@@ -86,7 +87,8 @@ public static void sort(File file) throws IOException {
8687
public static void sort(File file, Comparator<String> comparator) throws IOException {
8788
File sorted = createTempFile("fleioutilssort", null);
8889
merge(sortInBatch(file, comparator, true), sorted, comparator);
89-
move(sorted, file);
90+
System.err.println("XXX: " + sorted + " " + file);
91+
Files.move(sorted.toPath(), file.toPath(), StandardCopyOption.REPLACE_EXISTING);
9092
}
9193

9294
/**

0 commit comments

Comments
 (0)