bbottema/simple-java-mail

Issue with empty Email address criteria

Romixery opened this issue · 4 comments

Hi,
Using version 6.6.1, I got an error when I used clearEmailAddressCriteria.
The error message: argument was assumed nonNull, but was null

The configuration I used:

MailerBuilder
                .withSMTPServer(SERVER_ADDRESS, SERVER_PORT, SERVER_USERNAME, SERVER_PASSWORD)
                .withTransportStrategy(TransportStrategy.SMTP)
                .withSessionTimeout(10 * 1000)
                .clearEmailAddressCriteria() 
                .withDebugLogging(true)
                .buildMailer();

Does anyone know how to fix it or do I have to wait for the bug fix? I investigated through the stack trace and found assumeNotNull checks for empty() of a collection too, so checking every empty collection will cause raise this error.
Thanks.

Can you provide the full stacktrace please.

Sure,

Caused by: java.lang.IllegalArgumentException: argument was assumed nonNull, but was null
	at org.simplejavamail.internal.util.Preconditions.verifyNonnull(Preconditions.java:41) ~[core-module-6.6.1.jar:na]
	at org.simplejavamail.internal.util.Preconditions.assumeNonNull(Preconditions.java:35) ~[core-module-6.6.1.jar:na]
	at org.simplejavamail.mailer.internal.MailerGenericBuilderImpl.buildEmailGovernance(MailerGenericBuilderImpl.java:295) ~[simple-java-mail-6.6.1.jar:na]
	at org.simplejavamail.mailer.internal.MailerImpl.<init>(MailerImpl.java:122) ~[simple-java-mail-6.6.1.jar:na]
	at org.simplejavamail.mailer.internal.MailerRegularBuilderImpl.buildMailer(MailerRegularBuilderImpl.java:209) ~[simple-java-mail-6.6.1.jar:na]

This is fixed in #319, but hasn't been released yet (it's part of a bigger release).

I think this bug appeared in version 6.6.0, so you could try 6.5.4. Unless you work with S/MIME, you won't miss much. That or use the most lenient rules for address validation...

I decided to tackle this in a patch release and it actually revealed another bug that caused this. Fix just released in 6.7.3