From 03500a04fced1f37adda7d42c6cbdbf494716a3d Mon Sep 17 00:00:00 2001 From: peter Date: Sun, 3 Feb 2013 23:48:21 +0100 Subject: [PATCH] EA-43465 - assert: GroovyDslFileIndex$.compute --- .../groovy/dsl/GroovyDslFileIndex.java | 26 ++++++++++++------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/dsl/GroovyDslFileIndex.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/dsl/GroovyDslFileIndex.java index 64b0803db1a0..ca405965f44d 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/dsl/GroovyDslFileIndex.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/dsl/GroovyDslFileIndex.java @@ -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 { final Semaphore semaphore = new Semaphore(); semaphore.down(); + final AtomicReference>> ref = new AtomicReference>>(); ourPool.execute(new Runnable() { @SuppressWarnings("AssignmentToStaticFieldFromInstanceMethod") @Override public void run() { - if (derefStandardScripts() != null) { - return; - } - try { + List> pairs = derefStandardScripts(); + if (pairs != null) { + ref.set(pairs); + return; + } + Set scriptFolders = new LinkedHashSet(); // perhaps a separate extension for that? for (GroovyFrameworkConfigNotification extension : GroovyFrameworkConfigNotification.EP_NAME.getExtensions()) { @@ -324,6 +328,7 @@ public class GroovyDslFileIndex extends ScalarIndexExtension { } } ourStandardScripts = new SoftReference>>(executors); + ref.set(executors); } catch (OutOfMemoryError e) { stopGdsl = true; @@ -339,13 +344,16 @@ public class GroovyDslFileIndex extends ScalarIndexExtension { } }); - 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>> SCRIPTS_CACHE = Key.create("GdslScriptCache");