static FileLock takeDirectoryLockIfExists(File directory) {
        if (new File(directory, ".lock").exists()) {
            return takeDirectoryLock(directory);
        } else {
            return null;
        }
    }
Take the FileLock in the given directory, if it already exists. Technically, there is a
TOCTOU bug here where someone could create and lock the lockfile in between our check
and our use. However, this is very unlikely to ever be a problem in practice, and closing
this hole would require the parent directory to always be writable when loading a
snapshot so that we could create our .lock file there.
shell/src/main/java/org/apache/kafka/shell/MetadataShell.java