Bug 724228 (BRMS-172)

Summary: Collection returned by StatefulKnowledgeSession.getObjects() doesn't conform to standard collection behaviour
Product: [JBoss] JBoss Enterprise BRMS Platform 5 Reporter: nwallace <nwallace>
Component: unspecifiedAssignee: Mark Proctor <mark.proctor>
Status: CLOSED NEXTRELEASE QA Contact:
Severity: unspecified Docs Contact:
Priority: high    
Version: unspecified   
Target Milestone: ---   
Target Release: 5.0.1   
Hardware: Unspecified   
OS: Unspecified   
URL: http://jira.jboss.org/jira/browse/BRMS-172
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2009-09-01 12:25:14 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:

Description nwallace 2009-07-07 14:44:27 UTC
Date of First Response: 2009-10-04 05:46:53
securitylevel_name: Public

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.

Comment 1 nwallace 2009-07-07 14:45:42 UTC
Link: Added: This issue is related to JBRULES-2057


Comment 2 nwallace 2009-09-01 12:25:14 UTC
Fix in place.

Comment 3 Dana Mison 2009-10-04 09:46:53 UTC
added to the 5.0.CP01 release notes as resolved:

JBRULES-2057
StatefulKnowledgeSession.getObjects() returns a Collection whose contains method that does not conform to the expected Java Collection behaviour.   This is intentional and has now been documented in the API JavaDocs.