cshannon commented on PR #1874:
URL: https://github.com/apache/activemq/pull/1874#issuecomment-4185395071

   I removed the set from getPrincipals() because this was not only ineficient 
but also not thread safe.
   
   I looked around and the sub classes of SecurityContext.getPrincipals() all 
generally return null, empty set, a new copy of a set or they return 
Subject.getPrincipals() if using Jaas. For null/empty set and a new copy ther 
is no reason to make another copy of course. For Subject.getPrincipals(), that 
set is actually backed by a SynchronizedSet which is not thread safe to iterate 
over (which happens when making a copy) without adding synchronization 
externally, so by removing the copy not only do we avoid the overhead but it's 
actually thread safe now as calling Subject.getPrincipals().contains() is 
thread safe.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
For further information, visit: https://activemq.apache.org/contact


Reply via email to