quarkus: Quarks Cache is not working in Bean that is created via a Producer
Describe the bug
I annotated a function with @CacheResult in a class that gets created as a bean by a producer. The cache is created as I can see in the DEV UI, but no values are written to the cache.
If I create the bean by just adding the @ApplicationScoped annotation and remove the producer everything works fine.
Expected behavior
No response
Actual behavior
No response
How to Reproduce?
No response
Output of uname -a or ver
No response
Output of java -version
openjdk version “18.0.2” 2022-07-19
GraalVM version (if different from Java)
No response
Quarkus version or git rev
2.16.5.Final
Build tool (ie. output of mvnw --version or gradlew --version)
Gradle 7.4
Additional information
No response
About this issue
- Original URL
- State: open
- Created a year ago
- Comments: 27 (22 by maintainers)
I’m not sure I would add a warning in the logs but we need a warning in the documentation. And I think we should also point to this warning in the cache doc.
Ah, I didn’t know we have an issue for that. Will copy my comments there.
@geoand Yes, but it’s not supported for good reasons. BTW the same applies to synthetic beans, because only managed beans (aka beans implemented by Java classes) support interception.
Or generate the subclass at runtime… which is not idiomatic for quarkus, nor an option for native image.
We could. Until someone else complains that those warnings are superfluous for this particular use case (it wouldn’t be for the first time 😉.
https://quarkus.io/version/2.13/guides/cdi-reference#simplified-producer-method-declaration
@Produces @ApplicationScoped @UnlessBuildProfile("prod") fun noOpFirebaseRemoteConfig(): RemoteConfigService = TestRemoteConfigService()This is my producer for my local test environment. I will create a test application to show this behavior.