From ea5dfa5210707bd2733170bc3e06e43deef64271 Mon Sep 17 00:00:00 2001 From: HashEngineering Date: Wed, 24 Jul 2024 14:56:05 -0700 Subject: [PATCH] fix: log and remove a deadlock when logging a diff message using the blockchain Signed-off-by: HashEngineering --- .../evolution/AbstractQuorumState.java | 10 +++-- .../org/bitcoinj/evolution/QuorumState.java | 21 ++++++++++ .../bitcoinj/utils/DebugReentrantLock.java | 39 +++++++++++++++++++ .../java/org/bitcoinj/utils/Threading.java | 5 +++ 4 files changed, 72 insertions(+), 3 deletions(-) create mode 100644 core/src/main/java/org/bitcoinj/utils/DebugReentrantLock.java diff --git a/core/src/main/java/org/bitcoinj/evolution/AbstractQuorumState.java b/core/src/main/java/org/bitcoinj/evolution/AbstractQuorumState.java index 9e6d5a958..4b315cacf 100644 --- a/core/src/main/java/org/bitcoinj/evolution/AbstractQuorumState.java +++ b/core/src/main/java/org/bitcoinj/evolution/AbstractQuorumState.java @@ -47,6 +47,7 @@ import org.bitcoinj.quorums.SimplifiedQuorumList; import org.bitcoinj.store.BlockStoreException; import org.bitcoinj.utils.ContextPropagatingThreadFactory; +import org.bitcoinj.utils.DebugReentrantLock; import org.bitcoinj.utils.Threading; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -89,7 +90,8 @@ public abstract class AbstractQuorumState getQueuedThreads() { + return super.getQueuedThreads(); + } + + public Thread getOwner() { + return super.getOwner(); + } +} diff --git a/core/src/main/java/org/bitcoinj/utils/Threading.java b/core/src/main/java/org/bitcoinj/utils/Threading.java index 8632b3616..9e60575da 100644 --- a/core/src/main/java/org/bitcoinj/utils/Threading.java +++ b/core/src/main/java/org/bitcoinj/utils/Threading.java @@ -162,6 +162,11 @@ public static ReentrantLock lock(String name) { return factory.newReentrantLock(name); } + /** creates a lock that gives access to the owner thread **/ + public static DebugReentrantLock debugLock(String name) { + return new DebugReentrantLock(name); + } + public static void setUseDefaultAndroidPolicy(boolean use) { useDefaultAndroidPolicy = use; }