This is an automated email from the ASF dual-hosted git repository.

reschke pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/jackrabbit-oak.git


The following commit(s) were added to refs/heads/trunk by this push:
     new ad3254e474  OAK-11448: Remove usage of Guava Files.readLines()  (#2046)
ad3254e474 is described below

commit ad3254e47477bd7a79f053c913f3771c8742f5f6
Author: Julian Reschke <[email protected]>
AuthorDate: Sun Feb 2 10:32:01 2025 +0100

     OAK-11448: Remove usage of Guava Files.readLines()  (#2046)
    
    * OAK-11448: Remove usage of Guava Files.readLines()
    
    * OAK-11448: Remove usage of Guava Files.readLines()
    
    * OAK-11448: Remove usage of Guava Files.readLines()
    
    * OAK-11448: Remove usage of Guava Files.readLines()
    
    * OAK-11448: Remove usage of Guava Files.readLines()
---
 .../org/apache/jackrabbit/oak/commons/sort/ExternalSortTest.java  | 8 ++++----
 .../oak/plugins/index/datastore/DataStoreTextWriter.java          | 7 ++++---
 .../org/apache/jackrabbit/oak/segment/file/JournalEntryTest.java  | 6 ++----
 3 files changed, 10 insertions(+), 11 deletions(-)

diff --git 
a/oak-commons/src/test/java/org/apache/jackrabbit/oak/commons/sort/ExternalSortTest.java
 
b/oak-commons/src/test/java/org/apache/jackrabbit/oak/commons/sort/ExternalSortTest.java
index e00edad706..2303078a5d 100644
--- 
a/oak-commons/src/test/java/org/apache/jackrabbit/oak/commons/sort/ExternalSortTest.java
+++ 
b/oak-commons/src/test/java/org/apache/jackrabbit/oak/commons/sort/ExternalSortTest.java
@@ -18,7 +18,6 @@ package org.apache.jackrabbit.oak.commons.sort;
 
 import net.jpountz.lz4.LZ4FrameInputStream;
 import net.jpountz.lz4.LZ4FrameOutputStream;
-import org.apache.jackrabbit.guava.common.io.Files;
 import org.apache.jackrabbit.oak.commons.Compression;
 import org.junit.After;
 import org.junit.Before;
@@ -41,6 +40,7 @@ import java.io.OutputStreamWriter;
 import java.nio.channels.FileChannel;
 import java.nio.charset.Charset;
 import java.nio.charset.StandardCharsets;
+import java.nio.file.Files;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collections;
@@ -457,8 +457,8 @@ public class ExternalSortTest {
                                                                              
File compressedFile) throws IOException {
         try (BufferedWriter bufferedWriter = new BufferedWriter(
                 new OutputStreamWriter(algorithm.getOutputStream(new 
FileOutputStream(compressedFile)),
-                        Charset.defaultCharset()));) {
-            Files.readLines(uncompressedInputFile, 
Charset.defaultCharset()).forEach(n -> {
+                        Charset.defaultCharset()))) {
+            Files.lines(uncompressedInputFile.toPath()).forEach(n -> {
                 try {
                     bufferedWriter.write(n + "\n");
                 } catch (IOException e) {
@@ -511,7 +511,7 @@ public class ExternalSortTest {
         Collections.sort(testLines);
 
         List<TestLine> linesFromSortedFile = new ArrayList<>();
-        Files.readLines(out, charset).forEach(line -> 
linesFromSortedFile.add(new TestLine(line)));
+        Files.lines(out.toPath()).forEach(line -> linesFromSortedFile.add(new 
TestLine(line)));
 
         assertEquals(testLines, linesFromSortedFile);
 
diff --git 
a/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/datastore/DataStoreTextWriter.java
 
b/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/datastore/DataStoreTextWriter.java
index d497275a0a..38394983c6 100644
--- 
a/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/datastore/DataStoreTextWriter.java
+++ 
b/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/datastore/DataStoreTextWriter.java
@@ -29,6 +29,7 @@ import java.nio.file.Files;
 import java.util.HashSet;
 import java.util.Set;
 import java.util.concurrent.Callable;
+import java.util.stream.Collectors;
 
 import org.apache.commons.io.FileUtils;
 import org.apache.jackrabbit.oak.api.Blob;
@@ -230,11 +231,11 @@ public class DataStoreTextWriter implements TextWriter, 
Closeable, PreExtractedT
     }
 
     private Set<String> loadFromFile(File file) throws IOException {
-        Set<String> result = new HashSet<>();
         if (file.exists()) {
-            
result.addAll(org.apache.jackrabbit.guava.common.io.Files.readLines(file, 
StandardCharsets.UTF_8));
+            return Files.lines(file.toPath()).collect(Collectors.toSet());
+        } else {
+            return new HashSet<>();
         }
-        return result;
     }
 
     private void writeToFile(String fileName, Set<String> blobIds) throws 
IOException {
diff --git 
a/oak-segment-tar/src/test/java/org/apache/jackrabbit/oak/segment/file/JournalEntryTest.java
 
b/oak-segment-tar/src/test/java/org/apache/jackrabbit/oak/segment/file/JournalEntryTest.java
index 5fb265f5ee..a0597eeb6c 100644
--- 
a/oak-segment-tar/src/test/java/org/apache/jackrabbit/oak/segment/file/JournalEntryTest.java
+++ 
b/oak-segment-tar/src/test/java/org/apache/jackrabbit/oak/segment/file/JournalEntryTest.java
@@ -16,7 +16,6 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-
 package org.apache.jackrabbit.oak.segment.file;
 
 import static 
org.apache.jackrabbit.oak.segment.file.FileStoreBuilder.fileStoreBuilder;
@@ -25,11 +24,10 @@ import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertTrue;
 
 import java.io.File;
-import java.nio.charset.Charset;
+import java.nio.file.Files;
 import java.util.List;
 
 import org.apache.jackrabbit.guava.common.base.Splitter;
-import org.apache.jackrabbit.guava.common.io.Files;
 import org.apache.jackrabbit.oak.segment.SegmentNodeStore;
 import org.apache.jackrabbit.oak.segment.SegmentNodeStoreBuilders;
 import org.apache.jackrabbit.oak.segment.file.tar.LocalJournalFile;
@@ -70,7 +68,7 @@ public class JournalEntryTest {
         fileStore.close();
 
         File journal = new File(tempFolder.getRoot(), "journal.log");
-        List<String> lines = Files.readLines(journal, 
Charset.defaultCharset());
+        List<String> lines = Files.readAllLines(journal.toPath());
         assertFalse(lines.isEmpty());
 
         String line = lines.get(0);

Reply via email to