Nope, was not following correctly. On obtain we get the FS for the lock, the lock than closed the FS on release (now close). All good.
I found the issue. We create the Filesystem instance, but we have to close it if we don't end up making the Lock instance. That also means we have to create a Filesystem object at the start of each retry.
Seems like SOLR-8169 would take care of this indirectly.
We should still fix this current code. It's fairly simple, I have the code somewhere I think. Forgot that this issue was still open.
Patch with change.
Commit 1720773 from Mark Miller in branch 'dev/trunk'
[ https://svn.apache.org/r1720773 ]
SOLR-8015: HdfsLock may fail to close a FileSystem instance if it cannot immediately obtain an index lock.
Commit 1720775 from Mark Miller in branch 'dev/branches/branch_5x'
[ https://svn.apache.org/r1720775 ]