github: implement abortable connection check
authorAleksey Pivovarov <Aleksey.Pivovarov@jetbrains.com>
Wed, 3 Sep 2014 08:50:30 +0000 (12:50 +0400)
committerAleksey Pivovarov <Aleksey.Pivovarov@jetbrains.com>
Wed, 3 Sep 2014 09:21:29 +0000 (13:21 +0400)
plugins/github/src/org/jetbrains/plugins/github/tasks/GithubRepository.java

index d92c4f43cd008443e6127be7e3659100f137ca4c..c77b7cf18acef2198ff1da774ee1108508f28814 100644 (file)
@@ -22,10 +22,7 @@ import org.jetbrains.plugins.github.api.GithubApiUtil;
 import org.jetbrains.plugins.github.api.GithubConnection;
 import org.jetbrains.plugins.github.api.GithubIssue;
 import org.jetbrains.plugins.github.api.GithubIssueComment;
-import org.jetbrains.plugins.github.exceptions.GithubAuthenticationException;
-import org.jetbrains.plugins.github.exceptions.GithubJsonException;
-import org.jetbrains.plugins.github.exceptions.GithubRateLimitExceededException;
-import org.jetbrains.plugins.github.exceptions.GithubStatusCodeException;
+import org.jetbrains.plugins.github.exceptions.*;
 import org.jetbrains.plugins.github.util.GithubAuthData;
 import org.jetbrains.plugins.github.util.GithubUtil;
 
@@ -68,14 +65,20 @@ public class GithubRepository extends BaseRepositoryImpl {
   @Override
   public CancellableConnection createCancellableConnection() {
     return new CancellableConnection() {
+      private final GithubConnection myConnection = new GithubConnection(getAuthData(), false);
+
       @Override
       protected void doTest() throws Exception {
-        getIssues("", 10, false);
+        try {
+          GithubApiUtil.getIssuesQueried(myConnection, getRepoAuthor(), getRepoName(), "", false);
+        }
+        catch (GithubOperationCanceledException ignore) {
+        }
       }
 
       @Override
       public void cancel() {
-        // TODO
+        myConnection.abort();
       }
     };
   }