geode-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bschucha...@apache.org
Subject [34/50] [abbrv] incubator-geode git commit: [GEODE-144] - Adding try-with-resources to cache API.
Date Mon, 27 Jul 2015 23:19:57 GMT
[GEODE-144] - Adding try-with-resources to cache API.


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

Branch: refs/heads/feature/GEODE-77
Commit: 7f72d8da6bfc97a4f1d4b82727dc6934addfab6a
Parents: b3e2167
Author: William Markito <wmarkito@pivotal.io>
Authored: Thu Jul 23 11:39:24 2015 -0700
Committer: William Markito <wmarkito@pivotal.io>
Committed: Thu Jul 23 11:41:01 2015 -0700

----------------------------------------------------------------------
 .../gemstone/gemfire/cache/RegionService.java    |  2 +-
 .../gemfire/cache/RegionFactoryJUnitTest.java    | 19 ++++++++++++++++++-
 2 files changed, 19 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/7f72d8da/gemfire-core/src/main/java/com/gemstone/gemfire/cache/RegionService.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/cache/RegionService.java b/gemfire-core/src/main/java/com/gemstone/gemfire/cache/RegionService.java
index 9ea65c0..5d65450 100644
--- a/gemfire-core/src/main/java/com/gemstone/gemfire/cache/RegionService.java
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/cache/RegionService.java
@@ -39,7 +39,7 @@ import com.gemstone.gemfire.pdx.PdxInstanceFactory;
  * @since 6.5
  * @author darrel
  */
-public interface RegionService {
+public interface RegionService extends AutoCloseable {
   /**
    * the cancellation criterion for this service
    * @return the service's cancellation object

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/7f72d8da/gemfire-core/src/test/java/com/gemstone/gemfire/cache/RegionFactoryJUnitTest.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/cache/RegionFactoryJUnitTest.java
b/gemfire-core/src/test/java/com/gemstone/gemfire/cache/RegionFactoryJUnitTest.java
index 151e9c8..a561066 100644
--- a/gemfire-core/src/test/java/com/gemstone/gemfire/cache/RegionFactoryJUnitTest.java
+++ b/gemfire-core/src/test/java/com/gemstone/gemfire/cache/RegionFactoryJUnitTest.java
@@ -146,7 +146,7 @@ public class RegionFactoryJUnitTest {
     r1 = factory.create(r1Name);
     assertBasicRegionFunctionality(r1, r1Name);
   }
-  
+
   /**
    * Test RegionFactory with Cache close and DistributedSystem disconnect
    */
@@ -1100,6 +1100,23 @@ public class RegionFactoryJUnitTest {
     assertEquals(2, ra.getPartitionAttributes().getRedundantCopies());
   }
 
+  @Test
+  public void testCacheCloseUsingTryWithResources() throws Exception {
+    Cache extCache;
+
+    // try block creates and close cache
+    try (Cache cache = new CacheFactory(createGemFireProperties()).create()) {
+      extCache = cache;
+      assertEquals(false, cache.isClosed());
+    }
+
+    if (extCache != null) {
+      assertEquals(true, extCache.isClosed());
+    } else {
+      fail("CacheFactory must be created.");
+    }
+  }
+
   private String getName() {
     return getClass().getSimpleName() + "_" + testName.getMethodName();
   }


Mime
View raw message