From 250312bdf91dccf2b26be4b835a12c5f602cc245 Mon Sep 17 00:00:00 2001 From: Julian Reschke Date: Thu, 23 Jan 2025 14:03:11 +0100 Subject: [PATCH 1/2] OAK-11428: Remove usage of Guava Files.copy() - oak-blob-plugins --- .../oak/plugins/blob/datastore/BlobIdTracker.java | 2 +- .../oak/plugins/blob/AbstractDataStoreCacheTest.java | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/oak-blob-plugins/src/main/java/org/apache/jackrabbit/oak/plugins/blob/datastore/BlobIdTracker.java b/oak-blob-plugins/src/main/java/org/apache/jackrabbit/oak/plugins/blob/datastore/BlobIdTracker.java index 67d50298ed3..06df3ba1d7f 100644 --- a/oak-blob-plugins/src/main/java/org/apache/jackrabbit/oak/plugins/blob/datastore/BlobIdTracker.java +++ b/oak-blob-plugins/src/main/java/org/apache/jackrabbit/oak/plugins/blob/datastore/BlobIdTracker.java @@ -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()); diff --git a/oak-blob-plugins/src/test/java/org/apache/jackrabbit/oak/plugins/blob/AbstractDataStoreCacheTest.java b/oak-blob-plugins/src/test/java/org/apache/jackrabbit/oak/plugins/blob/AbstractDataStoreCacheTest.java index df954e20276..1b98de223f5 100644 --- a/oak-blob-plugins/src/test/java/org/apache/jackrabbit/oak/plugins/blob/AbstractDataStoreCacheTest.java +++ b/oak-blob-plugins/src/test/java/org/apache/jackrabbit/oak/plugins/blob/AbstractDataStoreCacheTest.java @@ -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; @@ -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. */ @@ -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); @@ -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); From 2f6aae68029dac73869a3cf1cd31f5b061472cbe Mon Sep 17 00:00:00 2001 From: Julian Reschke Date: Thu, 23 Jan 2025 14:23:51 +0100 Subject: [PATCH 2/2] OAK-11428: Remove usage of Guava Files.copy() - oak-lucene --- .../lucene/LuceneWritesOnSegmentStatsTest.java | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneWritesOnSegmentStatsTest.java b/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneWritesOnSegmentStatsTest.java index df97c295961..12327b8c1d4 100644 --- a/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneWritesOnSegmentStatsTest.java +++ b/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneWritesOnSegmentStatsTest.java @@ -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; @@ -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; @@ -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; - } }