Skip to content

Commit e27b02a

Browse files
rishabhdaimRishabh Kumar
and
Rishabh Kumar
authored
OAK-11556 : removed usage of Guava's Iterables.getFirst with oak-commons API (#2146)
* OAK-11556 : removed usage of Guava's Iterables.getFirst with Streams.findFirst() * OAK-11556 : removed usage of Guava's Iterables.getFirst with oak-commons --------- Co-authored-by: Rishabh Kumar <[email protected]>
1 parent 88c8a2c commit e27b02a

File tree

5 files changed

+8
-5
lines changed

5 files changed

+8
-5
lines changed

oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/property/PropertyIndexTest.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -1041,7 +1041,7 @@ protected Validator getRootValidator(NodeState before, NodeState after, CommitIn
10411041
assertTrue(indexedState.exists());
10421042
Iterable<String> values = indexedState.getStrings("entry");
10431043
assertEquals(1, IterableUtils.size(values));
1044-
assertEquals("/content", Iterables.getFirst(values, null));
1044+
assertEquals("/content", IterableUtils.getFirst(values, null));
10451045

10461046
Mount roMount = mip.getMountByName("foo");
10471047
assertFalse(getNode(indexed, "/oak:index/foo/" + getNodeForMount(roMount)).exists());

oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/OakRepositoryStub.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
import org.apache.jackrabbit.guava.common.collect.Iterables;
2727

2828
import org.apache.jackrabbit.oak.commons.FixturesHelper.Fixture;
29+
import org.apache.jackrabbit.oak.commons.collections.IterableUtils;
2930
import org.apache.jackrabbit.test.NotExecutableException;
3031
import org.apache.jackrabbit.test.RepositoryStub;
3132
import org.apache.jackrabbit.test.RepositoryStubException;
@@ -65,7 +66,7 @@ public Principal getUnknownPrincipal(Session session)
6566
private static RepositoryStub newDelegate(Properties settings)
6667
throws RepositoryException {
6768
// use first fixture for stub with segment-tar as default
68-
Fixture f = Iterables.getFirst(getFixtures(), Fixture.SEGMENT_TAR);
69+
Fixture f = IterableUtils.getFirst(getFixtures(), Fixture.SEGMENT_TAR);
6970
if (f == Fixture.DOCUMENT_MEM) {
7071
return new OakDocumentMemRepositoryStub(settings);
7172
} else if (f == Fixture.DOCUMENT_RDB) {

oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/VersionGCSupport.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ protected static boolean isDefaultNoBranchSplitNewerThan(NodeDocument doc,
306306
if (doc.getSplitDocType() != SplitDocType.DEFAULT_NO_BRANCH) {
307307
return false;
308308
}
309-
Revision r = Iterables.getFirst(doc.getAllChanges(), null);
309+
Revision r = IterableUtils.getFirst(doc.getAllChanges(), null);
310310
return r != null && sweepRevs.isRevisionNewer(r);
311311
}
312312
}

oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStoreSweepTest.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import org.apache.jackrabbit.guava.common.collect.Iterables;
2626
import org.apache.jackrabbit.oak.api.CommitFailedException;
2727
import org.apache.jackrabbit.oak.commons.PathUtils;
28+
import org.apache.jackrabbit.oak.commons.collections.IterableUtils;
2829
import org.apache.jackrabbit.oak.plugins.document.memory.MemoryDocumentStore;
2930
import org.apache.jackrabbit.oak.plugins.document.util.Utils;
3031
import org.apache.jackrabbit.oak.spi.state.NodeBuilder;
@@ -260,7 +261,7 @@ public <T extends Document> List<T> query(Collection<T> collection,
260261
Revision r = null;
261262
for (NodeDocument d : Utils.getAllDocuments(store)) {
262263
if (d.getPath().toString().startsWith("/node-")) {
263-
r = Iterables.getFirst(d.getAllChanges(), null);
264+
r = IterableUtils.getFirst(d.getAllChanges(), null);
264265
break;
265266
}
266267
}

oak-store-spi/src/main/java/org/apache/jackrabbit/oak/plugins/memory/PropertyStates.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
import org.apache.jackrabbit.oak.api.Blob;
3333
import org.apache.jackrabbit.oak.api.PropertyState;
3434
import org.apache.jackrabbit.oak.api.Type;
35+
import org.apache.jackrabbit.oak.commons.collections.IterableUtils;
3536
import org.apache.jackrabbit.oak.plugins.value.Conversions;
3637
import org.apache.jackrabbit.oak.plugins.value.OakValue;
3738
import org.apache.jackrabbit.util.ISO8601;
@@ -89,7 +90,7 @@ public static PropertyState createProperty(
8990
String name, Iterable<Value> values)
9091
throws RepositoryException {
9192
int type = PropertyType.STRING;
92-
Value first = Iterables.getFirst(values, null);
93+
Value first = IterableUtils.getFirst(values, null);
9394
if (first != null) {
9495
type = first.getType();
9596
}

0 commit comments

Comments
 (0)