Closed gBomb3000 closed 2 years ago
This is https://github.com/grails3-plugins/mail/issues/12 and will be fixed with the upcoming 2.0.0
There are actually two problems at work here:
ConfigObject
reference is not changed. Here is a workaround in a use site: config.grails.mail.host = ... // Some change to the config
config.grails.mail = config.grails.mail.clone() // Ensure a different hashCode
Fixing this in the plugin would require comparing the config by value rather than hashCode()
, or have the hashCode generated from the actual values rather than the object reference.
I am afraid that the fix for https://github.com/grails3-plugins/mail/issues/12 grails3 only addresses the second point and that the fixed code will never be run. I may be wrong, sorry I don't have the resources to actually try the grails 3 version. Additionally, I had to update the mailSender
ref in mailMessageBuilderFactory
, which may also be required in grails 3:
``` groovy```` event.ctx.getBean('mailMessageBuilderFactory').mailSender = event.ctx.getBean('mailSender')
There is an undefined property named 'beans' in MailGrailsPlugin.groovy ln106 ('def newBeans = beans {').
This property is never accessed and therefore the exceptions is never thrown as the if condition on ln94 ('if (newMailConfigHash != mailConfigHash) {') checks to see if the hash of the old and new ConfigObject are not equal. Unfortunately the ConfigObject returns the same hash regardless of the properties and values it contains.
Both of these issues render the onConfigChange method completely broken and config changes will never be pushed into the plugin.