-
Notifications
You must be signed in to change notification settings - Fork 951
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
GRAILS-8978: Respect grails.views.gsp.htmlcodec configuration #548
Conversation
199124f
to
c1a2857
Compare
public Encoder getEncoder() { | ||
if(encoder == null){ | ||
GrailsApplication grailsApplication = grails.util.Holders.getGrailsApplication(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what was the motivation in using the static holder version rather than GrailsApplicationAware?
@graemerocher the setGrailsApplication method is never called. It appears that GrailsApplicationAware doesn't work for this case (I'm not sure if that's intentional or not, but I did confirm that this codec is the only one that tries to use GrailsApplicationAware). |
is HTMLCodec being subjected to DI? I think GrailsApplicationAware would cause the property to be auto initialized if the thing were a bean in the context. I don't think that is the case, or is it? |
When I debugged through it, it didn't appear to be a bean. I suspect that it's not and not intended to be one which explains why GrailsApplicationAware/setGrailsApplication isn't executed. In that case, I think either some changes need to be made making it a bean or an approach such as the one in this PR needs to be used. |
The correct fix would be get it to honour GrailsApplicationAware, we try to avoid the use of the statics going forward |
DefaultCodecLookup is already a bean in the application context and it is already GrailsApplicationAware. It might end up being really simple to add code there which initializes the grailsApplication property in the codecs. |
DefaultCodecLookup tries to perform injection on the codec class in DefaultCodecLookup.autowireCodecBean. However, grailsApplication is null, so it never actually does anything. Line 775 in 2ac245a
|
c2cccc1
to
5ef9acc
Compare
All set - IMHO, this PR is ready for merging. I created a simple Grails app to test that the grails.views.gsp.htmlcodec setting takes effect, and it does. The PR includes updates to the tests to test this functionality. |
Thanks Craig. We will take a look. |
Respect grails.views.gsp.htmlcodec configuration Commit 5037e65 intended for the grails.views.gsp.htmlcodec setting to take effect. This commit fixes the implementation so that setting is respected. Issue: GRAILS-8978
Polite prodding It would be super cool to get this merged - let me know if there's anything I can do to help. |
GRAILS-8978: Respect grails.views.gsp.htmlcodec configuration
Commit 5037e65 intended for the grails.views.gsp.htmlcodec setting to take effect. This commit fixes the implementation so that setting is respected.
https://jira.grails.org/browse/GRAILS-8978