[infinispan-commits] Infinispan SVN: r2359 - in branches/4.2.x/core/src: test/java/org/infinispan/marshall and 1 other directory.

infinispan-commits at lists.jboss.org infinispan-commits at lists.jboss.org
Tue Sep 14 05:01:04 EDT 2010


Author: galder.zamarreno at jboss.com
Date: 2010-09-14 05:01:03 -0400 (Tue, 14 Sep 2010)
New Revision: 2359

Modified:
   branches/4.2.x/core/src/main/java/org/infinispan/interceptors/MarshalledValueInterceptor.java
   branches/4.2.x/core/src/test/java/org/infinispan/marshall/MarshalledValueTest.java
Log:
[ISPN-643] (Deserialization of marshalled return values can happen from within JGroups thread context) Fixed.

Modified: branches/4.2.x/core/src/main/java/org/infinispan/interceptors/MarshalledValueInterceptor.java
===================================================================
--- branches/4.2.x/core/src/main/java/org/infinispan/interceptors/MarshalledValueInterceptor.java	2010-09-14 09:00:33 UTC (rev 2358)
+++ branches/4.2.x/core/src/main/java/org/infinispan/interceptors/MarshalledValueInterceptor.java	2010-09-14 09:01:03 UTC (rev 2359)
@@ -99,7 +99,7 @@
       Map map = wrapMap(command.getMap(), marshalledValues, ctx);
       command.setMap(map);
       Object retVal = invokeNextInterceptor(ctx, command);
-      return compactAndProcessRetVal(marshalledValues, retVal);
+      return compactAndProcessRetVal(marshalledValues, retVal, ctx);
    }
 
    @Override
@@ -125,7 +125,7 @@
          Object retVal = invokeNextInterceptor(ctx, command);
          compact(key);
          compact(value);
-         return processRetVal(retVal);
+         return processRetVal(retVal, ctx);
       } finally {
          // Regardless of what happens with the remote key update, revert to equality for instance
          if (isRawComparisonRequired)
@@ -142,7 +142,7 @@
       }
       Object retVal = invokeNextInterceptor(ctx, command);
       compact(value);
-      return processRetVal(retVal);
+      return processRetVal(retVal, ctx);
    }
 
    @Override
@@ -154,7 +154,7 @@
       }
       Object retVal = invokeNextInterceptor(ctx, command);
       compact(value);
-      return processRetVal(retVal);
+      return processRetVal(retVal, ctx);
    }
 
    @Override
@@ -167,7 +167,7 @@
       }
       Object retVal = invokeNextInterceptor(ctx, command);
       compact(mv);
-      return processRetVal(retVal);
+      return processRetVal(retVal, ctx);
    }
 
    @Override
@@ -235,7 +235,7 @@
       compact(key);
       compact(newValue);
       compact(oldValue);
-      return processRetVal(retVal);
+      return processRetVal(retVal, ctx);
    }
 
    @Override
@@ -261,11 +261,11 @@
       }
    }
 
-   private Object compactAndProcessRetVal(Set<MarshalledValue> marshalledValues, Object retVal)
+   private Object compactAndProcessRetVal(Set<MarshalledValue> marshalledValues, Object retVal, InvocationContext ctx)
            throws IOException, ClassNotFoundException {
       if (trace) log.trace("Compacting MarshalledValues created");
       for (MarshalledValue mv : marshalledValues) compact(mv);
-      return processRetVal(retVal);
+      return processRetVal(retVal, ctx);
    }
 
    private void compact(MarshalledValue mv) {
@@ -273,10 +273,12 @@
       mv.compact(false, false);
    }
 
-   private Object processRetVal(Object retVal) throws IOException, ClassNotFoundException {
+   private Object processRetVal(Object retVal, InvocationContext ctx) throws IOException, ClassNotFoundException {
       if (retVal instanceof MarshalledValue) {
-         if (trace) log.trace("Return is a marshall value, so extract instance from: {0}", retVal);
-         retVal = ((MarshalledValue) retVal).get();
+         if (ctx.isOriginLocal()) {
+            if (trace) log.trace("Return is a marshall value, so extract instance from: {0}", retVal);
+            retVal = ((MarshalledValue) retVal).get();
+         }
       }
       return retVal;
    }

Modified: branches/4.2.x/core/src/test/java/org/infinispan/marshall/MarshalledValueTest.java
===================================================================
--- branches/4.2.x/core/src/test/java/org/infinispan/marshall/MarshalledValueTest.java	2010-09-14 09:00:33 UTC (rev 2358)
+++ branches/4.2.x/core/src/test/java/org/infinispan/marshall/MarshalledValueTest.java	2010-09-14 09:01:03 UTC (rev 2359)
@@ -494,6 +494,16 @@
       assertSerializationCounts(3, 1);
    }
 
+   public void testReturnValueDeserialization() { 
+      Cache cache1 = cache(0, "replSync");
+      cache(1, "replSync");
+
+      Pojo v1 = new Pojo(1);
+      cache1.put("1", v1);
+      Pojo previous = (Pojo) cache1.put("1", new Pojo(2));
+      assert previous.equals(v1);
+   }
+
    @Listener
    public static class MockListener {
       Object newValue;



More information about the infinispan-commits mailing list