From 67ffd2f45715dae09bf592ef625d73755bdba9a3 Mon Sep 17 00:00:00 2001 From: Dmitry Jemerov Date: Tue, 10 Nov 2009 13:44:39 +0300 Subject: [PATCH] avoid infinite recursion loop when storage creation doesn't work at all (part of RUBY-5181) --- .../util/src/com/intellij/util/io/storage/Storage.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/platform/util/src/com/intellij/util/io/storage/Storage.java b/platform/util/src/com/intellij/util/io/storage/Storage.java index e8bbc4899b55..9f29962adb71 100644 --- a/platform/util/src/com/intellij/util/io/storage/Storage.java +++ b/platform/util/src/com/intellij/util/io/storage/Storage.java @@ -66,6 +66,11 @@ public class Storage implements Disposable, Forceable { @NotNull public static Storage create(String storageFilePath, PagePool pool) throws IOException { + return create(storageFilePath, pool, 0); + } + + @NotNull + private static Storage create(String storageFilePath, PagePool pool, final int retryCount) throws IOException { convertFromOldExtensions(storageFilePath); final File recordsFile = new File(storageFilePath + INDEX_EXTENSION); @@ -94,7 +99,10 @@ public class Storage implements Disposable, Forceable { if (!deleted) { throw new IOException("Can't delete caches at: " + storageFilePath); } - return create(storageFilePath, pool); + if (retryCount >= 5) { + throw new IOException("Can't create storage at: " + storageFilePath); + } + return create(storageFilePath, pool, retryCount+1); } return new Storage(storageFilePath, recordsTable, dataTable, pool);