This is an automated email from the ASF dual-hosted git repository. alexott pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/zeppelin.git
The following commit(s) were added to refs/heads/master by this push: new 302c287 Minor refactoring 302c287 is described below commit 302c2873cdb4fb29f0a0d932c18c63f28b3d35c4 Author: Kirill Turchinskii <turchinskii.kir...@gmail.com> AuthorDate: Mon May 4 01:30:35 2020 +0300 Minor refactoring ### What is this PR for? Position literals first in comparisons, if the second argument is null then NullPointerExceptions can be avoided, they will just return false. Then I will move to annotations and other issues that my static analyzer shows (My previous branch was removed because of the multiple problems, so I decided to start over) ### What type of PR is it? Refactoring ### What is the Jira issue? This task is not on jira, but I'll move to this https://issues.apache.org/jira/browse/ZEPPELIN-3225?filter=12348928 ### How should this be tested? https://travis-ci.org/github/KirillTurchinskii/zeppelin/builds/682716706 ### Screenshots (if appropriate) ### Questions: * What else besides annotations (that I will add) I can fix/refactor using static analysis? Author: Kirill Turchinskii <turchinskii.kir...@gmail.com> Closes #3760 from KirillTurchinskii/fix2 and squashes the following commits: 6b4ce16ac [Kirill Turchinskii] Position literals first in comparisons, if the second argument is null then NullPointerExceptions can be avoided, they will just return false. --- .../java/org/apache/zeppelin/realm/LdapRealm.java | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/zeppelin-server/src/main/java/org/apache/zeppelin/realm/LdapRealm.java b/zeppelin-server/src/main/java/org/apache/zeppelin/realm/LdapRealm.java index e33385a..bf8692b 100644 --- a/zeppelin-server/src/main/java/org/apache/zeppelin/realm/LdapRealm.java +++ b/zeppelin-server/src/main/java/org/apache/zeppelin/realm/LdapRealm.java @@ -269,7 +269,7 @@ public class LdapRealm extends JndiLdapRealm { /** * Get groups from LDAP. - * + * * @param principals * the principals of the Subject whose AuthenticationInfo should * be queried from the LDAP server. @@ -353,8 +353,8 @@ public class LdapRealm extends JndiLdapRealm { byte[] cookie = null; try { ldapCtx.addToEnvironment(Context.REFERRAL, "ignore"); - - ldapCtx.setRequestControls(new Control[]{new PagedResultsControl(pageSize, + + ldapCtx.setRequestControls(new Control[]{new PagedResultsControl(pageSize, Control.NONCRITICAL)}); do { @@ -376,7 +376,7 @@ public class LdapRealm extends JndiLdapRealm { final SearchResult group = searchResultEnum.next(); Attribute attribute = group.getAttributes().get(getGroupIdAttribute()); - String groupName = attribute.get().toString(); + String groupName = attribute.get().toString(); String roleName = roleNameFor(groupName); if (roleName != null) { @@ -601,7 +601,7 @@ public class LdapRealm extends JndiLdapRealm { /** * Set Member Attribute Template for LDAP. - * + * * @param template * DN template to be used to query ldap. * @throws IllegalArgumentException @@ -658,7 +658,7 @@ public class LdapRealm extends JndiLdapRealm { /** * Set User Search Attribute Name for LDAP. - * + * * @param userSearchAttributeName * userAttribute to search ldap. */ @@ -718,14 +718,14 @@ public class LdapRealm extends JndiLdapRealm { LdapName searchBaseDn = new LdapName(searchBaseString); // do scope test - if (searchScope.equalsIgnoreCase("base")) { + if ("base".equalsIgnoreCase(searchScope)) { log.debug("DynamicGroup SearchScope base"); return false; } if (!userLdapDn.toString().endsWith(searchBaseDn.toString())) { return false; } - if (searchScope.equalsIgnoreCase("one") && (userLdapDn.size() != searchBaseDn.size() - 1)) { + if ("one".equalsIgnoreCase(searchScope) && (userLdapDn.size() != searchBaseDn.size() - 1)) { log.debug("DynamicGroup SearchScope one"); return false; } @@ -737,7 +737,7 @@ public class LdapRealm extends JndiLdapRealm { NamingEnumeration<SearchResult> searchResultEnum = null; try { searchResultEnum = systemLdapCtx.search(userLdapDn, searchFilter, - searchScope.equalsIgnoreCase("sub") ? SUBTREE_SCOPE : ONELEVEL_SCOPE); + "sub".equalsIgnoreCase(searchScope) ? SUBTREE_SCOPE : ONELEVEL_SCOPE); if (searchResultEnum.hasMore()) { return true; } @@ -759,7 +759,7 @@ public class LdapRealm extends JndiLdapRealm { /** * Set Regex for Principal LDAP. - * + * * @param regex * regex to use to search for principal in shiro. */