You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
To my understanding from the javadoc, poll() should be consistent with isEmpty() return value and thus should never return null is if isEmpty returns false. Using the snippet below I observed a different behaviour
import java.io.Serializable;
import java.util.Objects;
import org.agrona.concurrent.ManyToOneConcurrentArrayQueue;
import java.util.concurrent.ForkJoinPool;
import java.util.concurrent.atomic.AtomicBoolean;
public class AgroTest {
public static void main(String[] args) {
ManyToOneConcurrentArrayQueue<TestMsg> queue = new ManyToOneConcurrentArrayQueue<>(1000);
AtomicBoolean finished = new AtomicBoolean(false);
long msgsToSend = 1_000_000_000;
ForkJoinPool.commonPool().execute(() -> {
TestMsg payload = new TestMsg("TestMe", new Payload(0xdeadbeef));
for (long element = 0; element < msgsToSend; element++) {
queue.offer(payload);
}
finished.setRelease(true);
});
while(!finished.getAcquire() || !queue.isEmpty()) {
while(!queue.isEmpty()) {
Objects.requireNonNull(queue.poll());
}
}
}
private record Payload(int value) implements Serializable {}
private record TestMsg(String name, Payload payload) implements Serializable {}
}
Output:
Exception in thread "main" java.lang.NullPointerException
at java.base/java.util.Objects.requireNonNull(Objects.java:208)
at io.reacted.examples.benchmarking.AgroTest.main(AgroTest.java:34)
The text was updated successfully, but these errors were encountered:
To my understanding from the javadoc, poll() should be consistent with isEmpty() return value and thus should never return null is if isEmpty returns false. Using the snippet below I observed a different behaviour
Output:
The text was updated successfully, but these errors were encountered: