You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@isis.apache.org by "Dan Haywood (JIRA)" <ji...@apache.org> on 2015/12/23 18:28:46 UTC

[jira] [Commented] (ISIS-1283) SAFE_AND_CACHEABLE semantics caches incorrectly, works for domain services (stateless) but not for domain entities (where stateful target determines result)

    [ https://issues.apache.org/jira/browse/ISIS-1283?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15069917#comment-15069917 ] 

Dan Haywood commented on ISIS-1283:
-----------------------------------

further comment from Oscar:

To document it here, what would be need to change would be current

ActionInvocationFacetForDomainEventAbstract.internalInvoke

implementation, when invocation is cacheable.



> SAFE_AND_CACHEABLE semantics caches incorrectly, works for domain services (stateless) but not for domain entities (where stateful target determines result)
> ------------------------------------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: ISIS-1283
>                 URL: https://issues.apache.org/jira/browse/ISIS-1283
>             Project: Isis
>          Issue Type: Bug
>          Components: Core
>    Affects Versions: 1.10.0
>            Reporter: Dan Haywood
>            Assignee: Dan Haywood
>            Priority: Critical
>             Fix For: 1.11.0
>
>
> From Oscar, on mailing list:
> I’m experiencing a bad behavior using SAFE_AND_CACHEABLE actions implemented on Domain Entities.
> As current QueryResultsCache implementation has as its Key the calling class, instead of the concrete domain entity that has invoked it, it will return the cached result when invoking the same action on different domain objects.
> For example, I have the following action:
> public class Product {
>     // {{ findStockForSupplier (action)
>     @Action(semantics = SemanticsOf.SAFE_AND_REQUEST_CACHEABLE)
>     @ActionLayout(hidden = Where.ANYWHERE)
>     @MemberOrder(name = "supplierTerms", sequence = "3")
>     public BigDecimal findStockForSupplier(
>             final Supplier supplier) {
>         final ProductSupplierTerms productSupplierTerms = this.wrapSkipRules(this).findTermsForSupplier(supplier);
>         return productSupplierTerms != null ? productSupplierTerms.getStock() : BigDecimal.ZERO;
>     }
> }
> If I invoke that action over 2 different Products (ie, Product instances) as per:
> final ProductSupplierTerms productSupplierTerms1 = this.wrapSkipRules(product1).findTermsForSupplier(supplier);
> final ProductSupplierTerms productSupplierTerms2 = this.wrapSkipRules(product2).findTermsForSupplier(supplier);
> For the second invocation it will return the cached result, as only the class is considered on the QueryResultsCache and not the instance “identity”, and both “product1” and “product2” are Product instances.
> As all Domain Entities implement the Comparable interface, perhaps it might be considered.
> Until now, I didn’t noticed this because I always used the QueryResultsCache for Domain Services, and they have only 1 instance in production.
> But it’s not the same when the SAFE_AND_CACHEABLE actions are implemented on Domain Entities.
> Perhaps the solution would be to simply change the QueryResultsCache.Key implementation to accept an Object instead of a Class, using the “Comparable” interface if implemented to differentiate between objects (for Domain Objects), and the “equal” operator when not present (for Services)?



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)