From db8a6b155821c8b77db3ad39be9fafbc6991a2d4 Mon Sep 17 00:00:00 2001 From: Roman Shevchenko Date: Wed, 30 Jan 2013 14:04:03 +0400 Subject: [PATCH] Prevent tests from hanging --- .../documentation/AbstractExternalFilter.java | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/platform/lang-impl/src/com/intellij/codeInsight/documentation/AbstractExternalFilter.java b/platform/lang-impl/src/com/intellij/codeInsight/documentation/AbstractExternalFilter.java index 681e8e4393d0..3334413f5806 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/documentation/AbstractExternalFilter.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/documentation/AbstractExternalFilter.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2012 JetBrains s.r.o. + * Copyright 2000-2013 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,6 +16,7 @@ package com.intellij.codeInsight.documentation; import com.intellij.ide.BrowserUtil; +import com.intellij.openapi.application.Application; import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.progress.ProcessCanceledException; @@ -276,6 +277,12 @@ public abstract class AbstractExternalFilter { @Nullable @SuppressWarnings({"HardCodedStringLiteral"}) public String getExternalDocInfo(final String surl) throws Exception { + Application app = ApplicationManager.getApplication(); + if (app.isDispatchThread() || app.isWriteAccessAllowed()) { + LOG.error("May block indefinitely: shouldn't be called from EDT or under write lock"); + return null; + } + if (surl == null) return null; if (MyJavadocFetcher.isFree()) { final MyJavadocFetcher fetcher = new MyJavadocFetcher(surl, new MyDocBuilder() { @@ -284,7 +291,7 @@ public abstract class AbstractExternalFilter { doBuildFromStream(surl, input, result); } }); - final Future fetcherFuture = ApplicationManager.getApplication().executeOnPooledThread(fetcher); + final Future fetcherFuture = app.executeOnPooledThread(fetcher); try { fetcherFuture.get(); }