Skip to content

Commit

Permalink
Added back missing null check, as the javadoc states.
Browse files Browse the repository at this point in the history
Fixes issue #456

See ac77368

Signed-off-by: Tobias Weimer <tobias.weimer@posteo.de>
  • Loading branch information
tweimer authored and lukasj committed Jan 12, 2021
1 parent 8667fa6 commit 1c83c79
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions mail/src/main/java/jakarta/mail/internet/MimeMessage.java
Expand Up @@ -379,7 +379,10 @@ public Address[] getFrom() throws MessagingException {
*/
@Override
public void setFrom(Address address) throws MessagingException {
setAddressHeader("From", new Address[] { address });
if (address == null)
removeHeader("From");
else
setAddressHeader("From", new Address[] { address });
}

/**
Expand All @@ -397,7 +400,10 @@ public void setFrom(Address address) throws MessagingException {
* @since JvaMail 1.5
*/
public void setFrom(String address) throws MessagingException {
setAddressHeader("From", InternetAddress.parse(address));
if (address == null)
removeHeader("From");
else
setAddressHeader("From", InternetAddress.parse(address));
}

/**
Expand Down Expand Up @@ -479,7 +485,10 @@ public Address getSender() throws MessagingException {
* @since JavaMail 1.3
*/
public void setSender(Address address) throws MessagingException {
setAddressHeader("Sender", new Address[] { address });
if (address == null)
removeHeader("Sender");
else
setAddressHeader("Sender", new Address[] { address });
}

/**
Expand Down

0 comments on commit 1c83c79

Please sign in to comment.