Skip to content

Commit

Permalink
OAK-11428: Remove usage of Guava Files.copy() (#2022)
Browse files Browse the repository at this point in the history
* OAK-11428: Remove usage of Guava Files.copy() - oak-blob-plugins

* OAK-11428: Remove usage of Guava Files.copy() - oak-lucene
  • Loading branch information
reschke authored Jan 24, 2025
1 parent 7572f8b commit 68ab259
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -736,7 +736,7 @@ public synchronized void close() {
LOG.trace("Trying a copy file operation");
try {
if (renamed.createNewFile()) {
org.apache.jackrabbit.guava.common.io.Files.copy(processFile, renamed);
Files.copy(processFile.toPath(), renamed.toPath(), StandardCopyOption.REPLACE_EXISTING);
generations.add(renamed);
LOG.info("{} File copied to {}", processFile.getAbsolutePath(),
renamed.getAbsolutePath());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
import java.io.ObjectOutput;
import java.io.ObjectOutputStream;
import java.io.OutputStream;
import java.nio.file.Files;
import java.nio.file.StandardCopyOption;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
Expand Down Expand Up @@ -62,8 +64,6 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import org.apache.jackrabbit.guava.common.io.Files;

/**
* Abstract class for DataStore cache related tests.
*/
Expand All @@ -89,7 +89,7 @@ public TestStagingUploader(File dir, CountDownLatch adoptLatch) {
try {
File move = getFile(id, root);
move.getParentFile().mkdirs();
Files.copy(f, move);
Files.copy(f.toPath(), move.toPath(), StandardCopyOption.REPLACE_EXISTING);
LOG.info("In TestStagingUploader after write [{}]", move);
} catch (IOException e) {
throw new DataStoreException(e);
Expand Down Expand Up @@ -125,7 +125,7 @@ public void write(String id, File f) throws DataStoreException {
try {
File move = getFile(id, root);
move.getParentFile().mkdirs();
Files.copy(f, move);
Files.copy(f.toPath(), move.toPath(), StandardCopyOption.REPLACE_EXISTING);
LOG.info("In TestCacheLoader after write [{}], [{}]", id, move);
} catch (IOException e) {
throw new DataStoreException(e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
* specific language governing permissions and limitations
* under the License.
*/

package org.apache.jackrabbit.oak.plugins.index.lucene;

import java.io.File;
Expand All @@ -30,7 +29,6 @@
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;

import org.apache.jackrabbit.guava.common.io.Files;
import org.apache.commons.io.FileUtils;
import org.apache.jackrabbit.core.data.FileDataStore;
import org.apache.jackrabbit.oak.InitialContent;
Expand Down Expand Up @@ -374,18 +372,4 @@ private void printStats() throws IOException {
System.out.println("Index on FS size : " + FileUtils.byteCountToDisplaySize(sizeOfFSIndex));
}
}

private long dumpFileStoreTo(File to) throws IOException {
if (!to.exists()) {
assert to.mkdirs();
}
for (File f : DIRECTORY.listFiles()) {
Files.copy(f, new File(to.getPath(), f.getName()));
}

long sizeOfDirectory = FileUtils.sizeOfDirectory(to);

to.deleteOnExit();
return sizeOfDirectory;
}
}

0 comments on commit 68ab259

Please sign in to comment.