diff --git a/pulsar-functions/runtime/src/main/java/org/apache/pulsar/functions/runtime/KubernetesRuntime.java b/pulsar-functions/runtime/src/main/java/org/apache/pulsar/functions/runtime/KubernetesRuntime.java index 103980fe2a3f8..3d118581055de 100644 --- a/pulsar-functions/runtime/src/main/java/org/apache/pulsar/functions/runtime/KubernetesRuntime.java +++ b/pulsar-functions/runtime/src/main/java/org/apache/pulsar/functions/runtime/KubernetesRuntime.java @@ -284,16 +284,14 @@ public Throwable getDeathException() { @Override public CompletableFuture getFunctionStatus(int instanceId) { CompletableFuture retval = new CompletableFuture<>(); - if (instanceId < 0 || instanceId >= stub.length) { - if (stub == null) { - retval.completeExceptionally(new RuntimeException("Invalid InstanceId")); - return retval; - } - } if (stub == null) { retval.completeExceptionally(new RuntimeException("Not alive")); return retval; } + if (instanceId < 0 || instanceId >= stub.length) { + retval.completeExceptionally(new RuntimeException("Invalid InstanceId")); + return retval; + } ListenableFuture response = stub[instanceId].withDeadlineAfter(GRPC_TIMEOUT_SECS, TimeUnit.SECONDS).getFunctionStatus(Empty.newBuilder().build()); Futures.addCallback(response, new FutureCallback() { @Override