Skip to content

Conversation

tulinkry
Copy link
Contributor

@tulinkry tulinkry commented May 2, 2017

The scenario before needlessly slowed the authorization process as it exclusively allowed only one thread processing the stack of plugins.

The problem with the synchronization here is that we don't want to concurrently share the stack when there is a reload of plugins while there is some authorization in progress. ReadWrite lock is more accurate for this situation.

@tulinkry tulinkry self-assigned this May 2, 2017
@tulinkry tulinkry force-pushed the auth-better-locking branch from cc557b9 to 1c9795d Compare May 2, 2017 15:19
@@ -74,6 +76,11 @@
AuthorizationStack stack;

/**
* Lock for safe reloads.
*/
private ReadWriteLock lock = new ReentrantReadWriteLock();
Copy link
Member

Choose a reason for hiding this comment

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

explain why it needs to be reentrant

Copy link
Contributor Author

Choose a reason for hiding this comment

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

because that is the only class implementing the ReadWriteLock interface

@@ -646,6 +657,11 @@ private boolean checkAll(HttpServletRequest request, String cache, Nameable enti
* @return true if entity is allowed; false otherwise
*/
private synchronized boolean performCheck(Nameable entity, Predicate<IAuthorizationPlugin> predicate) {
Copy link
Member

Choose a reason for hiding this comment

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

the synchronized should still be present ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

no it should not, that is my merge problem

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

@tulinkry tulinkry force-pushed the auth-better-locking branch from 1c9795d to 7d1d03b Compare May 2, 2017 21:04
@tulinkry tulinkry added this to the 1.1 milestone May 2, 2017
@vladak vladak merged commit 600ba64 into oracle:master May 3, 2017
@tulinkry tulinkry deleted the auth-better-locking branch May 3, 2017 09:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants