Skip to content

Header can be empty #123

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
mcix opened this issue Jan 4, 2018 · 4 comments
Closed

Header can be empty #123

mcix opened this issue Jan 4, 2018 · 4 comments
Labels

Comments

@mcix
Copy link

mcix commented Jan 4, 2018

When converting a mimeMessage to Email abject I get the following stack trace.

java.lang.IllegalArgumentException: value is required
	at org.simplejavamail.internal.util.Preconditions.checkNonEmptyArgument(Preconditions.java:15)
	at org.simplejavamail.email.EmailPopulatingBuilder.withHeader(EmailPopulatingBuilder.java:1194)
	at org.simplejavamail.email.EmailPopulatingBuilder.withHeaders(EmailPopulatingBuilder.java:1178)
	at org.simplejavamail.converter.EmailConverter.buildEmailFromMimeMessage(EmailConverter.java:255)
	at org.simplejavamail.converter.EmailConverter.mimeMessageToEmailBuilder(EmailConverter.java:64)
	at org.simplejavamail.converter.EmailConverter.mimeMessageToEmail(EmailConverter.java:55)

One of the headers is in the MimeMessage is an empty string, I found this related issue:
#109

It seems to be the same problem, but in a different case when converting from a mimeMessage.

See (in EmailPopulatingBuilder.java)

public EmailPopulatingBuilder withHeader(@Nonnull String name, @Nonnull Object value) {
        Preconditions.checkNonEmptyArgument(name, "name");
        Preconditions.checkNonEmptyArgument(value, "value");
        this.headers.put(name, String.valueOf(value));
        return this;
    }

Should be

public EmailPopulatingBuilder withHeader(@Nonnull final String name, @Nullable final Object value) {
		checkNonEmptyArgument(name, "name");
		//checkNonEmptyArgument(value, "value");
		headers.put(name, value != null ? String.valueOf(value) : "");
		return this;
	}
@bbottema
Copy link
Owner

bbottema commented Jan 4, 2018

Hi @mcix, this issue should already be solved (#109) in 5.0.0.rc1-SNAPSHOT. Is it possible for you to update to this? You'll need the Nexus snapshots repo.

@mcix
Copy link
Author

mcix commented Jan 4, 2018

Hi @bbottema , yes I did try the 5.0.0.rc1-SNAPSHOT version using the nexus snapshot repo, but that did not solve the problem. The fix in #109 was fixed in src/main/java/org/simplejavamail/email/Email.java, the issue I am referring to is in src/main/java/org/simplejavamail/email/EmailPopulatingBuilder.java

bbottema added a commit that referenced this issue Jan 4, 2018
@bbottema
Copy link
Owner

bbottema commented Jan 4, 2018

I published a new release candidate, 5.0.0.rc2-SNAPSHOT, please try with that.

@mcix
Copy link
Author

mcix commented Jan 4, 2018

Thanks! Tested with 5.0.0.rc2-SNAPSHOT, works 👍

@bbottema bbottema closed this as completed Jan 4, 2018
@bbottema bbottema added the bug label Jul 22, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants