Skip to content

Commit

Permalink
OAK-11448: Remove usage of Guava Files.readLines() (#2046)
Browse files Browse the repository at this point in the history
* 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()
  • Loading branch information
reschke authored Feb 2, 2025
1 parent 24c83ec commit ad3254e
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@

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;
Expand All @@ -41,6 +40,7 @@
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;
Expand Down Expand Up @@ -457,8 +457,8 @@ private File convertPlainFileToCompressedFileBasedOnCompressionAlgorithm(File un
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) {
Expand Down Expand Up @@ -511,7 +511,7 @@ public void customType() throws Exception {
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);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
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;
Expand Down Expand Up @@ -230,11 +231,11 @@ public String toString() {
}

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 {
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.segment.file;

import static org.apache.jackrabbit.oak.segment.file.FileStoreBuilder.fileStoreBuilder;
Expand All @@ -25,11 +24,10 @@
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;
Expand Down Expand Up @@ -70,7 +68,7 @@ public void timestampInJournalEntry() throws Exception{
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);
Expand Down

0 comments on commit ad3254e

Please sign in to comment.