Skip to content

Commit

Permalink
OAK-11311: Remove usage of Guava ImmutableList - oak-blob-plugins
Browse files Browse the repository at this point in the history
  • Loading branch information
reschke committed Dec 20, 2024
1 parent 36b7820 commit b7b344d
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@
import org.slf4j.LoggerFactory;

import org.apache.jackrabbit.guava.common.base.Stopwatch;
import org.apache.jackrabbit.guava.common.collect.ImmutableList;
import org.apache.jackrabbit.guava.common.collect.Iterators;
import org.apache.jackrabbit.guava.common.io.Closeables;
import org.apache.jackrabbit.guava.common.util.concurrent.ListeningExecutorService;
Expand Down Expand Up @@ -374,7 +373,7 @@ public boolean exists(final DataIdentifier identifier) {
}

public List<DataStoreCacheStatsMBean> getStats() {
return ImmutableList.of(cache.getCacheStats(), cache.getStagingCacheStats());
return List.of(cache.getCacheStats(), cache.getStagingCacheStats());
}

protected CompositeDataStoreCache getCache() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
import java.util.List;
import java.util.Map;

import org.apache.jackrabbit.guava.common.collect.ImmutableList;
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.IOUtils;
import org.apache.commons.io.serialization.ValidatingObjectInputStream;
Expand Down Expand Up @@ -105,7 +104,7 @@ private static boolean notInExceptions(File file, List<String> exceptions) {
* @param path the root of the datastore
*/
public static void moveDownloadCache(final File path) {
final List<String> exceptions = ImmutableList.of("tmp", UPLOAD_STAGING_DIR, DOWNLOAD_DIR);
final List<String> exceptions = List.of("tmp", UPLOAD_STAGING_DIR, DOWNLOAD_DIR);
File newDownloadDir = new File(path, DOWNLOAD_DIR);

FileTreeTraverser.depthFirstPostOrder(path)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@

import org.apache.jackrabbit.guava.common.base.Stopwatch;
import org.apache.jackrabbit.guava.common.collect.FluentIterable;
import org.apache.jackrabbit.guava.common.collect.ImmutableList;
import org.apache.jackrabbit.guava.common.collect.ImmutableListMultimap;
import org.apache.jackrabbit.guava.common.collect.Iterators;
import org.apache.jackrabbit.guava.common.collect.Lists;
Expand Down Expand Up @@ -287,8 +286,7 @@ public List<GarbageCollectionRepoStats> getStats() throws Exception {
}

if (references.containsKey(id)) {
ImmutableList<DataRecord> refRecs = references.get(id);
for(DataRecord refRec : refRecs) {
for(DataRecord refRec : references.get(id)) {
String uniqueSessionId = refRec.getIdentifier().toString()
.substring(SharedStoreRecordType.REFERENCES.getType().length() + 1);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,8 @@
* specific language governing permissions and limitations
* under the License.
*/

package org.apache.jackrabbit.oak.plugins.blob;

import org.apache.jackrabbit.guava.common.collect.ImmutableList;
import org.apache.jackrabbit.core.data.DataIdentifier;
import org.apache.jackrabbit.core.data.DataRecord;
import org.apache.jackrabbit.core.data.DataStoreException;
Expand Down Expand Up @@ -79,7 +77,7 @@ public class SharedDataStoreMarkSweepGarbageCollectorTest {
@Before
public void setUp() throws IOException {
when(whiteboard.track(CheckpointMBean.class)).thenReturn(tracker);
when(tracker.getServices()).thenReturn(ImmutableList.of(checkpointMBean));
when(tracker.getServices()).thenReturn(List.of(checkpointMBean));

when(blobStore.getType()).thenReturn(SHARED);

Expand Down Expand Up @@ -116,7 +114,7 @@ public void markAndSweepShouldFailIfNotAllRepositoriesHaveMarkedReferencesAvaila
@Test
public void markAndSweepShouldSucceedWhenAllRepositoriesAreAvailable() throws Exception {
setupSharedDataRecords("REPO1", "REPO1");
when(blobStore.getAllChunkIds(0L)).thenReturn(ImmutableList.<String>of().iterator());
when(blobStore.getAllChunkIds(0L)).thenReturn(List.<String>of().iterator());

collector.markAndSweep(false, true);

Expand All @@ -133,8 +131,8 @@ private void setupSharedDataRecords(final String refRepoId, final String repoRep
DataRecord repoDataRecord = mock(DataRecord.class);
when(repoDataRecord.getIdentifier()).thenReturn(new DataIdentifier("repository-" + repoRepoId));

List<DataRecord> refs = ImmutableList.of(refDataRecord);
List<DataRecord> repos = ImmutableList.of(repoDataRecord);
List<DataRecord> refs = List.of(refDataRecord);
List<DataRecord> repos = List.of(repoDataRecord);

when(blobStore.getAllMetadataRecords(SharedDataStoreUtils.SharedStoreRecordType.REFERENCES.getType())).thenReturn(refs);
when(blobStore.getAllMetadataRecords(SharedDataStoreUtils.SharedStoreRecordType.REPOSITORY.getType())).thenReturn(repos);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,7 @@
import java.util.Set;
import java.util.UUID;

import org.apache.jackrabbit.guava.common.collect.ImmutableList;
import org.apache.jackrabbit.guava.common.collect.Iterables;
import org.apache.jackrabbit.guava.common.collect.Lists;
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.IOUtils;
import org.apache.jackrabbit.core.data.DataIdentifier;
Expand Down Expand Up @@ -170,7 +168,7 @@ public void testGetAllChunks() throws Exception{
DataIdentifier d10 = new DataIdentifier("d-10");
DataIdentifier d20 = new DataIdentifier("d-20");
DataIdentifier d30 = new DataIdentifier("d-30");
List<DataIdentifier> dis = ImmutableList.of(d10, d20, d30);
List<DataIdentifier> dis = List.of(d10, d20, d30);
List<DataRecord> recs = CollectionUtils.toList(
Iterables.transform(dis, input -> new TimeDataRecord(input)));
OakFileDataStore mockedDS = mock(OakFileDataStore.class);
Expand Down

0 comments on commit b7b344d

Please sign in to comment.