diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/AbstractJavaModelTests.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/AbstractJavaModelTests.java index 0c3051832fd..a1e34b692b9 100644 --- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/AbstractJavaModelTests.java +++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/AbstractJavaModelTests.java @@ -4107,6 +4107,7 @@ public void waitForManualRefresh() { try { Job.getJobManager().wakeUp(ResourcesPlugin.FAMILY_MANUAL_REFRESH); Job.getJobManager().join(ResourcesPlugin.FAMILY_MANUAL_REFRESH, null); + waitForSnapShot(); JavaModelManager.getIndexManager().waitForIndex(isIndexDisabledForTest(), null); wasInterrupted = false; } catch (OperationCanceledException e) { @@ -4127,6 +4128,27 @@ public static boolean isTouchJobRunning() { return false; } + public void waitForSnapShot() { + if (isWorkspaceRuleAlreadyInUse(getWorkspaceRoot())){ + // Don't wait holding workspace lock on FAMILY_SNAPSHOT, because + // we might deadlock with DelayedSnapshotJob + System.out.println("\n\nAborted waitForSnapShot() because running with the workspace rule\n\n"); + return; + } + boolean wasInterrupted = false; + do { + try { + Job.getJobManager().wakeUp(ResourcesPlugin.FAMILY_SNAPSHOT); + Job.getJobManager().join(ResourcesPlugin.FAMILY_SNAPSHOT, null); + wasInterrupted = false; + } catch (OperationCanceledException e) { + e.printStackTrace(); + } catch (InterruptedException e) { + wasInterrupted = true; + } + } while (wasInterrupted); + } + public void waitUntilIndexesReady() { // dummy query for waiting until the indexes are ready SearchEngine engine = new SearchEngine();