[hibernate-issues] [Hibernate-JIRA] Commented: (HHH-2142) PersistentMap.remove() may return UNKNOWN object that can cause ClassCastException in client code

Gail Badner (JIRA) noreply at atlassian.com
Mon Oct 29 14:24:39 EDT 2007


    [ http://opensource.atlassian.com/projects/hibernate/browse/HHH-2142?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_28620 ] 

Gail Badner commented on HHH-2142:
----------------------------------

Keep watching.

> PersistentMap.remove() may return UNKNOWN object that can cause ClassCastException in client code
> -------------------------------------------------------------------------------------------------
>
>                 Key: HHH-2142
>                 URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2142
>             Project: Hibernate3
>          Issue Type: Bug
>          Components: core
>    Affects Versions: 3.2.0.cr5
>            Reporter: Andrzej Miazga
>
> Here is some code in Hibernate 3.2.0cr5 that may cause this behaviour. I'm not sure if this is a bug but it surely affects the client code.
> AbstractPersistentCollection:
> protected Object readElementByIndex(Object index) {
>   if (!initialized) {
>     ...
>     return persister.getElementByIndex( entry.getLoadedKey(), index, session, owner );
>   }
>   ...
>   return UNKNOWN;
> }	
> PersistentMap (extends AbstractPersistentCollection):
>   public Object put(Object key, Object value) {
> 		if ( isPutQueueEnabled() ) {
> 			Object old = readElementByIndex( key );
> 			queueOperation( new Put( key, value, old ) );
> 			return old;
> 		}
> 		...
> So, there is a possibility to return UNKNOWN instance (MarkerObject) to the client code as the result of Map.put().
> In version 3.1.3 this worked fine, but the implementation was different:
> 	public Object put(Object key, Object value) {
> 		Object old = isPutQueueEnabled() ?
> 				readElementByIndex(key) : UNKNOWN;
> 		if ( old==UNKNOWN ) {
> 			write();
> 			return map.put(key, value);
> 		}
> ...
> 	} 

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

        



More information about the hibernate-issues mailing list