Repository: incubator-geode
Updated Branches:
  refs/heads/feature/GEODE-542 a25a662b6 -> 3a1f1ded3


Throw a FunctionInvocationTargetException if the cache is closed

Slight tweak to my last fix - if the function throws a cache closed
exception, it should probably be wrapped in
FunctionInvocationTargetException, which is the exception thrown when
the target member is not available.


Project: http://git-wip-us.apache.org/repos/asf/incubator-geode/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-geode/commit/3a1f1ded
Tree: http://git-wip-us.apache.org/repos/asf/incubator-geode/tree/3a1f1ded
Diff: http://git-wip-us.apache.org/repos/asf/incubator-geode/diff/3a1f1ded

Branch: refs/heads/feature/GEODE-542
Commit: 3a1f1ded396ed5c606e9124ee9279d3b251c84fe
Parents: a25a662
Author: Dan Smith <[email protected]>
Authored: Wed Nov 11 13:14:30 2015 -0800
Committer: Dan Smith <[email protected]>
Committed: Wed Nov 11 13:22:06 2015 -0800

----------------------------------------------------------------------
 .../internal/cache/MemberFunctionStreamingMessage.java    | 10 ++++++++++
 .../cache/execute/MemberFunctionExecutionDUnitTest.java   |  4 +++-
 2 files changed, 13 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/3a1f1ded/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/MemberFunctionStreamingMessage.java
----------------------------------------------------------------------
diff --git 
a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/MemberFunctionStreamingMessage.java
 
b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/MemberFunctionStreamingMessage.java
index a40a99d..b3bdc85 100755
--- 
a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/MemberFunctionStreamingMessage.java
+++ 
b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/MemberFunctionStreamingMessage.java
@@ -32,6 +32,7 @@ import com.gemstone.gemfire.cache.CacheException;
 import com.gemstone.gemfire.cache.Region;
 import com.gemstone.gemfire.cache.execute.Function;
 import com.gemstone.gemfire.cache.execute.FunctionException;
+import com.gemstone.gemfire.cache.execute.FunctionInvocationTargetException;
 import com.gemstone.gemfire.cache.execute.FunctionService;
 import com.gemstone.gemfire.cache.execute.ResultSender;
 import com.gemstone.gemfire.cache.query.QueryException;
@@ -209,6 +210,15 @@ public class MemberFunctionStreamingMessage extends 
DistributionMessage implemen
       replyWithException(dm, rex);
       // thr = functionException.getCause();
     }
+    catch (CancelException exception) {
+      // bug 37026: this is too noisy...
+      // throw new CacheClosedException("remote system shutting down");
+      // thr = se; cache is closed, no point trying to send a reply
+      thr = new FunctionInvocationTargetException(exception);
+      stats.endFunctionExecutionWithException(this.functionObject.hasResult());
+      rex = new ReplyException(thr);
+      replyWithException(dm, rex);
+    }
     catch (Exception exception) {
       if (logger.isDebugEnabled()) {
         logger.debug("Exception occured on remote member while executing 
Function: {}", this.functionObject.getId(), exception);

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/3a1f1ded/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/execute/MemberFunctionExecutionDUnitTest.java
----------------------------------------------------------------------
diff --git 
a/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/execute/MemberFunctionExecutionDUnitTest.java
 
b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/execute/MemberFunctionExecutionDUnitTest.java
index 403d317..4b8f009 100755
--- 
a/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/execute/MemberFunctionExecutionDUnitTest.java
+++ 
b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/execute/MemberFunctionExecutionDUnitTest.java
@@ -34,6 +34,7 @@ import com.gemstone.gemfire.cache.execute.Function;
 import com.gemstone.gemfire.cache.execute.FunctionAdapter;
 import com.gemstone.gemfire.cache.execute.FunctionContext;
 import com.gemstone.gemfire.cache.execute.FunctionException;
+import com.gemstone.gemfire.cache.execute.FunctionInvocationTargetException;
 import com.gemstone.gemfire.cache.execute.FunctionService;
 import com.gemstone.gemfire.cache.execute.ResultCollector;
 import com.gemstone.gemfire.cache30.CacheTestCase;
@@ -337,8 +338,9 @@ public class MemberFunctionExecutionDUnitTest extends 
CacheTestCase {
         
         try {
           rc.getResult(30, TimeUnit.SECONDS);
+          fail("Should have seen an exception");
         } catch (Exception e) {
-          if(!(e.getCause() instanceof CacheClosedException)) {
+          if(!(e.getCause() instanceof FunctionInvocationTargetException)) {
             fail("failed", e);
           }
         }

Reply via email to