diff --git a/okhttp/src/main/java/okhttp3/Cache.java b/okhttp/src/main/java/okhttp3/Cache.java index 204b3dca42f9..3717417b6da0 100644 --- a/okhttp/src/main/java/okhttp3/Cache.java +++ b/okhttp/src/main/java/okhttp3/Cache.java @@ -16,7 +16,9 @@ package okhttp3; +import java.io.Closeable; import java.io.File; +import java.io.Flushable; import java.io.IOException; import java.security.cert.Certificate; import java.security.cert.CertificateEncodingException; @@ -131,7 +133,7 @@ * caching directives. It even offers convenient constants {@link CacheControl#FORCE_NETWORK} and * {@link CacheControl#FORCE_CACHE} that address the use cases above. */ -public final class Cache { +public final class Cache implements Closeable, Flushable { private static final int VERSION = 201105; private static final int ENTRY_METADATA = 0; private static final int ENTRY_BODY = 1; @@ -380,11 +382,11 @@ public long maxSize() { return cache.getMaxSize(); } - public void flush() throws IOException { + @Override public void flush() throws IOException { cache.flush(); } - public void close() throws IOException { + @Override public void close() throws IOException { cache.close(); } diff --git a/okhttp/src/main/java/okhttp3/internal/DiskLruCache.java b/okhttp/src/main/java/okhttp3/internal/DiskLruCache.java index 70564087d204..34f993a9a688 100644 --- a/okhttp/src/main/java/okhttp3/internal/DiskLruCache.java +++ b/okhttp/src/main/java/okhttp3/internal/DiskLruCache.java @@ -20,6 +20,7 @@ import java.io.EOFException; import java.io.File; import java.io.FileNotFoundException; +import java.io.Flushable; import java.io.IOException; import java.util.ArrayList; import java.util.Arrays; @@ -81,7 +82,7 @@ * value, the edit will fail silently. Callers should handle other problems by catching {@code * IOException} and responding appropriately. */ -public final class DiskLruCache implements Closeable { +public final class DiskLruCache implements Closeable, Flushable { static final String JOURNAL_FILE = "journal"; static final String JOURNAL_FILE_TEMP = "journal.tmp"; static final String JOURNAL_FILE_BACKUP = "journal.bkp"; @@ -623,7 +624,7 @@ private synchronized void checkNotClosed() { } /** Force buffered operations to the filesystem. */ - public synchronized void flush() throws IOException { + @Override public synchronized void flush() throws IOException { if (!initialized) return; checkNotClosed(); @@ -632,7 +633,7 @@ public synchronized void flush() throws IOException { } /** Closes this cache. Stored values will remain on the filesystem. */ - public synchronized void close() throws IOException { + @Override public synchronized void close() throws IOException { if (!initialized || closed) { closed = true; return;