scwhittle commented on a change in pull request #14480:
URL: https://github.com/apache/beam/pull/14480#discussion_r613082546



##########
File path: 
sdks/java/harness/src/main/java/org/apache/beam/fn/harness/data/QueueingBeamFnDataClient.java
##########
@@ -193,16 +287,24 @@ public void accept(T value) throws Exception {
     }
   }
 
-  static class ConsumerAndData<T> {
-    private final FnDataReceiver<T> consumer;
-    private final T data;
+  private static class ConsumerAndData<T> {
+    private final @Nullable FnDataReceiver<T> consumer;
+    private final @Nullable T data;
+
+    public ConsumerAndData() {
+      this.consumer = null;
+      this.data = null;
+    }
 
     public ConsumerAndData(FnDataReceiver<T> receiver, T data) {
       this.consumer = receiver;
       this.data = data;
     }
 
     void accept() throws Exception {
+      if (consumer == null || data == null) {
+        throw new IllegalStateException("cannot accept POISON");

Review comment:
       I modified the poision so it is more self-contained, it just implements 
a reciever that throws.  Now ConsumerAndData always has non-null elements 
(enforced by nullness checking and default of NonNull annotation) and the 
poison stuff is contained entirely with in ClosableQueue.
   
   The user of the queue just knows that take() returns null once the queue is 
empty and has been closed, otherwiise non-null and never the poison.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to