You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by gg...@apache.org on 2022/11/25 14:27:12 UTC

[commons-email] branch master updated: Reuse constants

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

ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-email.git


The following commit(s) were added to refs/heads/master by this push:
     new ef02398  Reuse constants
ef02398 is described below

commit ef0239812a031b9d24b91273cb28790d381ec493
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Fri Nov 25 09:27:08 2022 -0500

    Reuse constants
---
 src/main/java/org/apache/commons/mail/Email.java | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/src/main/java/org/apache/commons/mail/Email.java b/src/main/java/org/apache/commons/mail/Email.java
index 83aa178..bc3bec5 100644
--- a/src/main/java/org/apache/commons/mail/Email.java
+++ b/src/main/java/org/apache/commons/mail/Email.java
@@ -54,6 +54,8 @@ import org.apache.commons.mail.util.IDNEmailAddressConverter;
  */
 public abstract class Email
 {
+    private static final InternetAddress[] EMPTY_INTERNET_ADDRESS_ARRAY = new InternetAddress[0];
+
     /** @deprecated since 1.3, use {@link EmailConstants#SENDER_EMAIL} instead */
     @Deprecated
     public static final String SENDER_EMAIL = EmailConstants.SENDER_EMAIL;
@@ -1630,7 +1632,7 @@ public abstract class Email
      */
     protected InternetAddress[] toInternetAddressArray(final List<InternetAddress> list)
     {
-        return list.toArray(new InternetAddress[list.size()]);
+        return list.toArray(EMPTY_INTERNET_ADDRESS_ARRAY);
     }
 
     /**