[12] RFR 8210695: Create test to cover JDK-8205330 InitialDirContext ctor sometimes throws NPE if the server has sent a disconnection

Daniel Fuchs daniel.fuchs at oracle.com
Thu Sep 13 09:43:39 UTC 2018

Hi Chris,

Thanks a lot for writing this test!

   60         serverSocket = new ServerSocket(0);
   69         env.put(Context.PROVIDER_URL, 

For robustness of the test I would suggest using
InetAddress.getLoopbackAddress() explicitly, to
avoid having the dummy server listen on all interfaces.
Listening on all interfaces has proved to be a source of
intermittent failures in the past, possibly due
to different port reuse strategies at OS level.

   88                     System.out.println("(" + count + "/" + 
   89                             + ") It's ok to get NamingException: " 
+ ne);
   90                     // for debug
   91                     ne.printStackTrace();

I think it would be better in that case to print the stactrace on
stdout (i.e. use ne.printStackTrace(System.out)), since that
exception is expected and not considered as an error.

best regards,

-- daniel

On 13/09/2018 07:59, Chris Yin wrote:
> Please have a review for below new added test to cover JDK-8205330, thanks
> This test used dummy ldap server to simulate the scenario to send “Notice of Disconnection” after binding, it will repeat InitialDirContext() for 1000 times (normally the NPE bug should be hit less than 100 times run, but just in case), test failed with NPE if without JDK-8205330 fix change and passed after the fix.
> I put this test under test/jdk/com/sun/jndi/ldap/ since the bug root cause is from com.sun.jndi.ldap.LdapClient, feel free to let me know if it should be moved to other suitable folder.
> bug: https://bugs.openjdk.java.net/browse/JDK-8210695
> webrev: http://cr.openjdk.java.net/~xyin/8210695/webrev.00/
> Regards,
> Chris

More information about the core-libs-dev mailing list