[
https://issues.jboss.org/browse/ISPN-881?page=com.atlassian.jira.plugin.s...
]
Miroslav Pokorny commented on ISPN-881:
---------------------------------------
Sorry for the unclear suggestion. My point was regarding the modify event that gets fired
after the create for the put for a new (previously unknown) key for a cache. Unfortunately
the modify event.getValue() returns null if the put is creating an entry while it returns
the replacement value if the put is a replace(overwriting a previous key/value). I am
saying that the modify event should at the very least have the putted value. The fact that
create events dont have a value is another story for now.
I originally understood the "pre" flag in the event to reflect tell whether the
event was fired before (pre=true) or after (pre=false) the operation was committed to the
cache. In the case of the third event ( the 2nd ModifiedEvent) i believe the modify event
getValue() should return the putted value and not null. WHen its a repalce put the modify
event. getVlaue does return the new replacement putted value...
A listener which receives CacheEntryCreatedEvent +
CacheEntryModifiedEvent events always has a null value after a Cache.put while a Cache.put
which replaces delivers the actual value.
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Key: ISPN-881
URL:
https://issues.jboss.org/browse/ISPN-881
Project: Infinispan
Issue Type: Bug
Components: Listeners
Affects Versions: 4.2.0.CR3
Environment: N/A
Reporter: Miroslav Pokorny
Assignee: Manik Surtani
It would be advantageous if the beheaviour of the delivered modify events did not deliver
null values after a put which is different from a put which replaces which does deliver
the actual value. It is also not possible to take the key from the create event and try
and read the cache. I have tried printing both when the Event.isPre() field is false and
true and the value is null.
Please examine the provided test harness which includes some prints the output which
demonstrates the problem...
---
package miroslav.pokorny.cache.infinispan;
import org.infinispan.manager.DefaultCacheManager;
import org.infinispan.manager.EmbeddedCacheManager;
import org.infinispan.notifications.Listener;
import org.infinispan.notifications.cachelistener.annotation.CacheEntryCreated;
import org.infinispan.notifications.cachelistener.annotation.CacheEntryModified;
import org.infinispan.notifications.cachelistener.event.CacheEntryCreatedEvent;
import org.infinispan.notifications.cachelistener.event.CacheEntryModifiedEvent;
public class InfinispanValueProblemTest {
private final static String KEY = "key";
private final static String VALUE = "*Value*";
static public void main(final String[] ignored) {
final EmbeddedCacheManager manager = new DefaultCacheManager();
final org.infinispan.Cache<String, String> cache = manager.getCache();
cache.addListener(new InfinispanCacheListener());
cache.put(KEY, VALUE);
}
@Listener
static final public class InfinispanCacheListener {
@CacheEntryCreated
public void entryCreated(final CacheEntryCreatedEvent<String, String>
event) {
System.out.println("CREATE EVENT\n\t" + event.getKey() + "=
cant do get value\n\tisPre=" + event.isPre()
+ "\n\tevent.getCache().get(event.getKey())=" +
event.getCache().get(event.getKey()));
}
@CacheEntryModified
public void entryModified(final CacheEntryModifiedEvent<String, String>
event) {
System.out.println("MODIFIED EVENT\n\t" + event.getKey() +
"=" + event.getValue() + "\n\tisPre=" + event.isPre()
+ "\n\tevent.getCache().get(event.getKey())=" +
event.getCache().get(event.getKey()));
}
}
}
-------------------------------------------
Running the test should print something like this
[ GlobalComponentRegistry] - Infinispan version: Infinispan 'Ursus'
4.2.0.CR3
[ ComponentRegistry] - Infinispan version: Infinispan 'Ursus'
4.2.0.CR3
CREATE EVENT
key= cant do get value
isPre=true
event.getCache().get(event.getKey())=null
CREATE EVENT
key= cant do get value
isPre=false
event.getCache().get(event.getKey())=null
MODIFIED EVENT
key=null
isPre=true
event.getCache().get(event.getKey())=null
MODIFIED EVENT
key=*Value*
isPre=false
event.getCache().get(event.getKey())=null
--
This message is automatically generated by JIRA.
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira