Skip to content

Header can be empty #123

Closed
Closed

Description

@mcix

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;
	}

Activity

  1. bbottema commented on Jan 4, 2018

    @bbottema
    Owner

    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.

  2. mcix commented on Jan 4, 2018

    @mcix
    Author

    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

  3. added a commit that references this issue on Jan 4, 2018
  4. bbottema commented on Jan 4, 2018

    @bbottema
    Owner

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

  5. mcix commented on Jan 4, 2018

    @mcix
    Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions