Open j1m-renwick opened 1 year ago
Update: looks like setting a logger explicitly in the class instead of the SLF4J annotation works
e.g. static Logger log = LoggerFactory.getLogger(MyClass)
(note the lack of a private
keyword)
Another workaround is to capture the logger in the @Cacheable
method, and then use that in the closure
@Cacheable(cacheNames = "some-cache")
Single<String> myCachedMethodWithInnerLogging() {
def logger = log
Single.just("hi")
.map{
logger.info("saying hi!")
return it
}
}
and another is to provide a getter for the log variable
def getLog() {
return log
}
Expected Behavior
the @Slf4j log property to be available in all parts of a class that features cache-related annotations
Actual Behaviour
the @SLF4J log property is sometimes not found in methods that belong to classes that feature cache-related annotations
Steps To Reproduce
groovy.lang.MissingPropertyException: No such property: log for class: com.example.$MyCachedClass$Definition$Intercepted
- either by running the unit tests, or by calling the GET APIs featured in MyController.( NOTE: this seems to occur for other annotations like @CacheInvalidate as well - not just @Cacheable )
Environment Information
Operating System: MacOS Ventura, Version 13.4 JDK Version: Coretto 17
Example Application
see above
Version
4.0.5