grails-cache icon indicating copy to clipboard operation
grails-cache copied to clipboard

@Cacheable annotation doesn't work with @CurrentTenant

Open dpcasady opened this issue 6 years ago • 1 comments

Given a simple service class annotated with @CurrentTenant:

@CurrentTenant
@Transactional(readOnly = true)
class MultiTenantCachingService {

    @Cacheable('test')
    def serviceMethod() {

    }
}

Calling serviceMethod() throws the following exception:

No such property: tenantId for class: org.grails.MultiTenantCachingService
groovy.lang.MissingPropertyException: No such property: tenantId for class: org.grails.MultiTenantCachingService
	at org.grails.MultiTenantCachingServiceSpec.$tt__$spock_feature_0_1(MultiTenantCachingServiceSpec.groovy:29)
	at org.grails.MultiTenantCachingServiceSpec.multi-tenant service method with @Cacheable annotation doesn't throw an exception_closure2(MultiTenantCachingServiceSpec.groovy)
	at groovy.lang.Closure.call(Closure.java:418)
	at groovy.lang.Closure.call(Closure.java:434)
	at grails.gorm.transactions.GrailsTransactionTemplate$1.doInTransaction(GrailsTransactionTemplate.groovy:68)
	at org.springframework.transaction.support.TransactionTemplate.execute(TransactionTemplate.java:133)
	at grails.gorm.transactions.GrailsTransactionTemplate.executeAndRollback(GrailsTransactionTemplate.groovy:65)
	at org.grails.MultiTenantCachingServiceSpec.multi-tenant service method with @Cacheable annotation doesn't throw an exception(MultiTenantCachingServiceSpec.groovy)

It looks like the AST triggered by the @Cacheable annotation isn't playing nicely with the @CurrentTenant annotation.

Here's an example application using v4.0.1 of the plugin that demonstrates the issue: https://github.com/dpcasady/multi-tenant-cacheable

It has one integration test that when run will throw the exception above.

dpcasady avatar Oct 15 '18 21:10 dpcasady

Nevermind this issue, it looks like it was fixed in abb34dc6293fb6abdcea91ad9e2e0f4ed0d15ee4.

Any plans to include this in a release soon?

dpcasady avatar Oct 17 '18 03:10 dpcasady