TsReaper commented on a change in pull request #11688: [FLINK-16636] Fix 
possible NPE in Utils.CollectHelper
URL: https://github.com/apache/flink/pull/11688#discussion_r406637302
 
 

 ##########
 File path: flink-java/src/main/java/org/apache/flink/api/java/Utils.java
 ##########
 @@ -138,6 +138,12 @@ public void writeRecord(T record) throws IOException {
 
                @Override
                public void close() {
+                       // when the sink is up but not initialized and the job 
fails due to other operators,
+                       // it is possible that close() is called when open() is 
not called,
+                       // so we have to do this null check
+                       if (accumulator == null) {
+                               accumulator = new SerializedListAccumulator<>();
 
 Review comment:
   The user of this `CollectHelper` expects this accumulator to appear in the 
result. Not adding this accumulator will result in additional checks on the 
user side.

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


With regards,
Apache Git Services

Reply via email to