Source:
<code>public OzoneFileStatus getFileStatus(OmKeyArgs args) throws IOException { Preconditions.checkNotNull(args, "Key args can not be null"); String volumeName = args.getVolumeName(); String bucketName = args.getBucketName(); String keyName = args.getKeyName(); try { <START> metadataManager.getLock().acquireBucketLock(volumeName, bucketName); <END> if (keyName.length() == 0) { validateBucket(volumeName, bucketName); return new OzoneFileStatus(OZONE_URI_DELIMITER); } String fileKeyBytes = metadataManager.getOzoneKey( volumeName, bucketName, keyName); OmKeyInfo fileKeyInfo = metadataManager.getKeyTable().get(fileKeyBytes); if (fileKeyInfo != null) { return new OzoneFileStatus(fileKeyInfo, scmBlockSize, false); } String dirKey = OzoneFSUtils.addTrailingSlashIfNeeded(keyName); String dirKeyBytes = metadataManager.getOzoneKey( volumeName, bucketName, dirKey); OmKeyInfo dirKeyInfo = metadataManager.getKeyTable().get(dirKeyBytes); if (dirKeyInfo != null) { return new OzoneFileStatus(dirKeyInfo, scmBlockSize, true); } List<OmKeyInfo> keys = metadataManager.listKeys(volumeName, bucketName, null, dirKey, 1); if (keys.iterator().hasNext()) { return new OzoneFileStatus(keyName); } LOG.debug("Unable to get file status for the key: volume:" + volumeName + " bucket:" + bucketName + " key:" + keyName + " with error no " + "such file exists:"); throw new OMException("Unable to get file status: volume: " + volumeName + " bucket: " + bucketName + " key: " + keyName, ResultCodes.FILE_NOT_FOUND); } finally { metadataManager.getLock().releaseBucketLock(volumeName, bucketName); } }</code><technical_language>do move acquireBucketLock try block? original pattern good me</technical_language>

Target:
public OzoneFileStatus getFileStatus(OmKeyArgs args) throws IOException { Preconditions.checkNotNull(args, "Key args can not be null"); String volumeName = args.getVolumeName(); String bucketName = args.getBucketName(); String keyName = args.getKeyName(); metadataManager.getLock().acquireBucketLock(volumeName, bucketName); try { if (keyName.length() == 0) { validateBucket(volumeName, bucketName); return new OzoneFileStatus(OZONE_URI_DELIMITER); } String fileKeyBytes = metadataManager.getOzoneKey( volumeName, bucketName, keyName); OmKeyInfo fileKeyInfo = metadataManager.getKeyTable().get(fileKeyBytes); if (fileKeyInfo != null) { return new OzoneFileStatus(fileKeyInfo, scmBlockSize, false); } String dirKey = OzoneFSUtils.addTrailingSlashIfNeeded(keyName); String dirKeyBytes = metadataManager.getOzoneKey( volumeName, bucketName, dirKey); OmKeyInfo dirKeyInfo = metadataManager.getKeyTable().get(dirKeyBytes); if (dirKeyInfo != null) { return new OzoneFileStatus(dirKeyInfo, scmBlockSize, true); } List<OmKeyInfo> keys = metadataManager.listKeys(volumeName, bucketName, null, dirKey, 1); if (keys.iterator().hasNext()) { return new OzoneFileStatus(keyName); } LOG.debug("Unable to get file status for the key: volume:" + volumeName + " bucket:" + bucketName + " key:" + keyName + " with error no " + "such file exists:"); throw new OMException("Unable to get file status: volume: " + volumeName + " bucket: " + bucketName + " key: " + keyName, ResultCodes.FILE_NOT_FOUND); } finally { metadataManager.getLock().releaseBucketLock(volumeName, bucketName); } }