HADOOP-10831. UserProvider is not thread safe. (Benoy Antony via umamahesh)

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1610789 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Uma Maheswara Rao G 2014-07-15 18:15:46 +00:00
parent b60ef8b91b
commit 65b0cfc96b
3 changed files with 9 additions and 5 deletions

View File

@ -379,6 +379,8 @@ Trunk (Unreleased)
NativeAzureFileSystem#NativeAzureFsInputStream#close(). NativeAzureFileSystem#NativeAzureFsInputStream#close().
(Chen He via cnauroth) (Chen He via cnauroth)
HADOOP-10831. UserProvider is not thread safe. (Benoy Antony via umamahesh)
OPTIMIZATIONS OPTIMIZATIONS
HADOOP-7761. Improve the performance of raw comparisons. (todd) HADOOP-7761. Improve the performance of raw comparisons. (todd)

View File

@ -29,6 +29,8 @@
* abstraction to separate credential storage from users of them. It * abstraction to separate credential storage from users of them. It
* is intended to support getting or storing passwords in a variety of ways, * is intended to support getting or storing passwords in a variety of ways,
* including third party bindings. * including third party bindings.
*
* <code>CredentialProvider</code> implementations must be thread safe.
*/ */
@InterfaceAudience.Public @InterfaceAudience.Public
@InterfaceStability.Unstable @InterfaceStability.Unstable

View File

@ -55,7 +55,7 @@ public boolean isTransient() {
} }
@Override @Override
public CredentialEntry getCredentialEntry(String alias) { public synchronized CredentialEntry getCredentialEntry(String alias) {
byte[] bytes = credentials.getSecretKey(new Text(alias)); byte[] bytes = credentials.getSecretKey(new Text(alias));
if (bytes == null) { if (bytes == null) {
return null; return null;
@ -64,7 +64,7 @@ public CredentialEntry getCredentialEntry(String alias) {
} }
@Override @Override
public CredentialEntry createCredentialEntry(String name, char[] credential) public synchronized CredentialEntry createCredentialEntry(String name, char[] credential)
throws IOException { throws IOException {
Text nameT = new Text(name); Text nameT = new Text(name);
if (credentials.getSecretKey(nameT) != null) { if (credentials.getSecretKey(nameT) != null) {
@ -77,7 +77,7 @@ public CredentialEntry createCredentialEntry(String name, char[] credential)
} }
@Override @Override
public void deleteCredentialEntry(String name) throws IOException { public synchronized void deleteCredentialEntry(String name) throws IOException {
byte[] cred = credentials.getSecretKey(new Text(name)); byte[] cred = credentials.getSecretKey(new Text(name));
if (cred != null) { if (cred != null) {
credentials.removeSecretKey(new Text(name)); credentials.removeSecretKey(new Text(name));
@ -95,7 +95,7 @@ public String toString() {
} }
@Override @Override
public void flush() { public synchronized void flush() {
user.addCredentials(credentials); user.addCredentials(credentials);
} }
@ -112,7 +112,7 @@ public CredentialProvider createProvider(URI providerName,
} }
@Override @Override
public List<String> getAliases() throws IOException { public synchronized List<String> getAliases() throws IOException {
List<String> list = new ArrayList<String>(); List<String> list = new ArrayList<String>();
List<Text> aliases = credentials.getAllSecretKeys(); List<Text> aliases = credentials.getAllSecretKeys();
for (Text key : aliases) { for (Text key : aliases) {