mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
fixing "dispatch thread assertion": id-to-key index may be created not only on startup, but as a part of certain index rebuild procedure
This commit is contained in:
@@ -502,12 +502,32 @@ public class FileBasedIndexImpl extends FileBasedIndex {
|
||||
@Override
|
||||
public PersistentHashMap<Integer, Collection<K>> create() {
|
||||
try {
|
||||
return ProgressManager.getInstance().runProcessWithProgressSynchronously(new ThrowableComputable<PersistentHashMap<Integer, Collection<K>>, IOException>() {
|
||||
@Override
|
||||
public PersistentHashMap<Integer, Collection<K>> compute() throws IOException {
|
||||
return createIdToDataKeysIndex(indexId, keyDescriptor, storage);
|
||||
// this factory method may be called either on index creation from dispatch thread, or on index rebuild
|
||||
// from arbitrary thread and under some existing progress indicator
|
||||
final ProgressManager progressManager = ProgressManager.getInstance();
|
||||
final ProgressIndicator currentProgress = progressManager.getProgressIndicator();
|
||||
if (currentProgress == null && ApplicationManager.getApplication().isDispatchThread()) {
|
||||
return progressManager.runProcessWithProgressSynchronously(
|
||||
new ThrowableComputable<PersistentHashMap<Integer, Collection<K>>, IOException>() {
|
||||
@Override
|
||||
public PersistentHashMap<Integer, Collection<K>> compute() throws IOException {
|
||||
return createIdToDataKeysIndex(indexId, keyDescriptor, storage);
|
||||
}
|
||||
}, LangBundle.message("compacting.indices.title"), false, null);
|
||||
}
|
||||
if (currentProgress != null) {
|
||||
// reuse existing progress indicator if available
|
||||
currentProgress.pushState();
|
||||
currentProgress.setText(LangBundle.message("compacting.indices.title"));
|
||||
}
|
||||
try {
|
||||
return createIdToDataKeysIndex(indexId, keyDescriptor, storage);
|
||||
}
|
||||
finally {
|
||||
if (currentProgress != null) {
|
||||
currentProgress.popState();
|
||||
}
|
||||
}, LangBundle.message("compacting.indices.title"), false, null);
|
||||
}
|
||||
}
|
||||
catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
|
||||
Reference in New Issue
Block a user