@Override public V get(K id) { // Batch is not closed here - it will be closed during release(...) or discard(...) @SuppressWarnings("resource") Batch batch = this.manager.getBatcher().createBatch(); try { Bean<K, V> bean = this.manager.findBean(id); if (bean == null) { batch.close(); return null; } V result = bean.acquire(); result.setCacheContext(batch); return result; } catch (RuntimeException | Error e) { batch.discard(); batch.close(); throw e; } }