hadoop-common-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Vinayakumar B (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (HADOOP-10830) Missing lock in JavaKeyStoreProvider.createCredentialEntry
Date Wed, 16 Jul 2014 07:24:04 GMT

    [ https://issues.apache.org/jira/browse/HADOOP-10830?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14063236#comment-14063236
] 

Vinayakumar B commented on HADOOP-10830:
----------------------------------------

Hi [~benoyantony], thanks for the patch.

There is no need of double try-catch-finally blocks. existing itself you can re-use.
Like following..
{code}  @Override
  public CredentialEntry createCredentialEntry(String alias, char[] credential)
    throws IOException {
    writeLock.lock();
    try {
      if (keyStore.containsAlias(alias) || cache.containsKey(alias)) {
        throw new IOException("Credential " + alias + " already exists in "
            + this);
      }
      return innerSetCredential(alias, credential);
    } catch (KeyStoreException e) {
      throw new IOException("Problem looking up credential " + alias + " in "
          + this, e);
    } finally {
      writeLock.unlock();
    }
  }{code}

anyway {{innerSetCredential(..)}} have its own try-catch block. So its fine to use one try-catch-finally
block itself.

> Missing lock in JavaKeyStoreProvider.createCredentialEntry
> ----------------------------------------------------------
>
>                 Key: HADOOP-10830
>                 URL: https://issues.apache.org/jira/browse/HADOOP-10830
>             Project: Hadoop Common
>          Issue Type: Bug
>          Components: security
>            Reporter: Benoy Antony
>            Assignee: Benoy Antony
>         Attachments: HADOOP-10830.patch
>
>
> _JavaKeyStoreProvider_ uses _ReentrantReadWriteLock_  to provide thread safety.
> The {{createCredentialEntry}} should hold _writeLock_ before adding the entry.



--
This message was sent by Atlassian JIRA
(v6.2#6252)

Mime
View raw message