{"action":"created","comment":{"url":"https://api.github.com/repos/cloudant/java-cloudant/pulls/comments/33654685","id":33654685,"diff_hunk":"@@ -33,4 +44,61 @@ public static String getHostName(String account) {\n         }\n \n     }\n+\n+    public static void removeReplicatorTestDoc(CloudantClient account, Response replicatorResponse)\n+            throws Exception {\n+\n+        //Find replicator document for removal\n+        ReplicatorDocument replicatorDoc = waitForReplicatorToComplete(account, replicatorResponse);\n+\n+        Response removeResponse = account.replicator()\n+                .replicatorDocId(replicatorDoc.getId())\n+                .replicatorDocRev(replicatorDoc.getRevision())\n+                .remove();\n+\n+        assertThat(removeResponse.getError(), is(nullValue()));\n+    }\n+\n+    public static ReplicatorDocument waitForReplicatorToComplete(CloudantClient account, Response replicatorResponse)\n+            throws Exception {\n+        ReplicatorDocument replicatorDoc = null;\n+\n+        boolean finished = false;\n+\n+        while(!finished && !hasTimedOut()) {\n+            //Sleep before finding replication document\n+            Thread.sleep(TIMEOUT_CONSTANT);\n+\n+            replicatorDoc = account.replicator()\n+                    .replicatorDocId(replicatorResponse.getId())\n+                    .find();\n+\n+            //If replicator state is completed or triggered, return true\n+            //If false, continue in the while loop until replicator is complete\n+            if(replicatorDoc != null && replicatorDoc.getReplicationState() != null\n+                    && (replicatorDoc.getReplicationState().equalsIgnoreCase(\"completed\")\n+                    || (replicatorDoc.getReplicationState().equalsIgnoreCase(\"triggered\")\n+                    && replicatorDoc.getContinuous()))) {\n+\n+                finished = true;\n+            }\n+        }\n+\n+        //Reset timeout to default 50 milliseconds\n+        TIMEOUT_CONSTANT = 100;\n+\n+        return replicatorDoc;\n+    }\n+\n+    private static boolean hasTimedOut() {\n+        long currentTime = System.currentTimeMillis();\n+        if(TIMEOUT_CONSTANT <= 3200 && currentTime < (currentTime + TIMEOUT_CONSTANT)) {","path":"src/test/java/com/cloudant/tests/util/Utils.java","position":77,"original_position":77,"commit_id":"c532b6db26a944c3731e5a18424c73df03b3410b","original_commit_id":"c532b6db26a944c3731e5a18424c73df03b3410b","user":{"login":"ricellis","id":10698320,"avatar_url":"https://avatars.githubusercontent.com/u/10698320?v=3","gravatar_id":"","url":"https://api.github.com/users/ricellis","html_url":"https://github.com/ricellis","followers_url":"https://api.github.com/users/ricellis/followers","following_url":"https://api.github.com/users/ricellis/following{/other_user}","gists_url":"https://api.github.com/users/ricellis/gists{/gist_id}","starred_url":"https://api.github.com/users/ricellis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ricellis/subscriptions","organizations_url":"https://api.github.com/users/ricellis/orgs","repos_url":"https://api.github.com/users/ricellis/repos","events_url":"https://api.github.com/users/ricellis/events{/privacy}","received_events_url":"https://api.github.com/users/ricellis/received_events","type":"User","site_admin":false},"body":"The check `currentTime < (currentTime + TIMEOUT_CONSTANT))` is always going to be true if `TIMEOUT_CONSTANT` is >0. It is also a bit confusing for me that the `TIMEOUT_CONSTANT` is not a constant. How would you feel about removing this `hasTimedOut` method and changing the while loop in `waitForReplicatorToComplete` to something like:\r\n```java\r\n        long startTime = System.currentTimeMillis();\r\n        long timeout = startTime + TIMEOUT_CONSTANT;\r\n        //initial wait of 100 ms\r\n        long delay = 100;\r\n        while (!finished && System.currentTimeMillis() < timeout) {\r\n            //Sleep before finding replication document\r\n            Thread.sleep(delay);\r\n\r\n            replicatorDoc = account.replicator()\r\n                    .replicatorDocId(replicatorResponse.getId())\r\n                    .find();\r\n\r\n            //If replicator state is completed or triggered, return true\r\n            //If false, continue in the while loop until replicator is complete\r\n\r\n            if (replicatorDoc != null && replicatorDoc.getReplicationState() != null\r\n                    && (replicatorDoc.getReplicationState().equalsIgnoreCase(\"completed\")\r\n                    || (replicatorDoc.getReplicationState().equalsIgnoreCase(\"triggered\")\r\n                    && replicatorDoc.getContinuous()))) {\r\n                finished = true;\r\n            }\r\n            //double the delay for the next iteration\r\n            delay *= 2;\r\n        }\r\n```","created_at":"2015-07-01T07:34:02Z","updated_at":"2015-07-01T07:34:02Z","html_url":"https://github.com/cloudant/java-cloudant/pull/59#discussion_r33654685","pull_request_url":"https://api.github.com/repos/cloudant/java-cloudant/pulls/59","_links":{"self":{"href":"https://api.github.com/repos/cloudant/java-cloudant/pulls/comments/33654685"},"html":{"href":"https://github.com/cloudant/java-cloudant/pull/59#discussion_r33654685"},"pull_request":{"href":"https://api.github.com/repos/cloudant/java-cloudant/pulls/59"}}},"pull_request":{"url":"https://api.github.com/repos/cloudant/java-cloudant/pulls/59","id":38686893,"html_url":"https://github.com/cloudant/java-cloudant/pull/59","diff_url":"https://github.com/cloudant/java-cloudant/pull/59.diff","patch_url":"https://github.com/cloudant/java-cloudant/pull/59.patch","issue_url":"https://api.github.com/repos/cloudant/java-cloudant/issues/59","number":59,"state":"open","locked":false,"title":"Intermittent failures of Replicator and Replication tests","user":{"login":"emlaver","id":10552966,"avatar_url":"https://avatars.githubusercontent.com/u/10552966?v=3","gravatar_id":"","url":"https://api.github.com/users/emlaver","html_url":"https://github.com/emlaver","followers_url":"https://api.github.com/users/emlaver/followers","following_url":"https://api.github.com/users/emlaver/following{/other_user}","gists_url":"https://api.github.com/users/emlaver/gists{/gist_id}","starred_url":"https://api.github.com/users/emlaver/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/emlaver/subscriptions","organizations_url":"https://api.github.com/users/emlaver/orgs","repos_url":"https://api.github.com/users/emlaver/repos","events_url":"https://api.github.com/users/emlaver/events{/privacy}","received_events_url":"https://api.github.com/users/emlaver/received_events","type":"User","site_admin":false},"body":"*What*\r\nInvestigate the intermittent failures of replicator and replication test classes.\r\n\r\n*How*\r\nThe tests were disabled as part of case 47450.  They required a timing fix which was resolved with Thread.sleep().  Also, the replicator documents used in each test are now removed when the test is complete.\r\n\r\n*Testing*\r\nSince these classes are test cases, no additional tests are required.\r\n\r\nFogBugz: 47545\r\n\r\nreviewer @ricellis \r\nreviewer @mikerhodes","created_at":"2015-06-26T20:35:07Z","updated_at":"2015-07-01T07:34:02Z","closed_at":null,"merged_at":null,"merge_commit_sha":"59243d63aa56d723d56d5ee482e4741e6d4d04c8","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/cloudant/java-cloudant/pulls/59/commits","review_comments_url":"https://api.github.com/repos/cloudant/java-cloudant/pulls/59/comments","review_comment_url":"https://api.github.com/repos/cloudant/java-cloudant/pulls/comments{/number}","comments_url":"https://api.github.com/repos/cloudant/java-cloudant/issues/59/comments","statuses_url":"https://api.github.com/repos/cloudant/java-cloudant/statuses/c532b6db26a944c3731e5a18424c73df03b3410b","head":{"label":"cloudant:47545-intermittent-failures-rep-tests-2","ref":"47545-intermittent-failures-rep-tests-2","sha":"c532b6db26a944c3731e5a18424c73df03b3410b","user":{"login":"cloudant","id":44642,"avatar_url":"https://avatars.githubusercontent.com/u/44642?v=3","gravatar_id":"","url":"https://api.github.com/users/cloudant","html_url":"https://github.com/cloudant","followers_url":"https://api.github.com/users/cloudant/followers","following_url":"https://api.github.com/users/cloudant/following{/other_user}","gists_url":"https://api.github.com/users/cloudant/gists{/gist_id}","starred_url":"https://api.github.com/users/cloudant/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cloudant/subscriptions","organizations_url":"https://api.github.com/users/cloudant/orgs","repos_url":"https://api.github.com/users/cloudant/repos","events_url":"https://api.github.com/users/cloudant/events{/privacy}","received_events_url":"https://api.github.com/users/cloudant/received_events","type":"Organization","site_admin":false},"repo":{"id":22873328,"name":"java-cloudant","full_name":"cloudant/java-cloudant","owner":{"login":"cloudant","id":44642,"avatar_url":"https://avatars.githubusercontent.com/u/44642?v=3","gravatar_id":"","url":"https://api.github.com/users/cloudant","html_url":"https://github.com/cloudant","followers_url":"https://api.github.com/users/cloudant/followers","following_url":"https://api.github.com/users/cloudant/following{/other_user}","gists_url":"https://api.github.com/users/cloudant/gists{/gist_id}","starred_url":"https://api.github.com/users/cloudant/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cloudant/subscriptions","organizations_url":"https://api.github.com/users/cloudant/orgs","repos_url":"https://api.github.com/users/cloudant/repos","events_url":"https://api.github.com/users/cloudant/events{/privacy}","received_events_url":"https://api.github.com/users/cloudant/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/cloudant/java-cloudant","description":"A Java client for Cloudant","fork":false,"url":"https://api.github.com/repos/cloudant/java-cloudant","forks_url":"https://api.github.com/repos/cloudant/java-cloudant/forks","keys_url":"https://api.github.com/repos/cloudant/java-cloudant/keys{/key_id}","collaborators_url":"https://api.github.com/repos/cloudant/java-cloudant/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/cloudant/java-cloudant/teams","hooks_url":"https://api.github.com/repos/cloudant/java-cloudant/hooks","issue_events_url":"https://api.github.com/repos/cloudant/java-cloudant/issues/events{/number}","events_url":"https://api.github.com/repos/cloudant/java-cloudant/events","assignees_url":"https://api.github.com/repos/cloudant/java-cloudant/assignees{/user}","branches_url":"https://api.github.com/repos/cloudant/java-cloudant/branches{/branch}","tags_url":"https://api.github.com/repos/cloudant/java-cloudant/tags","blobs_url":"https://api.github.com/repos/cloudant/java-cloudant/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/cloudant/java-cloudant/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/cloudant/java-cloudant/git/refs{/sha}","trees_url":"https://api.github.com/repos/cloudant/java-cloudant/git/trees{/sha}","statuses_url":"https://api.github.com/repos/cloudant/java-cloudant/statuses/{sha}","languages_url":"https://api.github.com/repos/cloudant/java-cloudant/languages","stargazers_url":"https://api.github.com/repos/cloudant/java-cloudant/stargazers","contributors_url":"https://api.github.com/repos/cloudant/java-cloudant/contributors","subscribers_url":"https://api.github.com/repos/cloudant/java-cloudant/subscribers","subscription_url":"https://api.github.com/repos/cloudant/java-cloudant/subscription","commits_url":"https://api.github.com/repos/cloudant/java-cloudant/commits{/sha}","git_commits_url":"https://api.github.com/repos/cloudant/java-cloudant/git/commits{/sha}","comments_url":"https://api.github.com/repos/cloudant/java-cloudant/comments{/number}","issue_comment_url":"https://api.github.com/repos/cloudant/java-cloudant/issues/comments{/number}","contents_url":"https://api.github.com/repos/cloudant/java-cloudant/contents/{+path}","compare_url":"https://api.github.com/repos/cloudant/java-cloudant/compare/{base}...{head}","merges_url":"https://api.github.com/repos/cloudant/java-cloudant/merges","archive_url":"https://api.github.com/repos/cloudant/java-cloudant/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/cloudant/java-cloudant/downloads","issues_url":"https://api.github.com/repos/cloudant/java-cloudant/issues{/number}","pulls_url":"https://api.github.com/repos/cloudant/java-cloudant/pulls{/number}","milestones_url":"https://api.github.com/repos/cloudant/java-cloudant/milestones{/number}","notifications_url":"https://api.github.com/repos/cloudant/java-cloudant/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/cloudant/java-cloudant/labels{/name}","releases_url":"https://api.github.com/repos/cloudant/java-cloudant/releases{/id}","created_at":"2014-08-12T10:19:56Z","updated_at":"2015-06-23T16:19:54Z","pushed_at":"2015-06-30T21:22:13Z","git_url":"git://github.com/cloudant/java-cloudant.git","ssh_url":"git@github.com:cloudant/java-cloudant.git","clone_url":"https://github.com/cloudant/java-cloudant.git","svn_url":"https://github.com/cloudant/java-cloudant","homepage":null,"size":3295,"stargazers_count":8,"watchers_count":8,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":10,"mirror_url":null,"open_issues_count":15,"forks":10,"open_issues":15,"watchers":8,"default_branch":"master"}},"base":{"label":"cloudant:master","ref":"master","sha":"5ff5e4f7e03b6c4a795affd4e5a3a6a14828d78f","user":{"login":"cloudant","id":44642,"avatar_url":"https://avatars.githubusercontent.com/u/44642?v=3","gravatar_id":"","url":"https://api.github.com/users/cloudant","html_url":"https://github.com/cloudant","followers_url":"https://api.github.com/users/cloudant/followers","following_url":"https://api.github.com/users/cloudant/following{/other_user}","gists_url":"https://api.github.com/users/cloudant/gists{/gist_id}","starred_url":"https://api.github.com/users/cloudant/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cloudant/subscriptions","organizations_url":"https://api.github.com/users/cloudant/orgs","repos_url":"https://api.github.com/users/cloudant/repos","events_url":"https://api.github.com/users/cloudant/events{/privacy}","received_events_url":"https://api.github.com/users/cloudant/received_events","type":"Organization","site_admin":false},"repo":{"id":22873328,"name":"java-cloudant","full_name":"cloudant/java-cloudant","owner":{"login":"cloudant","id":44642,"avatar_url":"https://avatars.githubusercontent.com/u/44642?v=3","gravatar_id":"","url":"https://api.github.com/users/cloudant","html_url":"https://github.com/cloudant","followers_url":"https://api.github.com/users/cloudant/followers","following_url":"https://api.github.com/users/cloudant/following{/other_user}","gists_url":"https://api.github.com/users/cloudant/gists{/gist_id}","starred_url":"https://api.github.com/users/cloudant/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cloudant/subscriptions","organizations_url":"https://api.github.com/users/cloudant/orgs","repos_url":"https://api.github.com/users/cloudant/repos","events_url":"https://api.github.com/users/cloudant/events{/privacy}","received_events_url":"https://api.github.com/users/cloudant/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/cloudant/java-cloudant","description":"A Java client for Cloudant","fork":false,"url":"https://api.github.com/repos/cloudant/java-cloudant","forks_url":"https://api.github.com/repos/cloudant/java-cloudant/forks","keys_url":"https://api.github.com/repos/cloudant/java-cloudant/keys{/key_id}","collaborators_url":"https://api.github.com/repos/cloudant/java-cloudant/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/cloudant/java-cloudant/teams","hooks_url":"https://api.github.com/repos/cloudant/java-cloudant/hooks","issue_events_url":"https://api.github.com/repos/cloudant/java-cloudant/issues/events{/number}","events_url":"https://api.github.com/repos/cloudant/java-cloudant/events","assignees_url":"https://api.github.com/repos/cloudant/java-cloudant/assignees{/user}","branches_url":"https://api.github.com/repos/cloudant/java-cloudant/branches{/branch}","tags_url":"https://api.github.com/repos/cloudant/java-cloudant/tags","blobs_url":"https://api.github.com/repos/cloudant/java-cloudant/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/cloudant/java-cloudant/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/cloudant/java-cloudant/git/refs{/sha}","trees_url":"https://api.github.com/repos/cloudant/java-cloudant/git/trees{/sha}","statuses_url":"https://api.github.com/repos/cloudant/java-cloudant/statuses/{sha}","languages_url":"https://api.github.com/repos/cloudant/java-cloudant/languages","stargazers_url":"https://api.github.com/repos/cloudant/java-cloudant/stargazers","contributors_url":"https://api.github.com/repos/cloudant/java-cloudant/contributors","subscribers_url":"https://api.github.com/repos/cloudant/java-cloudant/subscribers","subscription_url":"https://api.github.com/repos/cloudant/java-cloudant/subscription","commits_url":"https://api.github.com/repos/cloudant/java-cloudant/commits{/sha}","git_commits_url":"https://api.github.com/repos/cloudant/java-cloudant/git/commits{/sha}","comments_url":"https://api.github.com/repos/cloudant/java-cloudant/comments{/number}","issue_comment_url":"https://api.github.com/repos/cloudant/java-cloudant/issues/comments{/number}","contents_url":"https://api.github.com/repos/cloudant/java-cloudant/contents/{+path}","compare_url":"https://api.github.com/repos/cloudant/java-cloudant/compare/{base}...{head}","merges_url":"https://api.github.com/repos/cloudant/java-cloudant/merges","archive_url":"https://api.github.com/repos/cloudant/java-cloudant/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/cloudant/java-cloudant/downloads","issues_url":"https://api.github.com/repos/cloudant/java-cloudant/issues{/number}","pulls_url":"https://api.github.com/repos/cloudant/java-cloudant/pulls{/number}","milestones_url":"https://api.github.com/repos/cloudant/java-cloudant/milestones{/number}","notifications_url":"https://api.github.com/repos/cloudant/java-cloudant/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/cloudant/java-cloudant/labels{/name}","releases_url":"https://api.github.com/repos/cloudant/java-cloudant/releases{/id}","created_at":"2014-08-12T10:19:56Z","updated_at":"2015-06-23T16:19:54Z","pushed_at":"2015-06-30T21:22:13Z","git_url":"git://github.com/cloudant/java-cloudant.git","ssh_url":"git@github.com:cloudant/java-cloudant.git","clone_url":"https://github.com/cloudant/java-cloudant.git","svn_url":"https://github.com/cloudant/java-cloudant","homepage":null,"size":3295,"stargazers_count":8,"watchers_count":8,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":10,"mirror_url":null,"open_issues_count":15,"forks":10,"open_issues":15,"watchers":8,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/cloudant/java-cloudant/pulls/59"},"html":{"href":"https://github.com/cloudant/java-cloudant/pull/59"},"issue":{"href":"https://api.github.com/repos/cloudant/java-cloudant/issues/59"},"comments":{"href":"https://api.github.com/repos/cloudant/java-cloudant/issues/59/comments"},"review_comments":{"href":"https://api.github.com/repos/cloudant/java-cloudant/pulls/59/comments"},"review_comment":{"href":"https://api.github.com/repos/cloudant/java-cloudant/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/cloudant/java-cloudant/pulls/59/commits"},"statuses":{"href":"https://api.github.com/repos/cloudant/java-cloudant/statuses/c532b6db26a944c3731e5a18424c73df03b3410b"}}}}