diff --git a/src/main/java/mdnet/cache/DiskLruCache.java b/src/main/java/mdnet/cache/DiskLruCache.java index d8c7f03..91e93af 100644 --- a/src/main/java/mdnet/cache/DiskLruCache.java +++ b/src/main/java/mdnet/cache/DiskLruCache.java @@ -254,7 +254,9 @@ public final class DiskLruCache implements Closeable { try { readJournalLine(reader.readLine()); lineCount++; - } catch (EOFException endOfJournal) { + } catch(UnexpectedJournalLineException ignored) { + // just continue and hope nothing breaks + } catch (EOFException e) { break; } } @@ -273,7 +275,7 @@ public final class DiskLruCache implements Closeable { private void readJournalLine(String line) throws IOException { int firstSpace = line.indexOf(' '); if (firstSpace == -1) { - throw new IOException("unexpected journal line: " + line); + throw new UnexpectedJournalLineException(line); } int keyBegin = firstSpace + 1; @@ -305,7 +307,7 @@ public final class DiskLruCache implements Closeable { } else if (secondSpace == -1 && firstSpace == READ.length() && line.startsWith(READ)) { // This work was already done by calling lruEntries.get(). } else { - throw new IOException("unexpected journal line: " + line); + throw new UnexpectedJournalLineException(line); } } diff --git a/src/main/java/mdnet/cache/UnexpectedJournalLineException.java b/src/main/java/mdnet/cache/UnexpectedJournalLineException.java new file mode 100644 index 0000000..7e14f0b --- /dev/null +++ b/src/main/java/mdnet/cache/UnexpectedJournalLineException.java @@ -0,0 +1,9 @@ +package mdnet.cache; + +import java.io.IOException; + +public class UnexpectedJournalLineException extends IOException { + public UnexpectedJournalLineException(String unexpectedLine) { + super("unexpected journal line: " + unexpectedLine); + } +}