On Wed, 29 Sep 2021 10:45:41 GMT, Larry-N 
<github.com+75672469+larr...@openjdk.org> wrote:

> This fix adds a cache of service provider classes to LoginContext (in 
> particular, it's a cache of LoginModules classes). The approach helps to 
> increase the performance of the LoginContext.login() method significantly, 
> especially in a multi-threading environment. Service Loader is used for 
> polling on Service Provider classes, without instantiating LoginModules 
> object if Service Provider name doesn't match record in .config file. The set 
> of service providers is cached for each Context Loader separately.
> This code passed successfully tier1 and tier2 tests on mac os.

src/java.base/share/classes/javax/security/auth/login/LoginContext.java line 
721:

> 719:                         for ( Provider<LoginModule> lm: lmp){
> 720:                             if (lm.type().getName().equals(name)){
> 721:                                 moduleStack[i].module = lm.get();

There is a small behavior change here. Originally the login module class is 
loaded first and then its name is checked. With this change, the name is first 
checked and then class loaded. This is certainly a performance boost but 
unfortunately the test at `test/jdk/javax/security/auth/spi/Loader.java` would 
fail. That test was written to ensure that services provided through a service 
loader are checked first and then fallback to `Class.forName()`. Either you 
need to enhance the test to confirm this in a new way, or it would have to be 
removed.

-------------

PR: https://git.openjdk.java.net/jdk/pull/5748

Reply via email to