Skip to content

Commit

Permalink
OAK-10247: oak-commons: remove Guava from public API - remove remaini…
Browse files Browse the repository at this point in the history
…ng uses and add to shaded version to Profiler ignore list (#986)
  • Loading branch information
reschke committed Jun 15, 2023
1 parent ff0bf21 commit b8b7c35
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -66,16 +66,6 @@ private FileIOUtils() {
}
};

/**
* @deprecated use {@link Function#identity()} instead
*/
@Deprecated(since = "1.20.0", forRemoval = true)
public final static com.google.common.base.Function<String, String> passThruTransformer = new com.google.common.base.Function<String, String>() {
@Nullable @Override public String apply(@Nullable String input) {
return input;
}
};

/**
* Sorts the given file externally using the {@link #lexComparator} and removes duplicates.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ public class Profiler implements Runnable {
"sun," +
"com.sun.," +
"com.google.common.," +
"org.apache.jackrabbit.oak.guava.common.," +
"com.mongodb.," +
"org.bson"
).split(",");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import java.util.function.Function;

import org.apache.commons.io.LineIterator;
import org.apache.jackrabbit.guava.common.collect.AbstractIterator;
import org.apache.jackrabbit.oak.commons.FileIOUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand Down Expand Up @@ -93,7 +94,7 @@ public String apply(String s) {
});
}

private static class Impl<T> extends com.google.common.collect.AbstractIterator<T> implements Closeable {
private static class Impl<T> extends AbstractIterator<T> implements Closeable {
private final Iterator<String> iterator;
private final Function<String, T> transformer;
private final File backingFile;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,14 @@
import java.util.function.Supplier;

import org.apache.commons.io.input.ClosedInputStream;
import org.apache.jackrabbit.guava.common.io.ByteSource;

/**
* * This input stream delays accessing the {@link InputStream} until the first byte is read
*/
public class LazyInputStream extends FilterInputStream {

private final com.google.common.io.ByteSource byteSource;
private final ByteSource byteSource;
private final Supplier<InputStream> inputStreamSupplier;

private boolean opened;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,9 @@
import java.util.Set;

import org.apache.commons.io.FileUtils;
import org.apache.jackrabbit.guava.common.base.Function;
import org.apache.jackrabbit.guava.common.base.Splitter;
import org.apache.jackrabbit.guava.common.collect.Iterators;
import org.apache.jackrabbit.guava.common.collect.Sets;
import org.apache.jackrabbit.guava.common.primitives.Longs;
import org.jetbrains.annotations.Nullable;
Expand All @@ -69,7 +71,6 @@
import org.junit.Test;
import org.junit.rules.TemporaryFolder;


/**
* Tests for {@link FileIOUtils}
*/
Expand Down Expand Up @@ -189,21 +190,21 @@ public void sortLargeFileWithCustomComparatorTest() throws IOException {
for (int i = 0; i < numEntries; i++) {
entries[i] = r.nextLong();
}

Iterator<Long> boxedEntries = Longs.asList(entries).iterator();
Iterator<String> hexEntries = com.google.common.collect.Iterators.transform(boxedEntries, new com.google.common.base.Function<Long, String>() {
Iterator<String> hexEntries = Iterators.transform(boxedEntries, new Function<Long, String>() {
@Nullable @Override public String apply(@Nullable Long input) {
return Long.toHexString(input);
}
});
File f = assertWrite(hexEntries, false, numEntries);

Comparator<String> prefixComparator = new Comparator<String>() {
@Override public int compare(String s1, String s2) {
return s1.substring(0, 3).compareTo(s2.substring(0, 3));
}
};

sort(f, prefixComparator);
BufferedReader reader =
new BufferedReader(new InputStreamReader(new FileInputStream(f), UTF_8));
Expand Down

0 comments on commit b8b7c35

Please sign in to comment.