Skip to content

LinkGenerator initialisation ignores additional config overrides #15391

@jglapa

Description

@jglapa

Expected Behavior

This is a follow up from #15330 that was incorrectly diagnosed.

To supplement production overrides other than the ones in application.groovy an extra override file can be used and loaded from external file.

This is done in Application.groovy by using the EnvironmentAware interface:

@Override
    void setEnvironment(Environment environment) {
        Resource resourceConfig = new FileSystemResource('prod-overrides.groovy')
        def parsedConfig = new ConfigSlurper().parse(resourceConfig.getURL())
        environment.propertySources.addFirst(new MapPropertySource("prod-overrides", parsedConfig))
    }

snippet above will add additional config changes based on a file prod-overrides.groovy

the file contains the following:

grails {
    serverURL = 'https://grails7-absolute-link-issue.domain.com'
}

after starting the app by ./gradlew :bootRun and hitting http://localhost:8080/makeLink/index we should get:

Link : https://grails7-absolute-link-issue.domain.com/makeLink/index/1
serverURL: https://grails7-absolute-link-issue.domain.com

this works fine with grails6

Actual Behaviour

when you run the same example on grails7, we get:

Link : http://localhost:8080/makeLink/index/1
serverURL: https://grails7-absolute-link-issue.domain.com

Steps To Reproduce

Run the example application (both versions) observe that grails7 manifest different behaviour. It seem the LinkGenerator initialisation happens earlier and ignores the extra overrides loaded with the additional config.

Looks like asset.pipeline.grails.AssetPipelineAutoConfiguration configures the AssetSupportingCachingLinkGenerator and does not account for the override.

Environment Information

No response

Example Application

https://github.com/jglapa/grails7-absolute-link-issue

Version

7.0.7

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Status

    Done

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions