EA-43465 - assert: GroovyDslFileIndex$.compute

This commit is contained in:
peter
2013-02-03 23:48:21 +01:00
parent ac293f3fc7
commit 03500a04fc
@@ -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");