{"action":"created","comment":{"url":"https://api.github.com/repos/palantir/atlasdb/pulls/comments/88015422","pull_request_review_id":8601583,"id":88015422,"diff_hunk":"@@ -0,0 +1,116 @@\n+/**\n+ * Copyright 2016 Palantir Technologies\n+ *\n+ * Licensed under the BSD-3 License (the \"License\");\n+ * you may not use this file except in compliance with the License.\n+ * You may obtain a copy of the License at\n+ *\n+ * http://opensource.org/licenses/BSD-3-Clause\n+ *\n+ * Unless required by applicable law or agreed to in writing, software\n+ * distributed under the License is distributed on an \"AS IS\" BASIS,\n+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n+ * See the License for the specific language governing permissions and\n+ * limitations under the License.\n+ */\n+package com.palantir.atlasdb.http;\n+\n+import static org.hamcrest.Matchers.instanceOf;\n+import static org.hamcrest.Matchers.is;\n+import static org.hamcrest.Matchers.sameInstance;\n+import static org.junit.Assert.assertNull;\n+import static org.junit.Assert.assertThat;\n+import static org.mockito.Mockito.mock;\n+import static org.mockito.Mockito.when;\n+\n+import java.util.Collection;\n+import java.util.Date;\n+import java.util.HashMap;\n+import java.util.Map;\n+\n+import org.junit.Before;\n+import org.junit.Test;\n+\n+import feign.Response;\n+import feign.RetryableException;\n+import feign.codec.ErrorDecoder;\n+\n+public class AtlasDbErrorDecoderTest {\n+    private static final String EMPTY_METHOD_KEY = \"\";\n+\n+    private static final Exception NON_RETRYABLE_EXCEPTION = new Exception();\n+    private static final Exception RETRYABLE_EXCEPTION = new RetryableException(\"MyException\", new Date());\n+\n+    private static final int STATUS_503 = 503;\n+    private static final int STATUS_NOT_503 = 511;\n+\n+    ErrorDecoder defaultDecoder;\n+    AtlasDbErrorDecoder atlasDbDecoder;\n+\n+    @Before\n+    public void setUp() {\n+        defaultDecoder = mock(ErrorDecoder.class);\n+        atlasDbDecoder = new AtlasDbErrorDecoder(defaultDecoder);\n+    }\n+\n+    @Test\n+    public void shouldCreateNewRetryableExceptionWithNullRetryAfterWhen503AndNotRetryableException() {\n+        Response response = createResponse(STATUS_503);\n+        makeDefaultDecoderReplyWhenReceivingResponse(response, NON_RETRYABLE_EXCEPTION);\n+\n+        AtlasDbErrorDecoder decoder = new AtlasDbErrorDecoder(defaultDecoder);\n+        Exception exception = decoder.decode(EMPTY_METHOD_KEY, response);\n+\n+        assertThat(exception, is(instanceOf(RetryableException.class)));\n+        if (exception instanceof RetryableException) {\n+            RetryableException retryableException = (RetryableException) exception;\n+            assertNull(retryableException.retryAfter());\n+        }\n+    }\n+\n+    @Test\n+    public void shouldDelegateToDefaultDecoderWhen503AndRetryableException() {\n+        Response response = createResponse(STATUS_503);\n+        makeDefaultDecoderReplyWhenReceivingResponse(response, RETRYABLE_EXCEPTION);\n+\n+        AtlasDbErrorDecoder decoder = new AtlasDbErrorDecoder(defaultDecoder);\n+        Exception exception = decoder.decode(EMPTY_METHOD_KEY, response);\n+\n+        assertThat(exception, is(sameInstance(RETRYABLE_EXCEPTION)));\n+    }\n+\n+    @Test\n+    public void shouldDelegateToDefaultDecoderWhenNeither503NorRetryableException() {\n+        Response response = createResponse(STATUS_NOT_503);\n+        makeDefaultDecoderReplyWhenReceivingResponse(response, NON_RETRYABLE_EXCEPTION);\n+\n+        AtlasDbErrorDecoder decoder = new AtlasDbErrorDecoder(defaultDecoder);","path":"atlasdb-config/src/test/java/com/palantir/atlasdb/http/AtlasDbErrorDecoderTest.java","position":null,"original_position":87,"commit_id":"b1b78960e673fc6f22ad74229b8f1f8d6313f1d3","original_commit_id":"f5bc3944e5a793356d4c0debcc0a03cf2b795c6b","user":{"login":"harrybiddle","id":5887227,"avatar_url":"https://avatars.githubusercontent.com/u/5887227?v=3","gravatar_id":"","url":"https://api.github.com/users/harrybiddle","html_url":"https://github.com/harrybiddle","followers_url":"https://api.github.com/users/harrybiddle/followers","following_url":"https://api.github.com/users/harrybiddle/following{/other_user}","gists_url":"https://api.github.com/users/harrybiddle/gists{/gist_id}","starred_url":"https://api.github.com/users/harrybiddle/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/harrybiddle/subscriptions","organizations_url":"https://api.github.com/users/harrybiddle/orgs","repos_url":"https://api.github.com/users/harrybiddle/repos","events_url":"https://api.github.com/users/harrybiddle/events{/privacy}","received_events_url":"https://api.github.com/users/harrybiddle/received_events","type":"User","site_admin":false},"body":"Done!","created_at":"2016-11-15T13:29:59Z","updated_at":"2016-11-15T13:29:59Z","html_url":"https://github.com/palantir/atlasdb/pull/1175#discussion_r88015422","pull_request_url":"https://api.github.com/repos/palantir/atlasdb/pulls/1175","_links":{"self":{"href":"https://api.github.com/repos/palantir/atlasdb/pulls/comments/88015422"},"html":{"href":"https://github.com/palantir/atlasdb/pull/1175#discussion_r88015422"},"pull_request":{"href":"https://api.github.com/repos/palantir/atlasdb/pulls/1175"}}},"pull_request":{"url":"https://api.github.com/repos/palantir/atlasdb/pulls/1175","id":92773035,"html_url":"https://github.com/palantir/atlasdb/pull/1175","diff_url":"https://github.com/palantir/atlasdb/pull/1175.diff","patch_url":"https://github.com/palantir/atlasdb/pull/1175.patch","issue_url":"https://api.github.com/repos/palantir/atlasdb/issues/1175","number":1175,"state":"open","locked":false,"title":"Treat 503 as retryable","user":{"login":"harrybiddle","id":5887227,"avatar_url":"https://avatars.githubusercontent.com/u/5887227?v=3","gravatar_id":"","url":"https://api.github.com/users/harrybiddle","html_url":"https://github.com/harrybiddle","followers_url":"https://api.github.com/users/harrybiddle/followers","following_url":"https://api.github.com/users/harrybiddle/following{/other_user}","gists_url":"https://api.github.com/users/harrybiddle/gists{/gist_id}","starred_url":"https://api.github.com/users/harrybiddle/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/harrybiddle/subscriptions","organizations_url":"https://api.github.com/users/harrybiddle/orgs","repos_url":"https://api.github.com/users/harrybiddle/repos","events_url":"https://api.github.com/users/harrybiddle/events{/privacy}","received_events_url":"https://api.github.com/users/harrybiddle/received_events","type":"User","site_admin":false},"body":"This addresses #1146.\r\n\r\nChanges introduced in this PR:\r\n\r\n- We now _always_ create `RetryableExceptions` when we receive 503 responses. (The default behaviour of Feign is that it doesn't consider a 503 response without a Retry-After header to be retryable).\r\n- Before this PR, if the response does not contain a Retry-After header, we would abort our retrying logic. Now we retry on different servers even if there is no Retry-After header.\r\n\r\nWaiting for confirmation from @ungureanuvladvictor that this unblocks him, before merging.\r\n\r\n<!-- Reviewable:start -->\r\n\n---\r\nThis change is [<img src=\"https://reviewable.io/review_button.svg\" height=\"34\" align=\"absmiddle\" alt=\"Reviewable\"/>](https://reviewable.io/reviews/palantir/atlasdb/1175)\r\n<!-- Reviewable:end -->\r\n","created_at":"2016-11-08T12:59:14Z","updated_at":"2016-11-15T13:29:59Z","closed_at":null,"merged_at":null,"merge_commit_sha":"60a605078b9045bccdd8d332ca1a3b078558d775","assignee":null,"assignees":[],"milestone":{"url":"https://api.github.com/repos/palantir/atlasdb/milestones/4","html_url":"https://github.com/palantir/atlasdb/milestones/0.25.0","labels_url":"https://api.github.com/repos/palantir/atlasdb/milestones/4/labels","id":2125263,"number":4,"title":"0.25.0","description":"","creator":{"login":"rhero","id":7671354,"avatar_url":"https://avatars.githubusercontent.com/u/7671354?v=3","gravatar_id":"","url":"https://api.github.com/users/rhero","html_url":"https://github.com/rhero","followers_url":"https://api.github.com/users/rhero/followers","following_url":"https://api.github.com/users/rhero/following{/other_user}","gists_url":"https://api.github.com/users/rhero/gists{/gist_id}","starred_url":"https://api.github.com/users/rhero/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rhero/subscriptions","organizations_url":"https://api.github.com/users/rhero/orgs","repos_url":"https://api.github.com/users/rhero/repos","events_url":"https://api.github.com/users/rhero/events{/privacy}","received_events_url":"https://api.github.com/users/rhero/received_events","type":"User","site_admin":false},"open_issues":7,"closed_issues":1,"state":"open","created_at":"2016-11-09T17:34:29Z","updated_at":"2016-11-14T13:41:10Z","due_on":"2016-11-19T00:00:00Z","closed_at":null},"commits_url":"https://api.github.com/repos/palantir/atlasdb/pulls/1175/commits","review_comments_url":"https://api.github.com/repos/palantir/atlasdb/pulls/1175/comments","review_comment_url":"https://api.github.com/repos/palantir/atlasdb/pulls/comments{/number}","comments_url":"https://api.github.com/repos/palantir/atlasdb/issues/1175/comments","statuses_url":"https://api.github.com/repos/palantir/atlasdb/statuses/b1b78960e673fc6f22ad74229b8f1f8d6313f1d3","head":{"label":"palantir:improvement/treat-503-as-retryable","ref":"improvement/treat-503-as-retryable","sha":"b1b78960e673fc6f22ad74229b8f1f8d6313f1d3","user":{"login":"palantir","id":303157,"avatar_url":"https://avatars.githubusercontent.com/u/303157?v=3","gravatar_id":"","url":"https://api.github.com/users/palantir","html_url":"https://github.com/palantir","followers_url":"https://api.github.com/users/palantir/followers","following_url":"https://api.github.com/users/palantir/following{/other_user}","gists_url":"https://api.github.com/users/palantir/gists{/gist_id}","starred_url":"https://api.github.com/users/palantir/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/palantir/subscriptions","organizations_url":"https://api.github.com/users/palantir/orgs","repos_url":"https://api.github.com/users/palantir/repos","events_url":"https://api.github.com/users/palantir/events{/privacy}","received_events_url":"https://api.github.com/users/palantir/received_events","type":"Organization","site_admin":false},"repo":{"id":36960637,"name":"atlasdb","full_name":"palantir/atlasdb","owner":{"login":"palantir","id":303157,"avatar_url":"https://avatars.githubusercontent.com/u/303157?v=3","gravatar_id":"","url":"https://api.github.com/users/palantir","html_url":"https://github.com/palantir","followers_url":"https://api.github.com/users/palantir/followers","following_url":"https://api.github.com/users/palantir/following{/other_user}","gists_url":"https://api.github.com/users/palantir/gists{/gist_id}","starred_url":"https://api.github.com/users/palantir/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/palantir/subscriptions","organizations_url":"https://api.github.com/users/palantir/orgs","repos_url":"https://api.github.com/users/palantir/repos","events_url":"https://api.github.com/users/palantir/events{/privacy}","received_events_url":"https://api.github.com/users/palantir/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/palantir/atlasdb","description":"Transactional Distributed Database Layer","fork":false,"url":"https://api.github.com/repos/palantir/atlasdb","forks_url":"https://api.github.com/repos/palantir/atlasdb/forks","keys_url":"https://api.github.com/repos/palantir/atlasdb/keys{/key_id}","collaborators_url":"https://api.github.com/repos/palantir/atlasdb/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/palantir/atlasdb/teams","hooks_url":"https://api.github.com/repos/palantir/atlasdb/hooks","issue_events_url":"https://api.github.com/repos/palantir/atlasdb/issues/events{/number}","events_url":"https://api.github.com/repos/palantir/atlasdb/events","assignees_url":"https://api.github.com/repos/palantir/atlasdb/assignees{/user}","branches_url":"https://api.github.com/repos/palantir/atlasdb/branches{/branch}","tags_url":"https://api.github.com/repos/palantir/atlasdb/tags","blobs_url":"https://api.github.com/repos/palantir/atlasdb/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/palantir/atlasdb/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/palantir/atlasdb/git/refs{/sha}","trees_url":"https://api.github.com/repos/palantir/atlasdb/git/trees{/sha}","statuses_url":"https://api.github.com/repos/palantir/atlasdb/statuses/{sha}","languages_url":"https://api.github.com/repos/palantir/atlasdb/languages","stargazers_url":"https://api.github.com/repos/palantir/atlasdb/stargazers","contributors_url":"https://api.github.com/repos/palantir/atlasdb/contributors","subscribers_url":"https://api.github.com/repos/palantir/atlasdb/subscribers","subscription_url":"https://api.github.com/repos/palantir/atlasdb/subscription","commits_url":"https://api.github.com/repos/palantir/atlasdb/commits{/sha}","git_commits_url":"https://api.github.com/repos/palantir/atlasdb/git/commits{/sha}","comments_url":"https://api.github.com/repos/palantir/atlasdb/comments{/number}","issue_comment_url":"https://api.github.com/repos/palantir/atlasdb/issues/comments{/number}","contents_url":"https://api.github.com/repos/palantir/atlasdb/contents/{+path}","compare_url":"https://api.github.com/repos/palantir/atlasdb/compare/{base}...{head}","merges_url":"https://api.github.com/repos/palantir/atlasdb/merges","archive_url":"https://api.github.com/repos/palantir/atlasdb/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/palantir/atlasdb/downloads","issues_url":"https://api.github.com/repos/palantir/atlasdb/issues{/number}","pulls_url":"https://api.github.com/repos/palantir/atlasdb/pulls{/number}","milestones_url":"https://api.github.com/repos/palantir/atlasdb/milestones{/number}","notifications_url":"https://api.github.com/repos/palantir/atlasdb/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/palantir/atlasdb/labels{/name}","releases_url":"https://api.github.com/repos/palantir/atlasdb/releases{/id}","deployments_url":"https://api.github.com/repos/palantir/atlasdb/deployments","created_at":"2015-06-05T23:42:44Z","updated_at":"2016-11-15T12:01:43Z","pushed_at":"2016-11-15T13:29:39Z","git_url":"git://github.com/palantir/atlasdb.git","ssh_url":"git@github.com:palantir/atlasdb.git","clone_url":"https://github.com/palantir/atlasdb.git","svn_url":"https://github.com/palantir/atlasdb","homepage":"http://palantir.github.io/atlasdb/","size":28454,"stargazers_count":410,"watchers_count":410,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":true,"forks_count":62,"mirror_url":null,"open_issues_count":106,"forks":62,"open_issues":106,"watchers":410,"default_branch":"develop"}},"base":{"label":"palantir:develop","ref":"develop","sha":"10fa8546bc8c03d1347b07340673bc7a074fc862","user":{"login":"palantir","id":303157,"avatar_url":"https://avatars.githubusercontent.com/u/303157?v=3","gravatar_id":"","url":"https://api.github.com/users/palantir","html_url":"https://github.com/palantir","followers_url":"https://api.github.com/users/palantir/followers","following_url":"https://api.github.com/users/palantir/following{/other_user}","gists_url":"https://api.github.com/users/palantir/gists{/gist_id}","starred_url":"https://api.github.com/users/palantir/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/palantir/subscriptions","organizations_url":"https://api.github.com/users/palantir/orgs","repos_url":"https://api.github.com/users/palantir/repos","events_url":"https://api.github.com/users/palantir/events{/privacy}","received_events_url":"https://api.github.com/users/palantir/received_events","type":"Organization","site_admin":false},"repo":{"id":36960637,"name":"atlasdb","full_name":"palantir/atlasdb","owner":{"login":"palantir","id":303157,"avatar_url":"https://avatars.githubusercontent.com/u/303157?v=3","gravatar_id":"","url":"https://api.github.com/users/palantir","html_url":"https://github.com/palantir","followers_url":"https://api.github.com/users/palantir/followers","following_url":"https://api.github.com/users/palantir/following{/other_user}","gists_url":"https://api.github.com/users/palantir/gists{/gist_id}","starred_url":"https://api.github.com/users/palantir/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/palantir/subscriptions","organizations_url":"https://api.github.com/users/palantir/orgs","repos_url":"https://api.github.com/users/palantir/repos","events_url":"https://api.github.com/users/palantir/events{/privacy}","received_events_url":"https://api.github.com/users/palantir/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/palantir/atlasdb","description":"Transactional Distributed Database Layer","fork":false,"url":"https://api.github.com/repos/palantir/atlasdb","forks_url":"https://api.github.com/repos/palantir/atlasdb/forks","keys_url":"https://api.github.com/repos/palantir/atlasdb/keys{/key_id}","collaborators_url":"https://api.github.com/repos/palantir/atlasdb/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/palantir/atlasdb/teams","hooks_url":"https://api.github.com/repos/palantir/atlasdb/hooks","issue_events_url":"https://api.github.com/repos/palantir/atlasdb/issues/events{/number}","events_url":"https://api.github.com/repos/palantir/atlasdb/events","assignees_url":"https://api.github.com/repos/palantir/atlasdb/assignees{/user}","branches_url":"https://api.github.com/repos/palantir/atlasdb/branches{/branch}","tags_url":"https://api.github.com/repos/palantir/atlasdb/tags","blobs_url":"https://api.github.com/repos/palantir/atlasdb/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/palantir/atlasdb/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/palantir/atlasdb/git/refs{/sha}","trees_url":"https://api.github.com/repos/palantir/atlasdb/git/trees{/sha}","statuses_url":"https://api.github.com/repos/palantir/atlasdb/statuses/{sha}","languages_url":"https://api.github.com/repos/palantir/atlasdb/languages","stargazers_url":"https://api.github.com/repos/palantir/atlasdb/stargazers","contributors_url":"https://api.github.com/repos/palantir/atlasdb/contributors","subscribers_url":"https://api.github.com/repos/palantir/atlasdb/subscribers","subscription_url":"https://api.github.com/repos/palantir/atlasdb/subscription","commits_url":"https://api.github.com/repos/palantir/atlasdb/commits{/sha}","git_commits_url":"https://api.github.com/repos/palantir/atlasdb/git/commits{/sha}","comments_url":"https://api.github.com/repos/palantir/atlasdb/comments{/number}","issue_comment_url":"https://api.github.com/repos/palantir/atlasdb/issues/comments{/number}","contents_url":"https://api.github.com/repos/palantir/atlasdb/contents/{+path}","compare_url":"https://api.github.com/repos/palantir/atlasdb/compare/{base}...{head}","merges_url":"https://api.github.com/repos/palantir/atlasdb/merges","archive_url":"https://api.github.com/repos/palantir/atlasdb/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/palantir/atlasdb/downloads","issues_url":"https://api.github.com/repos/palantir/atlasdb/issues{/number}","pulls_url":"https://api.github.com/repos/palantir/atlasdb/pulls{/number}","milestones_url":"https://api.github.com/repos/palantir/atlasdb/milestones{/number}","notifications_url":"https://api.github.com/repos/palantir/atlasdb/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/palantir/atlasdb/labels{/name}","releases_url":"https://api.github.com/repos/palantir/atlasdb/releases{/id}","deployments_url":"https://api.github.com/repos/palantir/atlasdb/deployments","created_at":"2015-06-05T23:42:44Z","updated_at":"2016-11-15T12:01:43Z","pushed_at":"2016-11-15T13:29:39Z","git_url":"git://github.com/palantir/atlasdb.git","ssh_url":"git@github.com:palantir/atlasdb.git","clone_url":"https://github.com/palantir/atlasdb.git","svn_url":"https://github.com/palantir/atlasdb","homepage":"http://palantir.github.io/atlasdb/","size":28454,"stargazers_count":410,"watchers_count":410,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":true,"forks_count":62,"mirror_url":null,"open_issues_count":106,"forks":62,"open_issues":106,"watchers":410,"default_branch":"develop"}},"_links":{"self":{"href":"https://api.github.com/repos/palantir/atlasdb/pulls/1175"},"html":{"href":"https://github.com/palantir/atlasdb/pull/1175"},"issue":{"href":"https://api.github.com/repos/palantir/atlasdb/issues/1175"},"comments":{"href":"https://api.github.com/repos/palantir/atlasdb/issues/1175/comments"},"review_comments":{"href":"https://api.github.com/repos/palantir/atlasdb/pulls/1175/comments"},"review_comment":{"href":"https://api.github.com/repos/palantir/atlasdb/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/palantir/atlasdb/pulls/1175/commits"},"statuses":{"href":"https://api.github.com/repos/palantir/atlasdb/statuses/b1b78960e673fc6f22ad74229b8f1f8d6313f1d3"}}}}
{"actor":{"display_login":"harrybiddle"}}