Thanks Yiqun Lin for the patch, idea looks good.
I noticed the endFileLease is done in DFSClient#closeAllFilesBeingWritten instead of close and abort, any specific reasons? I think keeping the logic inside is safer, since the problem is when an exception is thrown within close/abort, the line endFileLease isn't executed. I hope we can just make sure it's run in any cases (basically your proposal in
HADOOP-13264, but keep the original thrown exception and rethrow that after we call endFileLease).
Also, seems DFSClient#endFileLease does not actually throw any IOExceptions. That could simplify things a little here too.
In the test, can we rephrase this comment?
Maybe to: Construct a new dfsClient to get the same LeaseRenewer instance, to avoid the original client being added to the leaseRenewer again.