diff --git a/gson/src/main/java/com/google/gson/Cache.java b/gson/src/main/java/com/google/gson/Cache.java index 32e1f8c8..0b425486 100644 --- a/gson/src/main/java/com/google/gson/Cache.java +++ b/gson/src/main/java/com/google/gson/Cache.java @@ -48,14 +48,4 @@ interface Cache { * @return the value for the given {@code key} */ V removeElement(K key); - - /** - * Removes everything from this cache. - */ - void clear(); - - /** - * @return the number of objects in this cache - */ - int size(); } diff --git a/gson/src/main/java/com/google/gson/LruCache.java b/gson/src/main/java/com/google/gson/LruCache.java index 947327e4..7c091d38 100644 --- a/gson/src/main/java/com/google/gson/LruCache.java +++ b/gson/src/main/java/com/google/gson/LruCache.java @@ -37,28 +37,18 @@ final class LruCache extends LinkedHashMap implements Cache { this.maxCapacity = maxCapacity; } - public void addElement(K key, V value) { + public synchronized void addElement(K key, V value) { put(key, value); } - @Override - public void clear() { - super.clear(); - } - - public V getElement(K key) { + public synchronized V getElement(K key) { return get(key); } - public V removeElement(K key) { + public synchronized V removeElement(K key) { return remove(key); } - @Override - public int size() { - return super.size(); - } - @Override protected boolean removeEldestEntry(Map.Entry entry) { return size() > maxCapacity;