geode-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "William Markito Oliveira (JIRA)" <j...@apache.org>
Subject [jira] [Resolved] (GEODE-144) Try-with-resources for Geode cache
Date Thu, 23 Jul 2015 18:46:05 GMT

     [ https://issues.apache.org/jira/browse/GEODE-144?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

William Markito Oliveira resolved GEODE-144.
--------------------------------------------
    Resolution: Fixed

> 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)

Mime
View raw message