@Nullable
 private List<Task> getIssuesFromRepositories(
     @Nullable String request,
     int max,
     long since,
     boolean forceRequest,
     @NotNull final ProgressIndicator cancelled) {
   List<Task> issues = null;
   for (final TaskRepository repository : getAllRepositories()) {
     if (!repository.isConfigured() || (!forceRequest && myBadRepositories.contains(repository))) {
       continue;
     }
     try {
       Task[] tasks = repository.getIssues(request, max, since, cancelled);
       myBadRepositories.remove(repository);
       if (issues == null) issues = new ArrayList<Task>(tasks.length);
       if (!repository.isSupported(TaskRepository.NATIVE_SEARCH) && request != null) {
         List<Task> filteredTasks =
             TaskSearchSupport.filterTasks(request, ContainerUtil.list(tasks));
         ContainerUtil.addAll(issues, filteredTasks);
       } else {
         ContainerUtil.addAll(issues, tasks);
       }
     } catch (ProcessCanceledException ignored) {
       // OK
     } catch (Exception e) {
       String reason = "";
       // Fix to IDEA-111810
       if (e.getClass() == Exception.class) {
         // probably contains some message meaningful to end-user
         reason = e.getMessage();
       }
       //noinspection InstanceofCatchParameter
       if (e instanceof SocketTimeoutException) {
         LOG.warn("Socket timeout from " + repository);
       } else {
         LOG.warn("Cannot connect to " + repository, e);
       }
       myBadRepositories.add(repository);
       if (forceRequest) {
         notifyAboutConnectionFailure(repository, reason);
       }
     }
   }
   return issues;
 }
  @Override
  public boolean testConnection(final TaskRepository repository) {

    TestConnectionTask task =
        new TestConnectionTask("Test connection") {
          public void run(@NotNull ProgressIndicator indicator) {
            indicator.setText("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, "Connection is successful", "Connection", Messages.getInformationIcon());
    } else if (!(e instanceof ProcessCanceledException)) {
      String message = e.getMessage();
      if (e instanceof UnknownHostException) {
        message = "Unknown host: " + message;
      }
      if (message == null) {
        LOG.error(e);
        message = "Unknown error";
      }
      Messages.showErrorDialog(myProject, StringUtil.capitalize(message), "Error");
    }
    return e == null;
  }