liqingwang commented on code in PR #10532:
URL: https://github.com/apache/dolphinscheduler/pull/10532#discussion_r903292100


##########
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/security/impl/ldap/LdapService.java:
##########
@@ -119,7 +120,16 @@ public String ldapLogin(String userId, String userPwd) {
         } catch (NamingException e) {
             logger.error("ldap search error", e);
             return null;
+        } finally {
+            try {
+                if (ctx != null) {
+                    ctx.close();
+                }

Review Comment:
   The reason why we use `try catch` is `ctx.close()` will throw 
`NamingException`. Not using `if` is ok but IDE will remind `Method invocation 
'close' may produce 'NullPointerException'`.  And not using `if` maybe log will 
show some `NullPointerException`, I think is not the best solution. WDYT?
   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to