What is the difference between Session.getDefaultInstance(props, authenticator)
and getInstance(props, authenticator)
? In general, when will you choos
For me, it was very important to use getInstance()
instead of getDefaultInstance()
.
Because after mail session properties was changed, mail session still was storing old properties.
So getDefaultInstance()
- it is looks like Singleton.
As docs said:
Note also that the Properties object is used only the first time this method is called, when a new Session object is created. Subsequent calls return the Session object that was created by the first call, and ignore the passed Properties object. Use the getInstance method to get a new Session object every time the method is called.