@Test(expected = IllegalStateException.class) public void testClear() throws Exception { CountDownLatch factoryLatch = new CountDownLatch(1); final CreatingCache<String, String> cache = new CreatingCache<String, String>(new DelayedFactory(factoryLatch)); CountDownLatch latch = new CountDownLatch(1); new Thread(new CacheRunnable(cache, latch)).start(); latch.await(); cache.clear(); }
public synchronized void clear() { if (!mProcessedValues.isEmpty()) { throw new IllegalStateException("Cache values are being processed"); } mCache.clear(); }
CreatingCache { public synchronized void clear() { if (!mProcessedValues.isEmpty()) { throw new IllegalStateException("Cache values are being processed"); } mCache.clear(); } }
CreatingCache { public synchronized void clear() { if (!mProcessedValues.isEmpty()) { throw new IllegalStateException("Cache values are being processed"); } mCache.clear(); } CreatingCache(@NonNull ValueFactory<K, V> valueFactory); }
CreatingCache { public synchronized void clear() { if (!mProcessedValues.isEmpty()) { throw new IllegalStateException("Cache values are being processed"); } mCache.clear(); } CreatingCache(@NonNull ValueFactory<K, V> valueFactory); @Nullable V get(@NonNull K key); synchronized void clear(); }
CreatingCache { public synchronized void clear() { if (!mProcessedValues.isEmpty()) { throw new IllegalStateException("Cache values are being processed"); } mCache.clear(); } CreatingCache(@NonNull ValueFactory<K, V> valueFactory); @Nullable V get(@NonNull K key); synchronized void clear();  }