Skip to content

KNOX-2233 - DefaultKeystoreService getCredentialForCluster uses cache…#264

Merged
pzampino merged 1 commit intoapache:masterfrom
pzampino:master
Feb 12, 2020
Merged

KNOX-2233 - DefaultKeystoreService getCredentialForCluster uses cache…#264
pzampino merged 1 commit intoapache:masterfrom
pzampino:master

Conversation

@pzampino
Copy link
Copy Markdown
Contributor

… without synchronization

What changes were proposed in this pull request?

Added synchronization to getCredentialForCluster(String, String) since it uses/updates the cache (e.g., checkCache(String, String), addToCache(String, String, String)). At a minimum, this avoids potential repeated unnecessary keystore file accesses for the same alias.

How was this patch tested?

Performed some manual testing, but since the overall behavior should not change, ran all existing tests as validation.

addToCache(clusterName, alias, credentialString);
char[] credential;

synchronized (this) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of synchronizing the whole block wouldn't it be better to add something like a ReadWriteLock ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The intention here is to complete the existing synchronization pattern. More drastic changes merit a separate JIRA IMO.

@pzampino pzampino merged commit 186ca4a into apache:master Feb 12, 2020
stoty pushed a commit to stoty/knox that referenced this pull request May 14, 2024
… without synchronization (apache#264)

Change-Id: I4a5949df9694fcb8ce2b3580cf8aeaafc777a4b1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants