-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Only convert config placeholders when necessary #9310
Conversation
This fixes the build broken by #9310. Basically: https://github.com/micronaut-projects/micronaut-core/blob/94f458ac04b0180a989d0cf28984d5e3b5df592f/http-client/src/test/groovy/io/micronaut/http/client/filter/StaticClientFilterSpec.groovy#L24-L28 The resolution of micronaut.server.port used to request the value of test-port as String. With this patch, it requests the value as Object instead (`.getValue(Object.class)`). Object is not cachable however, so it gets a new uncached random port, which causes the test failure. I don't really understand the distinction between cachable and non-cachable types. Making all types cacheable causes other test failures that request types like Map. This change (allowing caching for Object) seems to only affect placeholder resolution, and does not cause additional test failures.
@graemerocher this breaks the build because it breaks caching for placeholders. Basically: Lines 24 to 28 in 94f458a
The resolution of micronaut.server.port used to request the value of test-port as String. With this patch, it requests the value as Object instead ( I'm not really sure how to fix it. I tried making Object cachable. That did not resolve the issue, because the caching for Object and String happens separately. I think this logic is a bit weird in the first place, e.g. if you were to request test-port manually as int, it will return a new random port. But I don't want to open the can of worms of rewriting this. micronaut-core/inject/src/main/java/io/micronaut/context/env/PropertySourcePropertyResolver.java Line 315 in 75b767e
Maybe we just need to revert this PR. |
It seems to me like caching is a bit "misused" here. For the caching purposes (converting the same value to the same type every time) it makes sense to cache this way. But for preventing regeneration of the random value, the value should be cached regardless of requested type. Maybe there should be a two-level cache, one depending on the requested type, one depending on the actual unconverted type of the value. |
This fixes the build broken by #9310. Basically: https://github.com/micronaut-projects/micronaut-core/blob/94f458ac04b0180a989d0cf28984d5e3b5df592f/http-client/src/test/groovy/io/micronaut/http/client/filter/StaticClientFilterSpec.groovy#L24-L28 The resolution of micronaut.server.port used to request the value of test-port as String. With this patch, it requests the value as Object instead (`.getValue(Object.class)`). The caching in PropertySourcePropertyResolver depends on the requested type however, so the Object request (micronaut.server.port) and the String request (micronaut.http.services.a.url) are cached separately and have different computed ports. (Additionally Object request type is not cached at all, but this is not the core issue.) This patch adds another cache *before* conversion that is independent of the requested type. This cache ensures that the value is not recomputed for different request types.
This fixes the build broken by #9310. Basically: https://github.com/micronaut-projects/micronaut-core/blob/94f458ac04b0180a989d0cf28984d5e3b5df592f/http-client/src/test/groovy/io/micronaut/http/client/filter/StaticClientFilterSpec.groovy#L24-L28 The resolution of micronaut.server.port used to request the value of test-port as String. With this patch, it requests the value as Object instead (`.getValue(Object.class)`). The caching in PropertySourcePropertyResolver depends on the requested type however, so the Object request (micronaut.server.port) and the String request (micronaut.http.services.a.url) are cached separately and have different computed ports. (Additionally Object request type is not cached at all, but this is not the core issue.) This patch adds another cache *before* conversion that is independent of the requested type. This cache ensures that the value is not recomputed for different request types.
No description provided.