diff --git a/platform/lang-impl/src/com/intellij/psi/stubs/StubUpdatingIndex.java b/platform/lang-impl/src/com/intellij/psi/stubs/StubUpdatingIndex.java index 5c22c6a700f9..8bc874d04202 100644 --- a/platform/lang-impl/src/com/intellij/psi/stubs/StubUpdatingIndex.java +++ b/platform/lang-impl/src/com/intellij/psi/stubs/StubUpdatingIndex.java @@ -187,7 +187,8 @@ public class StubUpdatingIndex extends CustomImplementationFileBasedIndexExtensi @NotNull @Override - public UpdatableIndex createIndexImplementation(final ID indexId, @NotNull final FileBasedIndex owner, @NotNull IndexStorage storage) { + public UpdatableIndex createIndexImplementation(final ID indexId, @NotNull final FileBasedIndex owner, @NotNull IndexStorage storage) + throws StorageException { if (storage instanceof MemoryIndexStorage) { final MemoryIndexStorage memStorage = (MemoryIndexStorage)storage; memStorage.addBufferingStateListsner(new MemoryIndexStorage.BufferingStateListener() { @@ -229,15 +230,9 @@ public class StubUpdatingIndex extends CustomImplementationFileBasedIndexExtensi private static class MyIndex extends MapReduceIndex { private StubIndexImpl myStubIndex; - public MyIndex(final ID indexId, final IndexStorage storage, final DataIndexer indexer) { + public MyIndex(final ID indexId, final IndexStorage storage, final DataIndexer indexer) throws StorageException { super(indexId, indexer, storage); - try { - checkNameStorage(); - } - catch (StorageException e) { - LOG.info(e); - FileBasedIndex.getInstance().requestRebuild(INDEX_ID); - } + checkNameStorage(); } @Override diff --git a/platform/lang-impl/src/com/intellij/util/indexing/CustomImplementationFileBasedIndexExtension.java b/platform/lang-impl/src/com/intellij/util/indexing/CustomImplementationFileBasedIndexExtension.java index cc1088e3e3a6..16a0a4a43860 100644 --- a/platform/lang-impl/src/com/intellij/util/indexing/CustomImplementationFileBasedIndexExtension.java +++ b/platform/lang-impl/src/com/intellij/util/indexing/CustomImplementationFileBasedIndexExtension.java @@ -23,5 +23,6 @@ import org.jetbrains.annotations.NotNull; public abstract class CustomImplementationFileBasedIndexExtension extends FileBasedIndexExtension { @NotNull - public abstract UpdatableIndex createIndexImplementation(final ID indexId, @NotNull FileBasedIndex owner, @NotNull IndexStorage storage); + public abstract UpdatableIndex createIndexImplementation(final ID indexId, @NotNull FileBasedIndex owner, @NotNull IndexStorage storage) + throws StorageException; } \ No newline at end of file diff --git a/platform/lang-impl/src/com/intellij/util/indexing/FileBasedIndexImpl.java b/platform/lang-impl/src/com/intellij/util/indexing/FileBasedIndexImpl.java index bff212256402..b3b1728b3914 100644 --- a/platform/lang-impl/src/com/intellij/util/indexing/FileBasedIndexImpl.java +++ b/platform/lang-impl/src/com/intellij/util/indexing/FileBasedIndexImpl.java @@ -386,9 +386,11 @@ public class FileBasedIndexImpl extends FileBasedIndex { IndexInfrastructure.rewriteVersion(versionFile, version); } + MapIndexStorage storage = null; + for (int attempt = 0; attempt < 2; attempt++) { try { - final MapIndexStorage storage = new MapIndexStorage( + storage = new MapIndexStorage( IndexInfrastructure.getStorageFile(name), extension.getKeyDescriptor(), extension.getValueExternalizer(), @@ -413,8 +415,13 @@ public class FileBasedIndexImpl extends FileBasedIndex { myNoLimitCheckTypes.addAll(extension.getFileTypesWithSizeLimitNotApplicable()); break; } - catch (IOException e) { + catch (Exception e) { LOG.info(e); + try { + if (storage != null) storage.close(); + storage = null; + } catch (Exception ex) {} + FileUtil.delete(IndexInfrastructure.getIndexRootDir(name)); IndexInfrastructure.rewriteVersion(versionFile, version); } @@ -467,7 +474,7 @@ public class FileBasedIndexImpl extends FileBasedIndex { } @NotNull - private UpdatableIndex createIndex(@NotNull final ID indexId, @NotNull final FileBasedIndexExtension extension, @NotNull final MemoryIndexStorage storage) throws IOException { + private UpdatableIndex createIndex(@NotNull final ID indexId, @NotNull final FileBasedIndexExtension extension, @NotNull final MemoryIndexStorage storage) throws StorageException, IOException { final MapReduceIndex index; if (extension instanceof CustomImplementationFileBasedIndexExtension) { final UpdatableIndex custom = ((CustomImplementationFileBasedIndexExtension)extension).createIndexImplementation(indexId, this, storage);