- Under the condition that portal experiences intermittent LDAP server socket connection timeout while importing users and groups, certain users will fail to be imported as a result of NullPointerException, because Null value for LdapContext is returned when LDAP connection is initialized.
- Only under the condition that we set log level for PortalLDAPUtil as Debug, we can see the SocketTimeoutException leads to the failure of binding LDAP server.
- The following error message was see without any context:
Areas to improve
- Improve the logging by adding more context to warning message "Failed to bind to the LDAP server", to help diagnose issue in the future.
- Wrap the exception and propagate source exception from PortalLDAPUtil to caller.
- The NPE stack trace stems from method getNameInNamespace in class PortalLDAPUtil at line 434.
we can see there is no NULL check for parameter variable "binding" before the call "binding.getName()", so a NULL value check before line 434 with a suitable log message may be very helpful.
Related Log Snippet, further analysis and recommended approach
Attached for reference