jakartaee / mail-api

Jakarta Mail Specification project
https://jakartaee.github.io/mail-api
Other
240 stars 100 forks source link

Cannot parse messages without a session #710 #711

Closed jmehrens closed 4 months ago

jmehrens commented 4 months ago

Signed-off-by: jmehrens jason_mehrens@hotmail.com

jmehrens commented 4 months ago

Per @bshannon (R.I.P) on What is the use of javax.mail.Session?:

To add to that... The support for a null Session is there mostly to provide some reasonable behavior in the case where people screw up and fail to create a Session.

Classic! Point being is that null Session is allowed in MimeMessage the fallback is to use the default session when needed. The approach to this patch is to mimic the behavior in Transport.send0 which is:

Session s = (msg.session != null) ? msg.session :
                Session.getDefaultInstance(System.getProperties(), null);

The alternate patch would be to call StreamProvider.provider() in case the session is null. I think this is more consistent with what is already done.

lukasj commented 4 months ago

@jmehrens I'll respin 2.1.3 so this gets there. Do you have anything else for 2.1.3 before I do that?

jmehrens commented 4 months ago

@lukasj The only things that might be worth while are a backport of:

  1. https://github.com/eclipse-ee4j/angus-mail/issues/124 to v1.x
  2. https://github.com/eclipse-ee4j/angus-mail/pull/125 to 1.x