[jboss-jira] [JBoss JIRA] Updated: (JBRULES-1590) ShadowProxuUtils and org.hibernate.collection.PersistentSet
Delbart Vincent (JIRA)
jira-events at lists.jboss.org
Mon Apr 28 11:27:08 EDT 2008
[ http://jira.jboss.com/jira/browse/JBRULES-1590?page=all ]
Delbart Vincent updated JBRULES-1590:
-------------------------------------
Attachment: projectWithShadowProxy.zip
Project with to JUnit Test :
- one work with shadowproxy = false,
- other doesn't work
> ShadowProxuUtils and org.hibernate.collection.PersistentSet
> -----------------------------------------------------------
>
> Key: JBRULES-1590
> URL: http://jira.jboss.com/jira/browse/JBRULES-1590
> Project: JBoss Drools
> Issue Type: Feature Request
> Security Level: Public(Everyone can see)
> Components: Reteoo
> Affects Versions: 4.0.6
> Reporter: Delbart Vincent
> Assigned To: Edson Tirelli
> Fix For: 4.0.7, 5.0.0-M1
>
> Attachments: projectWithShadowProxy.zip
>
>
> I think the method cloneObject 'ShadowProxyUtils' could be improve like follow :
> public static Object cloneObject(Object original) {
> Object clone = null;
> if ( original instanceof Cloneable ) {
> try {
> Method cloneMethod = original.getClass().getMethod( "clone",
> new Class[0] );
> clone = cloneMethod.invoke( original,
> new Object[0] );
> } catch ( Exception e ) {
> /* Failed to clone. Don't worry about it, and just return
> * the original object. */
> clone = null;
> }
> }
> if ( clone == null ) {
> try {
> if ( original instanceof Map &&
> original != Collections.EMPTY_MAP &&
> !UNMODIFIABLE_MAP.isAssignableFrom( original.getClass() ) ) {
>
> /* empty and unmodifiable maps can't (and don't need to) be shadowed */
> clone = original.getClass().newInstance();
> ((Map) clone).putAll( (Map) original );
>
> } else if ( original instanceof Collection &&
> original != Collections.EMPTY_LIST &&
> original != Collections.EMPTY_SET &&
> !UNMODIFIABLE_COLLECTION.isAssignableFrom( original.getClass() ) ) {
>
> /* empty and unmodifiable collections can't (and don't need to) be shadowed */
> clone = original.getClass().newInstance();
> ((Collection) clone).addAll( (Collection) original );
>
> } else if ( original.getClass().isArray() ) {
> clone = cloneArray( original );
> }
>
> } catch ( Exception e ) {
> /* Failed to clone. Don't worry about it, and just return
> * the original object. */
> clone = null;
> }
> }
> if ( clone == null ) {
> clone = original;
> }
> return clone;
> }
> In this way my PersistentSet will be not clone and I will be able to continue to use shadow fact
> What do you think about ?
> V.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://jira.jboss.com/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
More information about the jboss-jira
mailing list