You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by ra...@apache.org on 2020/01/28 09:25:50 UTC

[sling-org-apache-sling-committer-cli] branch master updated: SLING-9034 - The MemebersFinder service throws a NPE if the name is missing from an email address

This is an automated email from the ASF dual-hosted git repository.

radu pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-committer-cli.git


The following commit(s) were added to refs/heads/master by this push:
     new ea8c0ab  SLING-9034 - The MemebersFinder service throws a NPE if the name is missing from an email address
ea8c0ab is described below

commit ea8c0ab907a1d8326b2cc71454c6779b34af06a2
Author: Radu Cotescu <ra...@apache.org>
AuthorDate: Tue Jan 28 10:25:33 2020 +0100

    SLING-9034 - The MemebersFinder service throws a NPE if the name is missing from an email address
---
 src/main/java/org/apache/sling/cli/impl/people/MembersFinder.java | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/main/java/org/apache/sling/cli/impl/people/MembersFinder.java b/src/main/java/org/apache/sling/cli/impl/people/MembersFinder.java
index 49e845d..86639bf 100644
--- a/src/main/java/org/apache/sling/cli/impl/people/MembersFinder.java
+++ b/src/main/java/org/apache/sling/cli/impl/people/MembersFinder.java
@@ -32,6 +32,8 @@ import org.apache.http.client.methods.HttpGet;
 import org.apache.http.impl.client.CloseableHttpClient;
 import org.apache.http.impl.client.HttpClients;
 import org.apache.sling.cli.impl.CredentialsService;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
 import org.osgi.service.component.annotations.Component;
 import org.osgi.service.component.annotations.Reference;
 import org.slf4j.Logger;
@@ -114,11 +116,11 @@ public class MembersFinder {
         return null;
     }
 
-    public Member findByNameOrEmail(String name, String email) {
+    public Member findByNameOrEmail(@Nullable String name, @NotNull String email) {
         Collator collator = Collator.getInstance(Locale.US);
         collator.setDecomposition(Collator.NO_DECOMPOSITION);
         for (Member member : findMembers()) {
-            if (email.equals(member.getEmail()) || collator.compare(name, member.getName()) == 0) {
+            if (email.equals(member.getEmail()) || (name != null && collator.compare(name, member.getName()) == 0)) {
                 return member;
             }
         }