This is an automated email from the ASF dual-hosted git repository.
btellier pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git
The following commit(s) were added to refs/heads/master by this push:
new b39ecfb44d JAMES-3827 Support From fields without domain parts in the
email address (#1271)
b39ecfb44d is described below
commit b39ecfb44d95d16bf7d8908908537c7cc133d9b6
Author: Benoit TELLIER <[email protected]>
AuthorDate: Wed Oct 26 09:17:35 2022 +0700
JAMES-3827 Support From fields without domain parts in the email address
(#1271)
```
java.lang.NullPointerException: Cannot invoke
"String.contains(java.lang.CharSequence)" because "s" is nul
at
org.apache.james.mailbox.elasticsearch.json.EMailer.removeTopDomain(EMailer.java:42)
at
org.apache.james.mailbox.elasticsearch.json.EMailer.<init>(EMailer.java:38)
at
org.apache.james.mailbox.elasticsearch.json.HeaderCollection$Builder.lambda$manageAddressField$0(HeaderCollection.java:145)
```
---
.../java/org/apache/james/mailbox/opensearch/json/EMailer.java | 3 +++
.../org/apache/james/mailbox/opensearch/json/EMailerTest.java | 10 ++++++++++
2 files changed, 13 insertions(+)
diff --git
a/mailbox/opensearch/src/main/java/org/apache/james/mailbox/opensearch/json/EMailer.java
b/mailbox/opensearch/src/main/java/org/apache/james/mailbox/opensearch/json/EMailer.java
index 9586236cfe..c035e8583f 100644
---
a/mailbox/opensearch/src/main/java/org/apache/james/mailbox/opensearch/json/EMailer.java
+++
b/mailbox/opensearch/src/main/java/org/apache/james/mailbox/opensearch/json/EMailer.java
@@ -39,6 +39,9 @@ public class EMailer implements SerializableMessage {
}
String removeTopDomain(String s) {
+ if (s == null) {
+ return null;
+ }
if (s.contains(".")) {
return s.substring(0, s.lastIndexOf('.'));
}
diff --git
a/mailbox/opensearch/src/test/java/org/apache/james/mailbox/opensearch/json/EMailerTest.java
b/mailbox/opensearch/src/test/java/org/apache/james/mailbox/opensearch/json/EMailerTest.java
index 48c28936e6..f3790ae555 100644
---
a/mailbox/opensearch/src/test/java/org/apache/james/mailbox/opensearch/json/EMailerTest.java
+++
b/mailbox/opensearch/src/test/java/org/apache/james/mailbox/opensearch/json/EMailerTest.java
@@ -19,6 +19,10 @@
package org.apache.james.mailbox.opensearch.json;
+import static org.assertj.core.api.Assertions.assertThatCode;
+
+import java.util.Optional;
+
import org.junit.jupiter.api.Test;
import nl.jqno.equalsverifier.EqualsVerifier;
@@ -29,4 +33,10 @@ class EMailerTest {
EqualsVerifier.forClass(EMailer.class)
.verify();
}
+
+ @Test
+ void shouldSupportNullDomain() {
+ assertThatCode(() -> new EMailer(Optional.empty(), "localPart", null))
+ .doesNotThrowAnyException();
+ }
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]