RFR: 8223260: NamingManager should cache InitialContextFactory

Alan Bateman Alan.Bateman at oracle.com
Tue Jan 28 19:29:43 UTC 2020


On 28/01/2020 13:13, Seán Coffey wrote:
> Looks like we can improve performance in this area. I've put together 
> a testcase which exercises the ServiceLoader and keeps track of 
> whether we're able to cache or not.
>
> https://bugs.openjdk.java.net/browse/JDK-8223260
> http://cr.openjdk.java.net/~coffeys/webrev.8223260.v1/webrev/
A WeakHashKey with the TCCL as the key should be okay here. It might be 
cleaner to move the adding to the map to after the two lookups so that 
it's one place rather than two.  ServiceLoader has a stream method so 
the while could be replaced to improve the readability but that is 
probably beyond what you want to do on this issue.

In the test it will spin calling System.gc. Can you put the System.gc() 
before the while lookup and just Thread.sleep(100) instead. There may be 
something in the test infrastructure libs that could use if you want.

-Alan.


More information about the core-libs-dev mailing list