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



##########
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:
          ```
           ConsumerAndData<?> tuple = queue.take();
           if (tuple == null) {
             break; // queue has been drained and is closed.
           }
   ```
   in the drainAndBlock code I am seeing this. So will POSION  be a 
ConsumerAndData that has null consumer or null data.

##########
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:
          ```
           ConsumerAndData<?> tuple = queue.take();
           if (tuple == null) {
             break; // queue has been drained and is closed.
           }
   ```
   in the drainAndBlock code I am seeing this. So will POSION  be a 
ConsumerAndData that has null consumer or null data?




-- 
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