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