[jboss-jira] [JBoss JIRA] Closed: (JBRULES-2057) Collection returned by StatefulKnowledgeSession.getObjects() doesn't conform to standard collection behaviour

Mark Proctor (JIRA) jira-events at lists.jboss.org
Wed May 13 18:43:49 EDT 2009


     [ https://jira.jboss.org/jira/browse/JBRULES-2057?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Mark Proctor closed JBRULES-2057.
---------------------------------

    Fix Version/s: 5.0.0.GA
       Resolution: Done


Documented the method as violating the Collections contains method. There is JDK precedence for this, such as in the IdentityHashMap, which says:
This class is not a general-purpose Map implementation! While this class implements the Map interface, it intentionally violates Map's general contract, which mandates the use of the equals method when comparing objects. This class is designed for use only in the rare cases wherein reference-equality semantics are required. 

> Collection returned by StatefulKnowledgeSession.getObjects() doesn't conform to standard collection behaviour
> -------------------------------------------------------------------------------------------------------------
>
>                 Key: JBRULES-2057
>                 URL: https://jira.jboss.org/jira/browse/JBRULES-2057
>             Project: JBoss Drools
>          Issue Type: Bug
>      Security Level: Public(Everyone can see) 
>    Affects Versions: 5.0.0.CR1
>            Reporter: Damon Horrell
>            Assignee: Mark Proctor
>             Fix For: 5.0.0.GA
>
>         Attachments: drools-bug-tests.zip
>
>
> StatefulKnowledgeSession.getObjects() returns a collection containing the objects in working memory.
> The Javadoc for Collection.contains says:
> "Returns true if this collection contains the specified element. More formally, returns true if and only if this collection contains at least one element e such that (o==null ? e==null : o.equals(e)). "
> This is not the case though for StatefulKnowledgeSessionImpl.ObjectStoreWrapper.  The implementation of contains returns true only if it is the exact same object instance, but false if it is a different instance but which equals the instance in the working memory.
> A workaround is to create a new collection and put the items returned into that.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: https://jira.jboss.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        



More information about the jboss-jira mailing list