You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by ja...@apache.org on 2023/04/20 03:28:38 UTC

[iotdb] 01/01: Fix potential Npe of ShuffleSinkHandle

This is an automated email from the ASF dual-hosted git repository.

jackietien pushed a commit to branch ShuffleNPE
in repository https://gitbox.apache.org/repos/asf/iotdb.git

commit 38ffb8d95c8b5df734b2fbeaae98979c385619ff
Author: Liao Lanyu <14...@qq.com>
AuthorDate: Thu Apr 20 09:13:23 2023 +0800

    Fix potential Npe of ShuffleSinkHandle
    
    (cherry picked from commit 544a33b0a6cbf5cc136d2861d5de6159b803474c)
---
 .../apache/iotdb/db/mpp/execution/exchange/sink/SinkChannel.java    | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/server/src/main/java/org/apache/iotdb/db/mpp/execution/exchange/sink/SinkChannel.java b/server/src/main/java/org/apache/iotdb/db/mpp/execution/exchange/sink/SinkChannel.java
index af52f610fa..da575c2c01 100644
--- a/server/src/main/java/org/apache/iotdb/db/mpp/execution/exchange/sink/SinkChannel.java
+++ b/server/src/main/java/org/apache/iotdb/db/mpp/execution/exchange/sink/SinkChannel.java
@@ -50,6 +50,7 @@ import java.util.List;
 import java.util.Map.Entry;
 import java.util.concurrent.ExecutorService;
 
+import static com.google.common.util.concurrent.Futures.immediateVoidFuture;
 import static com.google.common.util.concurrent.Futures.nonCancellationPropagating;
 import static org.apache.iotdb.db.mpp.common.FragmentInstanceId.createFullId;
 import static org.apache.iotdb.db.mpp.metric.DataExchangeCostMetricSet.SEND_NEW_DATA_BLOCK_EVENT_TASK_CALLER;
@@ -145,6 +146,11 @@ public class SinkChannel implements ISinkChannel {
   @Override
   public synchronized ListenableFuture<?> isFull() {
     checkState();
+    // blocked could be null if this channel is closed before it is opened by ShuffleSinkHandle
+    // return immediateVoidFuture() to avoid NPE
+    if (closed) {
+      return immediateVoidFuture();
+    }
     return nonCancellationPropagating(blocked);
   }