This is an automated email from the ASF dual-hosted git repository. zhouxj pushed a commit to branch feature/GEODE-8072 in repository https://gitbox.apache.org/repos/asf/geode.git
commit d15076e641a94030027e3a124a113beb195ed8bf Author: zhouxh <gz...@pivotal.io> AuthorDate: Tue May 5 09:43:21 2020 -0700 GEODE-8072: check the null and stop the on-going query function when cache is closing --- .../cache/execute/InternalFunctionExecutionServiceImpl.java | 2 +- .../cache/execute/InternalFunctionExecutionServiceTest.java | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/geode-core/src/main/java/org/apache/geode/internal/cache/execute/InternalFunctionExecutionServiceImpl.java b/geode-core/src/main/java/org/apache/geode/internal/cache/execute/InternalFunctionExecutionServiceImpl.java index dc73351..44c54d8 100644 --- a/geode-core/src/main/java/org/apache/geode/internal/cache/execute/InternalFunctionExecutionServiceImpl.java +++ b/geode-core/src/main/java/org/apache/geode/internal/cache/execute/InternalFunctionExecutionServiceImpl.java @@ -112,7 +112,7 @@ public class InternalFunctionExecutionServiceImpl @Override public Execution onRegion(Region region) { - if (region == null) { + if (region == null || region.getAttributes() == null) { throw new FunctionException("Region instance passed is null"); } diff --git a/geode-core/src/test/java/org/apache/geode/internal/cache/execute/InternalFunctionExecutionServiceTest.java b/geode-core/src/test/java/org/apache/geode/internal/cache/execute/InternalFunctionExecutionServiceTest.java index eec2b6d..6b90217 100644 --- a/geode-core/src/test/java/org/apache/geode/internal/cache/execute/InternalFunctionExecutionServiceTest.java +++ b/geode-core/src/test/java/org/apache/geode/internal/cache/execute/InternalFunctionExecutionServiceTest.java @@ -47,6 +47,16 @@ public class InternalFunctionExecutionServiceTest { } @Test + public void onRegionShouldThrowExceptionWhenRegionAttributesIsNull() { + Region mockRegion = mock(Region.class); + when(mockRegion.getAttributes()).thenReturn(null); + + assertThatThrownBy(() -> functionExecutionService.onRegion(mockRegion)) + .isInstanceOf(FunctionException.class) + .hasMessage("Region instance passed is null"); + } + + @Test public void onRegionShouldThrowExceptionWhenThePoolAssociatedWithTheRegionCanNotBeFound() { when(functionExecutionService.findPool(any())).thenReturn(null);