From 64e2deba53f696882f517a6010b81d83b55389b7 Mon Sep 17 00:00:00 2001 From: wangtaohz <103108928+wangtaohz@users.noreply.github.com> Date: Mon, 30 Oct 2023 21:33:48 +0800 Subject: [PATCH] Core: Fix NPE when calling InMemoryLockManager#release using Hadoop catalog (#8494) --- core/src/main/java/org/apache/iceberg/util/LockManagers.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/core/src/main/java/org/apache/iceberg/util/LockManagers.java b/core/src/main/java/org/apache/iceberg/util/LockManagers.java index ed141bdf7ba1..2dc7406d92b6 100644 --- a/core/src/main/java/org/apache/iceberg/util/LockManagers.java +++ b/core/src/main/java/org/apache/iceberg/util/LockManagers.java @@ -19,6 +19,7 @@ package org.apache.iceberg.util; import java.util.Map; +import java.util.Optional; import java.util.concurrent.Executors; import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.ScheduledFuture; @@ -253,7 +254,7 @@ public boolean release(String entityId, String ownerId) { return false; } - HEARTBEATS.remove(entityId).cancel(false); + Optional.ofNullable(HEARTBEATS.remove(entityId)).ifPresent(future -> future.cancel(false)); LOCKS.remove(entityId); return true; }