Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8206308

NullPointerException on LDAP bind using com.sun.jndi.ldap.LdapCtxFactory

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Cannot Reproduce
    • Icon: P3 P3
    • None
    • 8u161
    • core-libs

      Unexpected NullPointerException can be thrown on establishing of connection
      with LDAP server using initial context factory
      com.sun.jndi.ldap.LdapCtxFactory.
      The exception stack trace like the one below is reported:
      Caused by: java.lang.NullPointerException: null
              at com.sun.jndi.ldap.LdapClient.authenticate(LdapClient.java:300)
              at com.sun.jndi.ldap.LdapCtx.connect(LdapCtx.java:2791)
              at com.sun.jndi.ldap.LdapCtx.<init>(LdapCtx.java:319)
              at com.sun.jndi.ldap.LdapCtxFactory.getUsingURL(LdapCtxFactory.java:192)
              at com.sun.jndi.ldap.LdapCtxFactory.getUsingURLs(LdapCtxFactory.java:210)
              at com.sun.jndi.ldap.LdapCtxFactory.getLdapCtxInstance(LdapCtxFactory.java:153)
              at com.sun.jndi.ldap.LdapCtxFactory.getInitialContext(LdapCtxFactory.java:83)
              at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:684)
              at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:313)
              at javax.naming.InitialContext.init(InitialContext.java:244)
              at javax.naming.InitialContext.<init>(InitialContext.java:216)
              at javax.naming.directory.InitialDirContext.<init>(InitialDirContext.java:101)

      I suspect that it could be caused by JVM defect JDK-8205330
      (https://bugs.java.com/bugdatabase/view_bug.do?bug_id=JDK-8205330), though, Icould not reproduce the issue with BER logs (using
      com.sun.jndi.ldap.trace.ber).
      Thus, I cannot prove that "Notice of Disconnection" was issued by LDAP
      server.

      As NPE is not an expected exception which can be thrown on InitialDirContext
      creation, the exception handling logic on InitialDirContext creation usually
      only handles NamingExceptions. As result, the unhandled NPE can cause crashes
      of applications.

      It does not look like there is a work around for the issue apart form
      strengthening the exception handling logic to catch all RuntimeExceptions

      Environment:
      JVM Version: 1.8.0_161-b12
      OS : Linux version: 3.10.0-514.6.1.el7.x86_64 arch: amd64 cores: 4

            robm Robert Mckenna
            shadowbug Shadow Bug
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: