[ 
https://issues.apache.org/jira/browse/HDDS-13293?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Tsz-wo Sze updated HDDS-13293:
------------------------------
    Description: 
{code:java}
    TableIterator<String, ? extends KeyValue<String, OmKeyInfo>> iterator;
    Table<String, OmKeyInfo> keyTable;
    metadataManager.getLock().acquireReadLock(BUCKET_LOCK, volumeName,
        bucketName);
    try {
      keyTable = metadataManager.getKeyTable(
          getBucketLayout(metadataManager, volumeName, bucketName));
      iterator = getIteratorForKeyInTableCache(recursive, startKey,
          volumeName, bucketName, cacheKeyMap, keyArgs, keyTable);
    } finally {
      metadataManager.getLock().releaseReadLock(BUCKET_LOCK, volumeName,
          bucketName);
    }

    try {
      findKeyInDbWithIterator(recursive, startKey, numEntries, volumeName,
          bucketName, keyName, cacheKeyMap, keyArgs, keyTable, iterator);
    } finally {
      iterator.close();
    }
{code}
In the code above, if the first finally-block throws an exception, the 
iterator.close() in the second finally-block will not be called.

This problem is minor since the finally-block should not throw any exceptions.

  was:
{code}
    TableIterator<String, ? extends KeyValue<String, OmKeyInfo>> iterator;
    Table<String, OmKeyInfo> keyTable;
    metadataManager.getLock().acquireReadLock(BUCKET_LOCK, volumeName,
        bucketName);
    try {
      keyTable = metadataManager.getKeyTable(
          getBucketLayout(metadataManager, volumeName, bucketName));
      iterator = getIteratorForKeyInTableCache(recursive, startKey,
          volumeName, bucketName, cacheKeyMap, keyArgs, keyTable);
    } finally {
      metadataManager.getLock().releaseReadLock(BUCKET_LOCK, volumeName,
          bucketName);
    }

    try {
      findKeyInDbWithIterator(recursive, startKey, numEntries, volumeName,
          bucketName, keyName, cacheKeyMap, keyArgs, keyTable, iterator);
    } finally {
      iterator.close();
    }
{code}
In the code above, if the first try-block throws an exception, the 
iterator.close() in the second finally-block will not be called.

       Priority: Minor  (was: Major)

> In KeyManagerImpl.listStatus(..), iterator may leak
> ---------------------------------------------------
>
>                 Key: HDDS-13293
>                 URL: https://issues.apache.org/jira/browse/HDDS-13293
>             Project: Apache Ozone
>          Issue Type: Bug
>          Components: OM
>            Reporter: Tsz-wo Sze
>            Assignee: Tsz-wo Sze
>            Priority: Minor
>
> {code:java}
>     TableIterator<String, ? extends KeyValue<String, OmKeyInfo>> iterator;
>     Table<String, OmKeyInfo> keyTable;
>     metadataManager.getLock().acquireReadLock(BUCKET_LOCK, volumeName,
>         bucketName);
>     try {
>       keyTable = metadataManager.getKeyTable(
>           getBucketLayout(metadataManager, volumeName, bucketName));
>       iterator = getIteratorForKeyInTableCache(recursive, startKey,
>           volumeName, bucketName, cacheKeyMap, keyArgs, keyTable);
>     } finally {
>       metadataManager.getLock().releaseReadLock(BUCKET_LOCK, volumeName,
>           bucketName);
>     }
>     try {
>       findKeyInDbWithIterator(recursive, startKey, numEntries, volumeName,
>           bucketName, keyName, cacheKeyMap, keyArgs, keyTable, iterator);
>     } finally {
>       iterator.close();
>     }
> {code}
> In the code above, if the first finally-block throws an exception, the 
> iterator.close() in the second finally-block will not be called.
> This problem is minor since the finally-block should not throw any exceptions.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to