You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ofbiz.apache.org by "Adam Heath (JIRA)" <ji...@apache.org> on 2014/06/25 22:25:24 UTC

[jira] [Assigned] (OFBIZ-3880) EntityDateFilterCondition causes the entity cache to return false matches

     [ https://issues.apache.org/jira/browse/OFBIZ-3880?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Adam Heath reassigned OFBIZ-3880:
---------------------------------

    Assignee: Adam Heath

> EntityDateFilterCondition causes the entity cache to return false matches
> -------------------------------------------------------------------------
>
>                 Key: OFBIZ-3880
>                 URL: https://issues.apache.org/jira/browse/OFBIZ-3880
>             Project: OFBiz
>          Issue Type: Bug
>          Components: framework
>            Reporter: Scott Gray
>            Assignee: Adam Heath
>
> The EntityDateFilterCondition can cause problems when used as a condition in cache queries because it does not internally store the right hand side of the query (i.e. the moment in time to filter against).  The result is that all instances using the same field names (e.g. "fromDate" and "thruDate") are considered equal by the equals(Object) method regardless of the moment in time that they ultimately end up querying.
> The end result of this is that the if a value is cached against an EntityCondition and that condition contains a EntityDateFilterCondition then that value could be returned even if would not satisfy the same condition queried against the database.
> Concrete example:
> - You query for PartyRelationship records using an EntityDateFilterCondition and use the cache
> - Some time passes and one of the previously returned PartyRelationship records has expired i.e. thruDate has been set and passed
> - If you now run the same query again then the expired PartyRelationship record will be returned in the results from the cache even though you have filtered by date
> Obviously the cache shouldn't be being used in combination with an EntityDateFilterCondition anyway (in its current state at least) since it is impossible to ever retrieve the value from the cache once that moment in time has passed (assuming this bug were fixed).  But this problem is somewhat obscure and it is too easy for a developer to combine the date filter and the cache accidentally or without fully thinking it through.
> Proposed fix is to store the moment in time that the condition tests against in the object and use it in equals(Object) and hasCode(), should be set during init() and cleared during reset().
> But really I don't even understand the purpose of this class, it uses a regular EntityCondition internally and we could probably just move the code that does the real work (makeCondition(...)) into EntityCondition as a utility method or even into EntityUtil and then discard this class entirely.
> Thoughts welcome.



--
This message was sent by Atlassian JIRA
(v6.2#6252)