Skip to content

Commit ad3254e

Browse files
authored
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()
1 parent 24c83ec commit ad3254e

File tree

3 files changed

+10
-11
lines changed

3 files changed

+10
-11
lines changed

oak-commons/src/test/java/org/apache/jackrabbit/oak/commons/sort/ExternalSortTest.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818

1919
import net.jpountz.lz4.LZ4FrameInputStream;
2020
import net.jpountz.lz4.LZ4FrameOutputStream;
21-
import org.apache.jackrabbit.guava.common.io.Files;
2221
import org.apache.jackrabbit.oak.commons.Compression;
2322
import org.junit.After;
2423
import org.junit.Before;
@@ -41,6 +40,7 @@
4140
import java.nio.channels.FileChannel;
4241
import java.nio.charset.Charset;
4342
import java.nio.charset.StandardCharsets;
43+
import java.nio.file.Files;
4444
import java.util.ArrayList;
4545
import java.util.Arrays;
4646
import java.util.Collections;
@@ -457,8 +457,8 @@ private File convertPlainFileToCompressedFileBasedOnCompressionAlgorithm(File un
457457
File compressedFile) throws IOException {
458458
try (BufferedWriter bufferedWriter = new BufferedWriter(
459459
new OutputStreamWriter(algorithm.getOutputStream(new FileOutputStream(compressedFile)),
460-
Charset.defaultCharset()));) {
461-
Files.readLines(uncompressedInputFile, Charset.defaultCharset()).forEach(n -> {
460+
Charset.defaultCharset()))) {
461+
Files.lines(uncompressedInputFile.toPath()).forEach(n -> {
462462
try {
463463
bufferedWriter.write(n + "\n");
464464
} catch (IOException e) {
@@ -511,7 +511,7 @@ public void customType() throws Exception {
511511
Collections.sort(testLines);
512512

513513
List<TestLine> linesFromSortedFile = new ArrayList<>();
514-
Files.readLines(out, charset).forEach(line -> linesFromSortedFile.add(new TestLine(line)));
514+
Files.lines(out.toPath()).forEach(line -> linesFromSortedFile.add(new TestLine(line)));
515515

516516
assertEquals(testLines, linesFromSortedFile);
517517

oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/datastore/DataStoreTextWriter.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
import java.util.HashSet;
3030
import java.util.Set;
3131
import java.util.concurrent.Callable;
32+
import java.util.stream.Collectors;
3233

3334
import org.apache.commons.io.FileUtils;
3435
import org.apache.jackrabbit.oak.api.Blob;
@@ -230,11 +231,11 @@ public String toString() {
230231
}
231232

232233
private Set<String> loadFromFile(File file) throws IOException {
233-
Set<String> result = new HashSet<>();
234234
if (file.exists()) {
235-
result.addAll(org.apache.jackrabbit.guava.common.io.Files.readLines(file, StandardCharsets.UTF_8));
235+
return Files.lines(file.toPath()).collect(Collectors.toSet());
236+
} else {
237+
return new HashSet<>();
236238
}
237-
return result;
238239
}
239240

240241
private void writeToFile(String fileName, Set<String> blobIds) throws IOException {

oak-segment-tar/src/test/java/org/apache/jackrabbit/oak/segment/file/JournalEntryTest.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
* specific language governing permissions and limitations
1717
* under the License.
1818
*/
19-
2019
package org.apache.jackrabbit.oak.segment.file;
2120

2221
import static org.apache.jackrabbit.oak.segment.file.FileStoreBuilder.fileStoreBuilder;
@@ -25,11 +24,10 @@
2524
import static org.junit.Assert.assertTrue;
2625

2726
import java.io.File;
28-
import java.nio.charset.Charset;
27+
import java.nio.file.Files;
2928
import java.util.List;
3029

3130
import org.apache.jackrabbit.guava.common.base.Splitter;
32-
import org.apache.jackrabbit.guava.common.io.Files;
3331
import org.apache.jackrabbit.oak.segment.SegmentNodeStore;
3432
import org.apache.jackrabbit.oak.segment.SegmentNodeStoreBuilders;
3533
import org.apache.jackrabbit.oak.segment.file.tar.LocalJournalFile;
@@ -70,7 +68,7 @@ public void timestampInJournalEntry() throws Exception{
7068
fileStore.close();
7169

7270
File journal = new File(tempFolder.getRoot(), "journal.log");
73-
List<String> lines = Files.readLines(journal, Charset.defaultCharset());
71+
List<String> lines = Files.readAllLines(journal.toPath());
7472
assertFalse(lines.isEmpty());
7573

7674
String line = lines.get(0);

0 commit comments

Comments
 (0)