Thanks for the reviews, Lei (Eddy) Xu and Xiao Chen.
Could you help me to understand where does stopWriterThread interrupt slowWriterThread?
stopWriterThread will call an operation that eventually leads to:
ReplicaInPipeline#stopWriter interrupts the existing writer thread and then tries to join it.
Should we break the while loop if the Thread holding this semaphore being interrupted?
Hmm. No one thread "holds" a semaphore. Are you proposing breaking on INE in uninterruptiblyAcquire? We cannot do that because it would lead to the slowWriter thread terminating immediately when ReplicaInPipeline#stopWriter was called. This defeats the point of the test, which is to ensure that nobody is holding the FsDatasetImpl lock when calling ReplicaInPipeline#stopWriter.
javadoc of uninterruptiblyAcquire has redundant parameter:
We could use GenericTestUtils#assertExceptionContains
Good question. I did not want to use this method, because on failure throws an exception which is different than the exception which it is checking. I want to see the original exception if there is a failure.
javadoc on testStopWorker should be updated (replace initReplicaRecovery)
removed extra spaces.