{"action":"created","comment":{"url":"https://api.github.com/repos/square/okhttp/pulls/comments/35656746","id":35656746,"diff_hunk":"@@ -393,8 +409,75 @@ public Connection getConnection() {\n   }\n \n   /**\n-   * Report and attempt to recover from {@code e}. Returns a new HTTP engine\n-   * that should be used for the retry if {@code e} is recoverable, or null if\n+   * Attempt to recover from failure to connect via a route. Returns a new HTTP engine\n+   * that should be used for the retry if there are other routes to try, or null if\n+   * there are no more routes to try.\n+   */\n+  public HttpEngine recover(RouteException e) {\n+    if (routeSelector != null && connection != null) {\n+      connectFailed(routeSelector, e.getLastConnectException());\n+    }\n+\n+    if (routeSelector == null && connection == null // No connection.\n+        || routeSelector != null && !routeSelector.hasNext() // No more routes to attempt.\n+        || !isRecoverable(e)) {\n+      return null;\n+    }\n+\n+    Connection connection = close();\n+\n+    // For failure recovery, use the same route selector with a new connection.\n+    return new HttpEngine(client, userRequest, bufferRequestBody, callerWritesRequestBody,\n+        forWebSocket, connection, routeSelector, (RetryableSink) requestBodyOut, priorResponse);\n+  }\n+\n+  private boolean isRecoverable(RouteException e) {\n+    // If the application has opted-out of recovery, don't recover.\n+    if (!client.getRetryOnConnectionFailure()) {\n+      return false;\n+    }\n+\n+    // Problems with a route may mean the connection can be retried with a new route, or may\n+    // indicate a client-side or server-side issue that should not be retried. To tell, we must look\n+    // at the cause.\n+\n+    IOException ioe = e.getLastConnectException();\n+\n+    // TODO(nfuller): This is the same logic as in ConnectionSpecSelector\n+    // If there was a protocol problem, don't recover.\n+    if (ioe instanceof ProtocolException) {\n+      return false;\n+    }\n+\n+    // If there was an interruption or timeout, don't recover.\n+    if (ioe instanceof InterruptedIOException) {","path":"okhttp/src/main/java/com/squareup/okhttp/internal/http/HttpEngine.java","position":118,"original_position":118,"commit_id":"60f5406dcc094d0431420139bd002e8bdd4ea5d5","original_commit_id":"60f5406dcc094d0431420139bd002e8bdd4ea5d5","user":{"login":"narayank","id":3646811,"avatar_url":"https://avatars.githubusercontent.com/u/3646811?v=3","gravatar_id":"","url":"https://api.github.com/users/narayank","html_url":"https://github.com/narayank","followers_url":"https://api.github.com/users/narayank/followers","following_url":"https://api.github.com/users/narayank/following{/other_user}","gists_url":"https://api.github.com/users/narayank/gists{/gist_id}","starred_url":"https://api.github.com/users/narayank/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/narayank/subscriptions","organizations_url":"https://api.github.com/users/narayank/orgs","repos_url":"https://api.github.com/users/narayank/repos","events_url":"https://api.github.com/users/narayank/events{/privacy}","received_events_url":"https://api.github.com/users/narayank/received_events","type":"User","site_admin":false},"body":"What was the purpose of this change (lines 452 - 455) ? This appears to have caused a regression on some devices where there are (network, not device) issues with IPV6 addresses, but where IPV4 addresses work ok.","created_at":"2015-07-28T14:55:09Z","updated_at":"2015-07-28T14:55:09Z","html_url":"https://github.com/square/okhttp/pull/1388#discussion_r35656746","pull_request_url":"https://api.github.com/repos/square/okhttp/pulls/1388","_links":{"self":{"href":"https://api.github.com/repos/square/okhttp/pulls/comments/35656746"},"html":{"href":"https://github.com/square/okhttp/pull/1388#discussion_r35656746"},"pull_request":{"href":"https://api.github.com/repos/square/okhttp/pulls/1388"}}},"pull_request":{"url":"https://api.github.com/repos/square/okhttp/pulls/1388","id":29081234,"html_url":"https://github.com/square/okhttp/pull/1388","diff_url":"https://github.com/square/okhttp/pull/1388.diff","patch_url":"https://github.com/square/okhttp/pull/1388.patch","issue_url":"https://api.github.com/repos/square/okhttp/issues/1388","number":1388,"state":"closed","locked":false,"title":"Move TLS retries / fallback into Connection.","user":{"login":"nfuller","id":6388721,"avatar_url":"https://avatars.githubusercontent.com/u/6388721?v=3","gravatar_id":"","url":"https://api.github.com/users/nfuller","html_url":"https://github.com/nfuller","followers_url":"https://api.github.com/users/nfuller/followers","following_url":"https://api.github.com/users/nfuller/following{/other_user}","gists_url":"https://api.github.com/users/nfuller/gists{/gist_id}","starred_url":"https://api.github.com/users/nfuller/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nfuller/subscriptions","organizations_url":"https://api.github.com/users/nfuller/orgs","repos_url":"https://api.github.com/users/nfuller/repos","events_url":"https://api.github.com/users/nfuller/events{/privacy}","received_events_url":"https://api.github.com/users/nfuller/received_events","type":"User","site_admin":false},"body":"API changes:\r\n1) Added: Address.getCertificatePinner()\r\n2) Incompatible API change: Address constructor no longer\r\nincludes ConnectionSpecs. Removed getConnectionSpecs().\r\n3) Added: ConnectionSpec.isCompatible(SSLSocket)\r\n4) Added: TlsVersion.javaNames()\r\n\r\nImplicit / semantic / internal changes:\r\n\r\n1) Connection now handles all attempts to connect via a route\r\n(effectively a {proxy, socket address} pair), rather than just\r\none attempt. i.e. Connection now handles all the TLS negotiation\r\nfallbacks internally.\r\n\r\n2) Route no longer deals with TLS versions. Individual TLS\r\nfailures are not counted against a Route. If no connection\r\nattempts to a route were successful the failure is counted\r\nagainst the route.\r\n\r\n3) The code makes a distinction between when various\r\nIOExceptions occur, with the intention making retries a bit\r\nsmarter. It is now more obvious which exceptions happen during\r\nsetup, connection, HTTP communication and thus which can be\r\nretried and whether the request might have been sent.","created_at":"2015-02-11T10:44:29Z","updated_at":"2015-07-28T14:55:09Z","closed_at":"2015-04-13T21:21:45Z","merged_at":"2015-04-13T21:21:45Z","merge_commit_sha":"b614dad6a9f366ea36a5409fae1e014480a67a4d","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/square/okhttp/pulls/1388/commits","review_comments_url":"https://api.github.com/repos/square/okhttp/pulls/1388/comments","review_comment_url":"https://api.github.com/repos/square/okhttp/pulls/comments{/number}","comments_url":"https://api.github.com/repos/square/okhttp/issues/1388/comments","statuses_url":"https://api.github.com/repos/square/okhttp/statuses/60f5406dcc094d0431420139bd002e8bdd4ea5d5","head":{"label":"nfuller:CutDownAlternativeTlsFallback1","ref":"CutDownAlternativeTlsFallback1","sha":"60f5406dcc094d0431420139bd002e8bdd4ea5d5","user":{"login":"nfuller","id":6388721,"avatar_url":"https://avatars.githubusercontent.com/u/6388721?v=3","gravatar_id":"","url":"https://api.github.com/users/nfuller","html_url":"https://github.com/nfuller","followers_url":"https://api.github.com/users/nfuller/followers","following_url":"https://api.github.com/users/nfuller/following{/other_user}","gists_url":"https://api.github.com/users/nfuller/gists{/gist_id}","starred_url":"https://api.github.com/users/nfuller/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nfuller/subscriptions","organizations_url":"https://api.github.com/users/nfuller/orgs","repos_url":"https://api.github.com/users/nfuller/repos","events_url":"https://api.github.com/users/nfuller/events{/privacy}","received_events_url":"https://api.github.com/users/nfuller/received_events","type":"User","site_admin":false},"repo":{"id":17255665,"name":"okhttp","full_name":"nfuller/okhttp","owner":{"login":"nfuller","id":6388721,"avatar_url":"https://avatars.githubusercontent.com/u/6388721?v=3","gravatar_id":"","url":"https://api.github.com/users/nfuller","html_url":"https://github.com/nfuller","followers_url":"https://api.github.com/users/nfuller/followers","following_url":"https://api.github.com/users/nfuller/following{/other_user}","gists_url":"https://api.github.com/users/nfuller/gists{/gist_id}","starred_url":"https://api.github.com/users/nfuller/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nfuller/subscriptions","organizations_url":"https://api.github.com/users/nfuller/orgs","repos_url":"https://api.github.com/users/nfuller/repos","events_url":"https://api.github.com/users/nfuller/events{/privacy}","received_events_url":"https://api.github.com/users/nfuller/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/nfuller/okhttp","description":"An HTTP+SPDY client for Android and Java applications.","fork":true,"url":"https://api.github.com/repos/nfuller/okhttp","forks_url":"https://api.github.com/repos/nfuller/okhttp/forks","keys_url":"https://api.github.com/repos/nfuller/okhttp/keys{/key_id}","collaborators_url":"https://api.github.com/repos/nfuller/okhttp/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/nfuller/okhttp/teams","hooks_url":"https://api.github.com/repos/nfuller/okhttp/hooks","issue_events_url":"https://api.github.com/repos/nfuller/okhttp/issues/events{/number}","events_url":"https://api.github.com/repos/nfuller/okhttp/events","assignees_url":"https://api.github.com/repos/nfuller/okhttp/assignees{/user}","branches_url":"https://api.github.com/repos/nfuller/okhttp/branches{/branch}","tags_url":"https://api.github.com/repos/nfuller/okhttp/tags","blobs_url":"https://api.github.com/repos/nfuller/okhttp/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/nfuller/okhttp/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/nfuller/okhttp/git/refs{/sha}","trees_url":"https://api.github.com/repos/nfuller/okhttp/git/trees{/sha}","statuses_url":"https://api.github.com/repos/nfuller/okhttp/statuses/{sha}","languages_url":"https://api.github.com/repos/nfuller/okhttp/languages","stargazers_url":"https://api.github.com/repos/nfuller/okhttp/stargazers","contributors_url":"https://api.github.com/repos/nfuller/okhttp/contributors","subscribers_url":"https://api.github.com/repos/nfuller/okhttp/subscribers","subscription_url":"https://api.github.com/repos/nfuller/okhttp/subscription","commits_url":"https://api.github.com/repos/nfuller/okhttp/commits{/sha}","git_commits_url":"https://api.github.com/repos/nfuller/okhttp/git/commits{/sha}","comments_url":"https://api.github.com/repos/nfuller/okhttp/comments{/number}","issue_comment_url":"https://api.github.com/repos/nfuller/okhttp/issues/comments{/number}","contents_url":"https://api.github.com/repos/nfuller/okhttp/contents/{+path}","compare_url":"https://api.github.com/repos/nfuller/okhttp/compare/{base}...{head}","merges_url":"https://api.github.com/repos/nfuller/okhttp/merges","archive_url":"https://api.github.com/repos/nfuller/okhttp/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/nfuller/okhttp/downloads","issues_url":"https://api.github.com/repos/nfuller/okhttp/issues{/number}","pulls_url":"https://api.github.com/repos/nfuller/okhttp/pulls{/number}","milestones_url":"https://api.github.com/repos/nfuller/okhttp/milestones{/number}","notifications_url":"https://api.github.com/repos/nfuller/okhttp/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/nfuller/okhttp/labels{/name}","releases_url":"https://api.github.com/repos/nfuller/okhttp/releases{/id}","created_at":"2014-02-27T16:30:14Z","updated_at":"2015-04-14T09:20:58Z","pushed_at":"2015-06-12T11:49:38Z","git_url":"git://github.com/nfuller/okhttp.git","ssh_url":"git@github.com:nfuller/okhttp.git","clone_url":"https://github.com/nfuller/okhttp.git","svn_url":"https://github.com/nfuller/okhttp","homepage":"http://square.github.io/okhttp/","size":9007,"stargazers_count":1,"watchers_count":1,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":true,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":1,"default_branch":"master"}},"base":{"label":"square:master","ref":"master","sha":"0237d3c3f29b004f4313b2b9fd58830b29cc6311","user":{"login":"square","id":82592,"avatar_url":"https://avatars.githubusercontent.com/u/82592?v=3","gravatar_id":"","url":"https://api.github.com/users/square","html_url":"https://github.com/square","followers_url":"https://api.github.com/users/square/followers","following_url":"https://api.github.com/users/square/following{/other_user}","gists_url":"https://api.github.com/users/square/gists{/gist_id}","starred_url":"https://api.github.com/users/square/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/square/subscriptions","organizations_url":"https://api.github.com/users/square/orgs","repos_url":"https://api.github.com/users/square/repos","events_url":"https://api.github.com/users/square/events{/privacy}","received_events_url":"https://api.github.com/users/square/received_events","type":"Organization","site_admin":false},"repo":{"id":5152285,"name":"okhttp","full_name":"square/okhttp","owner":{"login":"square","id":82592,"avatar_url":"https://avatars.githubusercontent.com/u/82592?v=3","gravatar_id":"","url":"https://api.github.com/users/square","html_url":"https://github.com/square","followers_url":"https://api.github.com/users/square/followers","following_url":"https://api.github.com/users/square/following{/other_user}","gists_url":"https://api.github.com/users/square/gists{/gist_id}","starred_url":"https://api.github.com/users/square/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/square/subscriptions","organizations_url":"https://api.github.com/users/square/orgs","repos_url":"https://api.github.com/users/square/repos","events_url":"https://api.github.com/users/square/events{/privacy}","received_events_url":"https://api.github.com/users/square/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/square/okhttp","description":"An HTTP+SPDY client for Android and Java applications.","fork":false,"url":"https://api.github.com/repos/square/okhttp","forks_url":"https://api.github.com/repos/square/okhttp/forks","keys_url":"https://api.github.com/repos/square/okhttp/keys{/key_id}","collaborators_url":"https://api.github.com/repos/square/okhttp/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/square/okhttp/teams","hooks_url":"https://api.github.com/repos/square/okhttp/hooks","issue_events_url":"https://api.github.com/repos/square/okhttp/issues/events{/number}","events_url":"https://api.github.com/repos/square/okhttp/events","assignees_url":"https://api.github.com/repos/square/okhttp/assignees{/user}","branches_url":"https://api.github.com/repos/square/okhttp/branches{/branch}","tags_url":"https://api.github.com/repos/square/okhttp/tags","blobs_url":"https://api.github.com/repos/square/okhttp/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/square/okhttp/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/square/okhttp/git/refs{/sha}","trees_url":"https://api.github.com/repos/square/okhttp/git/trees{/sha}","statuses_url":"https://api.github.com/repos/square/okhttp/statuses/{sha}","languages_url":"https://api.github.com/repos/square/okhttp/languages","stargazers_url":"https://api.github.com/repos/square/okhttp/stargazers","contributors_url":"https://api.github.com/repos/square/okhttp/contributors","subscribers_url":"https://api.github.com/repos/square/okhttp/subscribers","subscription_url":"https://api.github.com/repos/square/okhttp/subscription","commits_url":"https://api.github.com/repos/square/okhttp/commits{/sha}","git_commits_url":"https://api.github.com/repos/square/okhttp/git/commits{/sha}","comments_url":"https://api.github.com/repos/square/okhttp/comments{/number}","issue_comment_url":"https://api.github.com/repos/square/okhttp/issues/comments{/number}","contents_url":"https://api.github.com/repos/square/okhttp/contents/{+path}","compare_url":"https://api.github.com/repos/square/okhttp/compare/{base}...{head}","merges_url":"https://api.github.com/repos/square/okhttp/merges","archive_url":"https://api.github.com/repos/square/okhttp/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/square/okhttp/downloads","issues_url":"https://api.github.com/repos/square/okhttp/issues{/number}","pulls_url":"https://api.github.com/repos/square/okhttp/pulls{/number}","milestones_url":"https://api.github.com/repos/square/okhttp/milestones{/number}","notifications_url":"https://api.github.com/repos/square/okhttp/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/square/okhttp/labels{/name}","releases_url":"https://api.github.com/repos/square/okhttp/releases{/id}","created_at":"2012-07-23T13:42:55Z","updated_at":"2015-07-28T13:00:42Z","pushed_at":"2015-07-28T08:47:49Z","git_url":"git://github.com/square/okhttp.git","ssh_url":"git@github.com:square/okhttp.git","clone_url":"https://github.com/square/okhttp.git","svn_url":"https://github.com/square/okhttp","homepage":"http://square.github.io/okhttp/","size":28520,"stargazers_count":5327,"watchers_count":5327,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":1228,"mirror_url":null,"open_issues_count":108,"forks":1228,"open_issues":108,"watchers":5327,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/square/okhttp/pulls/1388"},"html":{"href":"https://github.com/square/okhttp/pull/1388"},"issue":{"href":"https://api.github.com/repos/square/okhttp/issues/1388"},"comments":{"href":"https://api.github.com/repos/square/okhttp/issues/1388/comments"},"review_comments":{"href":"https://api.github.com/repos/square/okhttp/pulls/1388/comments"},"review_comment":{"href":"https://api.github.com/repos/square/okhttp/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/square/okhttp/pulls/1388/commits"},"statuses":{"href":"https://api.github.com/repos/square/okhttp/statuses/60f5406dcc094d0431420139bd002e8bdd4ea5d5"}}}}