, try-. , , try .
, :
String result = null;
if (jedis.exists(name)) {
try {
result = jedis.getResult(name);
} catch (JedisConnectionException e) {
LOG.error("Could not get result", e);
} finally {
jedis.close();
}
}
return result;
, , "" JedisConnectionException, ( ), :
throw new MyAppException("Could not get result", e);
, .
, try-with-resources Java SE 7, JedisConnection Closable:
try (JedisConnection jedis = Pool.getJedisConnection()) {
result = jedis.getResult(name);
} catch (JedisConnectionException e) {
LOG.error("Could not get result", e);
}
JedisConnection .