mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
EA-43465 - assert: GroovyDslFileIndex$.compute
This commit is contained in:
@@ -68,6 +68,7 @@ import java.util.concurrent.LinkedBlockingQueue;
|
||||
import java.util.concurrent.ThreadFactory;
|
||||
import java.util.concurrent.ThreadPoolExecutor;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
|
||||
/**
|
||||
* @author peter
|
||||
@@ -284,15 +285,18 @@ public class GroovyDslFileIndex extends ScalarIndexExtension<String> {
|
||||
|
||||
final Semaphore semaphore = new Semaphore();
|
||||
semaphore.down();
|
||||
final AtomicReference<List<Pair<File, GroovyDslExecutor>>> ref = new AtomicReference<List<Pair<File, GroovyDslExecutor>>>();
|
||||
ourPool.execute(new Runnable() {
|
||||
@SuppressWarnings("AssignmentToStaticFieldFromInstanceMethod")
|
||||
@Override
|
||||
public void run() {
|
||||
if (derefStandardScripts() != null) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
List<Pair<File, GroovyDslExecutor>> pairs = derefStandardScripts();
|
||||
if (pairs != null) {
|
||||
ref.set(pairs);
|
||||
return;
|
||||
}
|
||||
|
||||
Set<File> scriptFolders = new LinkedHashSet<File>();
|
||||
// perhaps a separate extension for that?
|
||||
for (GroovyFrameworkConfigNotification extension : GroovyFrameworkConfigNotification.EP_NAME.getExtensions()) {
|
||||
@@ -324,6 +328,7 @@ public class GroovyDslFileIndex extends ScalarIndexExtension<String> {
|
||||
}
|
||||
}
|
||||
ourStandardScripts = new SoftReference<List<Pair<File, GroovyDslExecutor>>>(executors);
|
||||
ref.set(executors);
|
||||
}
|
||||
catch (OutOfMemoryError e) {
|
||||
stopGdsl = true;
|
||||
@@ -339,13 +344,16 @@ public class GroovyDslFileIndex extends ScalarIndexExtension<String> {
|
||||
}
|
||||
});
|
||||
|
||||
while (derefStandardScripts() == null && !stopGdsl && !semaphore.waitFor(20)) {
|
||||
while (true) {
|
||||
ProgressManager.checkCanceled();
|
||||
|
||||
if (stopGdsl) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
if (ref.get() != null || semaphore.waitFor(20)) {
|
||||
return ref.get();
|
||||
}
|
||||
}
|
||||
if (stopGdsl) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
return derefStandardScripts();
|
||||
}
|
||||
|
||||
private static final Key<CachedValue<List<GroovyDslScript>>> SCRIPTS_CACHE = Key.create("GdslScriptCache");
|
||||
|
||||
Reference in New Issue
Block a user