@Test(expected=RuntimeException.class) public void shouldCreationFailureBePropagated() throws IOException { new StorageFactory() { @Override protected Storage create(final String id, final int maximumSize) throws IOException { throw new IOException(); } }.createOrGet("id", 1, 1); }
public final T createOrGet(final String id, final int granularity, final long duration) throws IOException { Preconditions.checkNotNull(id, "null id"); Preconditions.checkArgument(duration % granularity == 0, "duration must be a multiple of granularity"); final int maximumSize = (int) (duration / granularity); return ConcurrentMaps.putIfAbsentAndReturn(this.cache, id, new Supplier<T>() { @Override public T get() { try { return create(id, maximumSize); } catch (IOException e) { throw new RuntimeException(e); } } }); }
StorageFactory implements Closeable { public final T createOrGet(final String id, final int granularity, final long duration) throws IOException { Preconditions.checkNotNull(id, "null id"); Preconditions.checkArgument(duration % granularity == 0, "duration must be a multiple of granularity"); final int maximumSize = (int) (duration / granularity); return ConcurrentMaps.putIfAbsentAndReturn(this.cache, id, new Supplier<T>() { @Override public T get() { try { return create(id, maximumSize); } catch (IOException e) { throw new RuntimeException(e); } } }); } }
StorageFactory implements Closeable { public final T createOrGet(final String id, final int granularity, final long duration) throws IOException { Preconditions.checkNotNull(id, "null id"); Preconditions.checkArgument(duration % granularity == 0, "duration must be a multiple of granularity"); final int maximumSize = (int) (duration / granularity); return ConcurrentMaps.putIfAbsentAndReturn(this.cache, id, new Supplier<T>() { @Override public T get() { try { return create(id, maximumSize); } catch (IOException e) { throw new RuntimeException(e); } } }); }  }
StorageFactory implements Closeable { public final T createOrGet(final String id, final int granularity, final long duration) throws IOException { Preconditions.checkNotNull(id, "null id"); Preconditions.checkArgument(duration % granularity == 0, "duration must be a multiple of granularity"); final int maximumSize = (int) (duration / granularity); return ConcurrentMaps.putIfAbsentAndReturn(this.cache, id, new Supplier<T>() { @Override public T get() { try { return create(id, maximumSize); } catch (IOException e) { throw new RuntimeException(e); } } }); }  final T createOrGet(final String id, final int granularity, final long duration); @Idempotent @Override final void close(); @Idempotent final boolean close(final String id); @Idempotent void delete(String id); }
StorageFactory implements Closeable { public final T createOrGet(final String id, final int granularity, final long duration) throws IOException { Preconditions.checkNotNull(id, "null id"); Preconditions.checkArgument(duration % granularity == 0, "duration must be a multiple of granularity"); final int maximumSize = (int) (duration / granularity); return ConcurrentMaps.putIfAbsentAndReturn(this.cache, id, new Supplier<T>() { @Override public T get() { try { return create(id, maximumSize); } catch (IOException e) { throw new RuntimeException(e); } } }); }  final T createOrGet(final String id, final int granularity, final long duration); @Idempotent @Override final void close(); @Idempotent final boolean close(final String id); @Idempotent void delete(String id);  }