You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@geode.apache.org by "ASF subversion and git services (JIRA)" <ji...@apache.org> on 2015/07/23 20:45:04 UTC

[jira] [Commented] (GEODE-144) Try-with-resources for Geode cache

    [ https://issues.apache.org/jira/browse/GEODE-144?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14639343#comment-14639343 ] 

ASF subversion and git services commented on GEODE-144:
-------------------------------------------------------

Commit 7f72d8da6bfc97a4f1d4b82727dc6934addfab6a in incubator-geode's branch refs/heads/develop from William Markito
[ https://git-wip-us.apache.org/repos/asf?p=incubator-geode.git;h=7f72d8d ]

[GEODE-144] - Adding try-with-resources to cache API.


> Try-with-resources for Geode cache
> ----------------------------------
>
>                 Key: GEODE-144
>                 URL: https://issues.apache.org/jira/browse/GEODE-144
>             Project: Geode
>          Issue Type: Improvement
>          Components: core
>            Reporter: William Markito Oliveira
>            Assignee: William Markito Oliveira
>            Priority: Minor
>
> I'd like to propose implementing AutoClosable interface in order to allow Geode users to treat Cache as an AutoClosable resource.
> Most of old GemFire examples and Geode docs[1] as well include a very common practice as follows:
> {code}
> Cache cache = new CacheFactory().set("name", "nodeName")
>         .set("log-level", "fine")
>         .set("statistic-sampling-enabled", "true")...
>         .create();
> // application code
> // Close the cache and disconnect
>     System.out.println("Closing the cache and disconnecting.");
>     cache.close();
> {code}
> The idea would be to avoid such closing calls when user think it's appropriate by using try-with-resources syntax:
> {code}
> try ( Cache cache = new CacheFactory().set("name", "nodeName").create() ) {
> // application code
> } 
> {code}
> There would be no need to call cache.close() or use try/finally blocks.  Please find in the link below more examples [3] of try-with-resources.
> [1] http://gemfire.docs.pivotal.io/latest/userguide/index.html#basic_config/the_cache/managing_a_client_cache.html
> [2] http://docs.oracle.com/javase/7/docs/api/java/lang/AutoCloseable.html
> [3] http://docs.oracle.com/javase/7/docs/technotes/guides/language/try-with-resources.html
> [4] http://gemfire.docs.pivotal.io/latest/javadocs/japi/com/gemstone/gemfire/cache/RegionService.html



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)