Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OAK-11428: Remove usage of Guava Files.copy() #2022

Merged
merged 2 commits into from
Jan 24, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;
}
}
Loading