You are viewing a plain text version of this content. The canonical link for it is here.
Posted to oak-commits@jackrabbit.apache.org by da...@apache.org on 2026/01/27 04:44:04 UTC
(jackrabbit-oak) branch OAK-11950 created (now b1c873a7ed)
This is an automated email from the ASF dual-hosted git repository.
daim pushed a change to branch OAK-11950
in repository https://gitbox.apache.org/repos/asf/jackrabbit-oak.git
at b1c873a7ed OAK-11950 : removed guava's queues.drainUninterruptibly
This branch includes the following new commits:
new b1c873a7ed OAK-11950 : removed guava's queues.drainUninterruptibly
The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
(jackrabbit-oak) 01/01: OAK-11950 : removed guava's queues.drainUninterruptibly
Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
daim pushed a commit to branch OAK-11950
in repository https://gitbox.apache.org/repos/asf/jackrabbit-oak.git
commit b1c873a7edaa4c57c0a1ca128bb1b6dfc20373c0
Author: rishabhdaim <ri...@gmail.com>
AuthorDate: Tue Jan 27 10:13:45 2026 +0530
OAK-11950 : removed guava's queues.drainUninterruptibly
---
.../oak/plugins/document/RevisionTest.java | 49 +++++++++++++++++++++-
1 file changed, 47 insertions(+), 2 deletions(-)
diff --git a/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/RevisionTest.java b/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/RevisionTest.java
index 6f7a01ae24..a99482c08d 100644
--- a/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/RevisionTest.java
+++ b/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/RevisionTest.java
@@ -17,9 +17,11 @@
package org.apache.jackrabbit.oak.plugins.document;
import java.util.ArrayList;
+import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
+import java.util.Objects;
import java.util.Random;
import java.util.Set;
import java.util.concurrent.BlockingQueue;
@@ -34,7 +36,6 @@ import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
-import org.apache.jackrabbit.guava.common.collect.Queues;
import org.apache.jackrabbit.guava.common.util.concurrent.Uninterruptibles;
import org.junit.Test;
@@ -230,7 +231,7 @@ public class RevisionTest {
while (!stop.get()) {
List<Revision> revs = new ArrayList<>();
- Queues.drainUninterruptibly(revisionQueue, revs, 5, 100, TimeUnit.MILLISECONDS);
+ drainUninterruptibly(revisionQueue, revs);
record(revs);
}
@@ -264,4 +265,48 @@ public class RevisionTest {
}
assertTrue(String.format("Duplicate rev seen %s %n Seen %s", duplicates, seenRevs), duplicates.isEmpty());
}
+
+
+
+ // helper methods
+
+ private <E> void drainUninterruptibly(final BlockingQueue<E> q, final Collection<? super E> buffer) {
+
+ Objects.requireNonNull(buffer, "buffer");
+
+ long deadline = System.nanoTime() + TimeUnit.MILLISECONDS.toNanos(100);
+ int added = 0;
+ boolean interrupted = false;
+ try {
+ while (added < 5) {
+ // First drain whatever is readily available
+ added += q.drainTo(buffer, 5 - added);
+
+ if (added < 5) {
+ E e;
+ while (true) {
+ try {
+ long nanosLeft = deadline - System.nanoTime();
+ if (nanosLeft <= 0L) {
+ return;
+ }
+ e = q.poll(nanosLeft, TimeUnit.NANOSECONDS);
+ break;
+ } catch (InterruptedException ex) {
+ interrupted = true; // remember and retry
+ }
+ }
+ if (e == null) {
+ break; // timeout elapsed, nothing more available
+ }
+ buffer.add(e);
+ added++;
+ }
+ }
+ } finally {
+ if (interrupted) {
+ Thread.currentThread().interrupt();
+ }
+ }
+ }
}