[infinispan-commits] Infinispan SVN: r1088 - in trunk/core/src: test/java/org/infinispan/marshall and 1 other directory.
infinispan-commits at lists.jboss.org
infinispan-commits at lists.jboss.org
Fri Oct 30 13:31:58 EDT 2009
Author: galder.zamarreno at jboss.com
Date: 2009-10-30 13:31:58 -0400 (Fri, 30 Oct 2009)
New Revision: 1088
Modified:
trunk/core/src/main/java/org/infinispan/notifications/cachelistener/event/EventImpl.java
trunk/core/src/test/java/org/infinispan/marshall/MarshalledValueTest.java
Log:
[ISPN-242] (MarshalledValue leaked to event listener implementations when lazy deserialization is on) Done.
Modified: trunk/core/src/main/java/org/infinispan/notifications/cachelistener/event/EventImpl.java
===================================================================
--- trunk/core/src/main/java/org/infinispan/notifications/cachelistener/event/EventImpl.java 2009-10-30 17:26:30 UTC (rev 1087)
+++ trunk/core/src/main/java/org/infinispan/notifications/cachelistener/event/EventImpl.java 2009-10-30 17:31:58 UTC (rev 1088)
@@ -21,7 +21,10 @@
*/
package org.infinispan.notifications.cachelistener.event;
+import net.jcip.annotations.NotThreadSafe;
+
import org.infinispan.Cache;
+import org.infinispan.marshall.MarshalledValue;
import org.infinispan.transaction.xa.GlobalTransaction;
/**
@@ -30,6 +33,7 @@
* @author <a href="mailto:manik at jboss.org">Manik Surtani</a>
* @since 4.0
*/
+ at NotThreadSafe
public class EventImpl implements CacheEntryActivatedEvent, CacheEntryCreatedEvent, CacheEntryEvictedEvent, CacheEntryLoadedEvent, CacheEntryModifiedEvent,
CacheEntryPassivatedEvent, CacheEntryRemovedEvent, CacheEntryVisitedEvent, TransactionCompletedEvent, TransactionRegisteredEvent,
CacheEntryInvalidatedEvent {
@@ -58,6 +62,8 @@
}
public Object getKey() {
+ if (key instanceof MarshalledValue)
+ key = ((MarshalledValue) key).get();
return key;
}
@@ -104,6 +110,8 @@
}
public Object getValue() {
+ if (value instanceof MarshalledValue)
+ value = ((MarshalledValue) value).get();
return value;
}
Modified: trunk/core/src/test/java/org/infinispan/marshall/MarshalledValueTest.java
===================================================================
--- trunk/core/src/test/java/org/infinispan/marshall/MarshalledValueTest.java 2009-10-30 17:26:30 UTC (rev 1087)
+++ trunk/core/src/test/java/org/infinispan/marshall/MarshalledValueTest.java 2009-10-30 17:31:58 UTC (rev 1088)
@@ -73,6 +73,7 @@
*/
@Test(groups = "functional", testName = "marshall.MarshalledValueTest")
public class MarshalledValueTest extends MultipleCacheManagersTest {
+ private static final Log log = LogFactory.getLog(MarshalledValueTest.class);
private MarshalledValueListenerInterceptor mvli;
String k = "key", v = "value";
private VersionAwareMarshaller marshaller;
@@ -98,9 +99,9 @@
@BeforeMethod
public void addMarshalledValueInterceptor() {
- Cache cache1, cache2;
+ Cache cache1;
cache1 = cache(0, "replSync");
- cache2 = cache(1, "replSync");
+ cache(1, "replSync");
InterceptorChain chain = TestingUtil.extractComponent(cache1, InterceptorChain.class);
chain.removeInterceptor(MarshalledValueListenerInterceptor.class);
mvli = new MarshalledValueListenerInterceptor();
@@ -112,7 +113,7 @@
}
@AfterClass(alwaysRun=true)
- protected void destroy() {
+ protected void destroy() {
if(marshaller != null) {
marshaller.stop();
marshaller = null;
@@ -143,9 +144,9 @@
assert Pojo.deserializationCount == deserializationCount : "Deserialization count: expected " + deserializationCount + " but was " + Pojo.deserializationCount;
}
- public void testNonSerializable() {
+ public void testNonSerializable() {
Cache cache1 = cache(0, "replSync");
- Cache cache2 = cache(1, "replSync");
+ cache(1, "replSync");
try {
cache1.put("Hello", new Object());
assert false : "Should have failed";
@@ -438,19 +439,19 @@
assertSerializationCounts(1, 1);
}
- public void testCallbackValues() {
+ public void testCallbackValues() throws Exception {
Cache cache1 = cache(0, "replSync");
- Cache cache2 = cache(1, "replSync");
+ cache(1, "replSync");
MockListener l = new MockListener();
cache1.addListener(l);
- Pojo pojo = new Pojo();
- cache1.put("key", pojo);
-
- assert l.newValue != null;
- assert l.newValue instanceof MarshalledValue : "recieved " + l.newValue.getClass().getName();
- MarshalledValue mv = (MarshalledValue) l.newValue;
- assert mv.instance instanceof Pojo;
- assertSerializationCounts(1, 0);
+ try {
+ Pojo pojo = new Pojo();
+ cache1.put("key", pojo);
+ assert l.newValue instanceof Pojo : "recieved " + l.newValue.getClass().getName();
+ assertSerializationCounts(1, 0);
+ } finally {
+ cache1.removeListener(l);
+ }
}
public void testRemoteCallbackValues() throws Exception {
@@ -458,19 +459,19 @@
Cache cache2 = cache(1, "replSync");
MockListener l = new MockListener();
cache2.addListener(l);
- Pojo pojo = new Pojo();
- cache1.put("key", pojo);
-
- assert l.newValue != null;
- assert l.newValue instanceof MarshalledValue;
- MarshalledValue mv = (MarshalledValue) l.newValue;
- assert mv.get() instanceof Pojo;
- assertSerializationCounts(1, 1);
+ try {
+ Pojo pojo = new Pojo();
+ cache1.put("key", pojo);
+ assert l.newValue instanceof Pojo;
+ assertSerializationCounts(1, 1);
+ } finally {
+ cache2.removeListener(l);
+ }
}
public void testEvictWithMarshalledValueKey() {
Cache cache1 = cache(0, "replSync");
- Cache cache2 = cache(1, "replSync");
+ cache(1, "replSync");
Pojo pojo = new Pojo();
cache1.put(pojo, pojo);
cache1.evict(pojo);
@@ -539,6 +540,7 @@
i = in.readInt();
b = in.readBoolean();
deserializationCount++;
+ log.trace("deserializationCount=" + deserializationCount);
}
}
More information about the infinispan-commits
mailing list