From 8ca89d2024848548a9c5014156100b96a8c16fcb Mon Sep 17 00:00:00 2001 From: Cody Henthorne Date: Mon, 29 Jul 2024 12:37:40 -0400 Subject: [PATCH] Add additional debugging info to group processing lock handling. --- .../securesms/groups/GroupsV2ProcessingLock.java | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/org/thoughtcrime/securesms/groups/GroupsV2ProcessingLock.java b/app/src/main/java/org/thoughtcrime/securesms/groups/GroupsV2ProcessingLock.java index f3463a83f8..3d077a615b 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/groups/GroupsV2ProcessingLock.java +++ b/app/src/main/java/org/thoughtcrime/securesms/groups/GroupsV2ProcessingLock.java @@ -19,7 +19,7 @@ public final class GroupsV2ProcessingLock { private GroupsV2ProcessingLock() { } - private static final ReentrantLock lock = new ReentrantLock(); + private static final GroupReentrantLock lock = new GroupReentrantLock(); @WorkerThread public static Closeable acquireGroupProcessingLock() throws GroupChangeBusyException { @@ -37,12 +37,12 @@ public final class GroupsV2ProcessingLock { } @WorkerThread - public static Closeable acquireGroupProcessingLock(long timeoutMs) throws GroupChangeBusyException { + private static Closeable acquireGroupProcessingLock(long timeoutMs) throws GroupChangeBusyException { ThreadUtil.assertNotMainThread(); try { if (!lock.tryLock(timeoutMs, TimeUnit.MILLISECONDS)) { - throw new GroupChangeBusyException("Failed to get a lock on the group processing in the timeout period"); + throw new GroupChangeBusyException("Failed to get a lock on the group processing in the timeout period. Owner: " + lock.getOwnerName()); } return lock::unlock; } catch (InterruptedException e) { @@ -50,4 +50,11 @@ public final class GroupsV2ProcessingLock { throw new GroupChangeBusyException(e); } } + + private static class GroupReentrantLock extends ReentrantLock { + String getOwnerName() { + Thread owner = super.getOwner(); + return (owner != null) ? owner.getName() : "null"; + } + } } \ No newline at end of file