[hibernate-issues] [Hibernate-JIRA] Commented: (HHH-2142) PersistentMap.put(), remove() may return UNKNOWN object that can cause ClassCastException in client code
Greg Steckman (JIRA)
noreply at atlassian.com
Tue Nov 14 21:40:05 EST 2006
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-2142?page=comments#action_25291 ]
Greg Steckman commented on HHH-2142:
------------------------------------
I'm also getting a MarkerObject in version 3.2.0 as a result of a put and a remove. I confirmed via debugger that it is coming from AbstractPersistentCollection.readElementByIndex(Object index).
> PersistentMap.put(), 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
> Type: Bug
> Components: core
> 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