-
-
Notifications
You must be signed in to change notification settings - Fork 953
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 3.0.4: Using both application.yml and application.groovy each with grails.* settings results in broken mimeType handling #9189
Comments
FYI there are a couple of work-arounds to this issue that got me moving again. I settled on option 1 for now since it's more pure grails 3.
|
Thanks for the info Shawn. One of us will look at it right away. |
This issue is understood and is a little bit of a pickle because the behavior is being inherited from boot. I think boot expects the app to be using one or the other, but not both config files. We already override boot's yaml loading so we can improve this situation by changing what we are doing in Grails. However, this would be a change that I think is too drastic to introduce in a 3.0.5 release. If we change that, I think it makes more sense to introduce the new behavior in 3.1. For now I think the thing to do is understand the limitations of the current system and let that guide developers. I think that it is ok to use both If we can agree on this then I think the short term thing to do is update the user guide and the longer term thing is to change the behavior in 3.1 so that the 2 files are properly merged instead of one stepping on the other. @scrain - What do you think? @graemerocher - What do you think? Rest of the community - What do you think? |
This is fine with me given the work arounds available. Should there a be a consideration to change SSC plugin's generation of settings into application.groovy? Not sure if all of its settings can be represented in YAML. Otherwise this will likely bite most users of the plugin. Other option might be a more pro-active detection of the contention between the two files and an explicit error or warning being output during start-up. |
I glanced at the source... looks like SSC's settings should work in YAML, but it would be best to make that the convention for porting the rest of SS's plugins moving forward if that is the desired approach. |
I'm fine with adding a note in the plugin docs and/or moving the config settings to application.yml, but the real fix is to either merge the two correctly or disallow using both. The initial config settings registered by s2-quickstart will work in either format, but there are settings that won't, e.g. ones where the value is a Closure. There's also a significant amount of flexibility when using Groovy format since you can use loops, logic checks, etc. |
Sorry, I should have been clearer in my comment. I didn't mean for this to be considered the real fix, but more of something that could be done relatively quickly to keep users of the plugin from running into this issue while waiting for the longer term solution. I figured there was likely some closure based config out there that would make this not completely viable. |
I am in a situation where using application.groovy is essential because of the need to do conditional logic in the config file for external environment detection. It seems confusing to even have application.yml, as it appears to remove flexibility within the config, and create the need for two files when there is a situation requiring more than YAML can provide. This is probably a naive opinion, but this is my experience so far. |
There isn't really a need for two files. You can use 1 or the other if that is your preference. Each offers their own benefits. Most applications manage fine with just |
I found a solution that did not require a major rework (see the above commit), so I am including the fix in 3.0.5 |
Sample app can be found in github here
If you have both application.yml and application.groovy files each with properties that start with
grails.
the content-type response header for generated controllers returns asapplication/xhtml+xml
instead oftext\html
at which point the browser errors out due to undefined entities.Note: I discovered this while using the new spring security core plugin, since it generates an application.groovy file with several grails.* properties, but the plugin is not required to recreate the issue.
Additional info: Not sure if this is related, but logging the runtime value of
grailsApplication.config.get( 'grails.mime.types' )
shows that the order of the values is effected when an application.groovy file is merged that containsgrails.
properties.mimeTypes order when application.groovy contains NO
grails.
propertiesmimeTypes order when application.groovy contains
grails.
propertiesThe text was updated successfully, but these errors were encountered: