You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm using simple-java-mail 6.4.3 with batch-module and try to understand how is it guaranteed for onSuccess and onException handlers that their setting will be performed before their usage?
So the assumption is that the user would set the handlers right after calling the send method, which should always take less time than sending the email, even when it's set to skip sending and only log. So in practice this shouldn't be an issue, but I agree it's not a very elegant approach.
I'll change this behavior to be more in line with how promised/futures work so the handlers will always be invoked.
bbottema
changed the title
Async email sending callbacks execution guarantee
Always invoke async success/exception handlers even if set after sending email (behaving more like promises/futures)
Oct 25, 2020
I'm using simple-java-mail 6.4.3 with batch-module and try to understand how is it guaranteed for
onSuccess
andonException
handlers that their setting will be performed before their usage?AsyncOperationHelper
contains commentsimple-java-mail/modules/batch-module/src/main/java/org/simplejavamail/internal/batchsupport/AsyncOperationHelper.java
Line 59 in 2ec2162
But if I correctly understand it's still possible (if inner
NamedRunnable
will be executed fast) thatsimple-java-mail/modules/batch-module/src/main/java/org/simplejavamail/internal/batchsupport/AsyncOperationHelper.java
Line 62 in 2ec2162
E.g. I tried to perform simple test based on example from site:
In this case the callback was executed successfully.
But if the main thread will sleep for some time, e.g.
The callback was not executed at all because
simple-java-mail/modules/batch-module/src/main/java/org/simplejavamail/internal/batchsupport/AsyncResponseImpl.java
Line 39 in 860a0d5
onSuccess
method was not called yet andsuccessHandler
was stillnull
.Do I understand something wrong or is it a bug?
This can probably be solved if callbacks will be passed directly into the
sendMail
method and then directly into theAsyncResponseImpl
constructorsimple-java-mail/modules/batch-module/src/main/java/org/simplejavamail/internal/batchsupport/AsyncOperationHelper.java
Line 56 in 2ec2162
The text was updated successfully, but these errors were encountered: