[infinispan-issues] [JBoss JIRA] Issue Comment Edited: (ISPN-1140) TransientMortalCacheEntry has incorrect implementation of setValue()
Steven Newson (JIRA)
jira-events at lists.jboss.org
Fri May 27 05:17:00 EDT 2011
[ https://issues.jboss.org/browse/ISPN-1140?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12604890#comment-12604890 ]
Steven Newson edited comment on ISPN-1140 at 5/27/11 5:15 AM:
--------------------------------------------------------------
It's probably worth noting that this bug breaks Non Transactional (i.e. non JTA) use of Infinispan in Hibernate.
was (Author: stevennewson):
It's probably worth noting that this bug breaks Non Transactional use of Infinispan in Hibernate.
> TransientMortalCacheEntry has incorrect implementation of setValue()
> --------------------------------------------------------------------
>
> Key: ISPN-1140
> URL: https://issues.jboss.org/browse/ISPN-1140
> Project: Infinispan
> Issue Type: Bug
> Components: Core API
> Affects Versions: 4.2.1.FINAL, 5.0.0.CR3
> Reporter: Steven Newson
> Assignee: Galder ZamarreƱo
> Fix For: 5.0.0.CR4, 5.0.0.FINAL
>
>
> The implementation of {{setValue()}} in {{TransientMortalCacheEntry}} is as follows
> {code:java}
> public Object setValue(Object value) {
> return cacheValue.maxIdle;
> }
> {code}
> This leads to problems in the {{DefaultDataContainer}} as the following {{put()}} code has no effect:
> {code:java}
> public void put(Object k, Object v, long lifespan, long maxIdle) {
> InternalCacheEntry e = entries.get(k);
> if (e != null) {
> e.setValue(v);
> InternalCacheEntry original = e;
> e = entryFactory.update(e, lifespan, maxIdle);
> // we have the same instance. So we need to reincarnate.
> if(original == e) {
> e.reincarnate();
> }
> } else {
> // this is a brand-new entry
> e = entryFactory.createNewEntry(k, v, lifespan, maxIdle);
> }
> entries.put(k, e);
> }
> {code}
> The effect of this for me is that the following steps via Hibernate don't work:
> - Insert record into table via Hibernate
> - Reload record by its ID
> - Change non-ID field on the record
> - Update the record via Hibernate
> - Reload the record by its ID
> - Check that the value reloaded matches the updated value
> The 2nd level cache always returns the first inserted record rather than the updated one. Each Hibernate access is inside its own transaction.
> I fixed this locally by overriding the class in the classpath, replacing the {{setValue()}} method with the following implementation:
> {code:java}
> public Object setValue(Object value) {
> Object original = cacheValue.value;
> cacheValue.value = value;
> return original;
> }
> {code}
> Which also corresponds to the (misspelled :)) Javadoc:
> {noformat}Sets the value of the entry, returing the previous value{noformat}
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira
More information about the infinispan-issues
mailing list