-
Notifications
You must be signed in to change notification settings - Fork 100
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ServiceLoader loads default providers ahead of application providers #350
Comments
The javamail.default.providers file is now loaded on demand. What protocol provider are you trying to use? Is it not being found? |
Ok that's issue for me and what I have seen in the
Don't know if I got you right, but I was loading the providers via this example
Just version number but no issues. With old version it shows the file is loaded but with new version of course it isn't shown Thanks |
Are you trying to replace the real protocol providers with mock protocol providers, for testing? |
Yes, I replaced So there is no chance that loading providers (...and looking for META-INF/javamail.default.providers) is coming back into the |
No, the addition of support for loading providers using the ServiceLoader mechanism A few points... It was never intended that you would replace the javamail.default.providers file. That There was never a well defined mechanism for overriding the included providers. The existing providers were not designed to be extended by users of JavaMail, but Have you tried including a META-INF/services/javax.mail.Provider file in your mock |
Currently I use the 1.5.6 and we run with that. But for sure there will be soltuion got get it mocked. You named already some and I am sure it will work :-). Thanks so far. Update |
Some other people have run into this issue as well and it's now clear that To be clear, an application should never include a javamail.default.providers file. |
What
I just upgraded from 1.5.6 to 1.6.2 and saw that my META-INF/javamail.default.providers is not used anymore.
Why
I watched into the code and saw the difference.
Session
creation the providers were loaded in the constructor (callloadProviders(cl)
in line 225 ).Session
does nothing about the providers.According to current 1.6.2 javadoc documentation use of javamail.default.providers file should continue to work.
Also here https://javaee.github.io/javamail/docs/CHANGES.txt I could not found any documented breaking changes.
Consequence
So my current issue is that I am depending on third library (JavaMailSenderImpl spring-context-support-5 via spring-boot-starter-mail:2.0.6) and their usage is like:
and described behaviour has changed.
Workaround
session.getProviders()
betweenSession.getInstance(
andsession.getTransport
now?The text was updated successfully, but these errors were encountered: