Don't use Apache Commons Http Client
It has been removed from IJ bundle in 2022.3
@@ -26,13 +26,19 @@ import com.intellij.openapi.project.Project;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiFile;
import java.io.IOException;
+import java.net.HttpURLConnection;
import java.util.Collections;
import java.util.List;
+import java.util.concurrent.CompletableFuture;
import javax.annotation.Nullable;
+
+import com.intellij.util.io.HttpRequests;
import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.methods.HeadMethod;
import org.apache.commons.httpclient.params.HttpConnectionManagerParams;
+import static com.intellij.openapi.progress.util.ProgressIndicatorUtils.awaitWithCheckCanceled;
+
/** Provides quick docs for some .blazeproject elements. */
public class ProjectViewDocumentationProvider extends AbstractDocumentationProvider
implements ExternalDocumentationProvider {
@@ -111,25 +117,18 @@ public class ProjectViewDocumentationProvider extends AbstractDocumentationProvi
}
return url;
}
-
private static boolean pageExists(String url) {
- final HttpClient client = new HttpClient();
- final HttpConnectionManagerParams params = client.getHttpConnectionManager().getParams();
- params.setSoTimeout(5 * 1000);
- params.setConnectionTimeout(5 * 1000);
-
+ CompletableFuture<Boolean> f = CompletableFuture.supplyAsync(() -> {
try {
- final HeadMethod method = new HeadMethod(url);
- final int rc = client.executeMethod(method);
- if (rc == 404) {
- return false;
- }
- } catch (IllegalArgumentException e) {
- return false;
+ return HttpRequests.head(url)
+ .forceHttps(true)
+ .connectTimeout(5 * 1000)
+ .tryConnect() == HttpURLConnection.HTTP_OK;
} catch (IOException e) {
- // ignore
+ return false;
}
- return true;
+ });
+ return awaitWithCheckCanceled(f);
}
@Nullable
