| 1 | package com.renomad.minum.database; | |
| 2 | ||
| 3 | ||
| 4 | import java.util.concurrent.locks.ReentrantLock; | |
| 5 | ||
| 6 | /** | |
| 7 | * A child class which provides access to | |
| 8 | * the {@link ReentrantLock#getOwner()} method, | |
| 9 | * useful for logging who a thread is waiting on | |
| 10 | * when multiple are contending. | |
| 11 | */ | |
| 12 | public class InspectableLock extends ReentrantLock { | |
| 13 | ||
| 14 | /** | |
| 15 | * Provide access to the protected method, {@link ReentrantLock#getOwner()} | |
| 16 | */ | |
| 17 | public Thread getLockOwner() { | |
| 18 |
1
1. getLockOwner : replaced return value with null for com/renomad/minum/database/InspectableLock::getLockOwner → TIMED_OUT |
return this.getOwner(); |
| 19 | } | |
| 20 | ||
| 21 | /** | |
| 22 | * A helper method to get the identifier | |
| 23 | * for a thread, handling null when necessary | |
| 24 | */ | |
| 25 | public static String getLockOwnerIdString(Thread thread) { | |
| 26 |
1
1. getLockOwnerIdString : negated conditional → KILLED |
if (thread == null) { |
| 27 |
1
1. getLockOwnerIdString : replaced return value with "" for com/renomad/minum/database/InspectableLock::getLockOwnerIdString → KILLED |
return "null"; |
| 28 | } else { | |
| 29 | return String.valueOf(thread.threadId()); | |
| 30 | } | |
| 31 | } | |
| 32 | } | |
Mutations | ||
| 18 |
1.1 |
|
| 26 |
1.1 |
|
| 27 |
1.1 |