boolean (final TaskRepository repository) { TestConnectionTask task = new TestConnectionTask(TaskBundle.message("dialog.title.test.connection")) { @Override public void run(@NotNull ProgressIndicator indicator) { indicator.setText(TaskBundle.message("progress.text.connecting.to", repository.getUrl())); indicator.setFraction(0); indicator.setIndeterminate(true); try { myConnection = repository.createCancellableConnection(); if (myConnection != null) { Future<Exception> future = ApplicationManager.getApplication().executeOnPooledThread(myConnection); while (true) { try { myException = future.get(100, TimeUnit.MILLISECONDS); return; } catch (TimeoutException ignore) { try { indicator.checkCanceled(); } catch (ProcessCanceledException e) { myException = e; myConnection.cancel(); return; } } catch (Exception e) { myException = e; return; } } } else { try { repository.testConnection(); } catch (Exception e) { LOG.info(e); myException = e; } } } catch (Exception e) { myException = e; } } }; ProgressManager.getInstance().run(task); Exception e = task.myException; if (e == null) { myBadRepositories.remove(repository); Messages.showMessageDialog(myProject, TaskBundle.message("dialog.message.connection.successful"), TaskBundle.message("dialog.title.connection"), Messages.getInformationIcon()); } else if (!(e instanceof ProcessCanceledException)) { String message = e.getMessage(); if (e instanceof UnknownHostException) { message = TaskBundle.message("dialog.message.unknown.host", message); } if (message == null) { LOG.error(e); message = TaskBundle.message("dialog.message.unknown.error"); } Messages.showErrorDialog(myProject, StringUtil.capitalize(message), TaskBundle.message("dialog.title.error")); } return e == null; }