{"action":"created","comment":{"url":"https://api.github.com/repos/square/okhttp/pulls/comments/40501273","id":40501273,"diff_hunk":"@@ -156,54 +160,53 @@ public Sink newMessageSink(int formatOpcode) {\n     }\n     activeWriter = true;\n \n+    // Reset FrameSink state for a new writer.\n     frameSink.formatOpcode = formatOpcode;\n     frameSink.isFirstFrame = true;\n+    frameSink.closed = false;\n+\n     return frameSink;\n   }\n \n-  private void writeFrame(int formatOpcode, Buffer source, long byteCount,\n-      boolean isFirstFrame, boolean isFinal) throws IOException {\n-    if (closed) throw new IOException(\"closed\");\n+  private void writeMessageFrameSynchronized(int formatOpcode, long byteCount, boolean isFirstFrame,\n+      boolean isFinal) throws IOException {\n+    if (writerClosed) throw new IOException(\"closed\");\n \n-    int opcode = isFirstFrame ? formatOpcode : OPCODE_CONTINUATION;\n-\n-    synchronized (sink) {\n-      int b0 = opcode;\n-      if (isFinal) {\n-        b0 |= B0_FLAG_FIN;\n-      }\n-      sink.writeByte(b0);\n-\n-      int b1 = 0;\n-      if (isClient) {\n-        b1 |= B1_FLAG_MASK;\n-        random.nextBytes(maskKey);\n-      }\n-      if (byteCount <= PAYLOAD_MAX) {\n-        b1 |= (int) byteCount;\n-        sink.writeByte(b1);\n-      } else if (byteCount <= 0xffffL) { // Unsigned short.\n-        b1 |= PAYLOAD_SHORT;\n-        sink.writeByte(b1);\n-        sink.writeShort((int) byteCount);\n-      } else {\n-        b1 |= PAYLOAD_LONG;\n-        sink.writeByte(b1);\n-        sink.writeLong(byteCount);\n-      }\n+    int b0 = isFirstFrame ? formatOpcode : OPCODE_CONTINUATION;\n+    if (isFinal) {\n+      b0 |= B0_FLAG_FIN;\n+    }\n+    sink.writeByte(b0);\n \n-      if (isClient) {\n-        sink.write(maskKey);\n-        writeAllMasked(source, byteCount);\n-      } else {\n-        sink.write(source, byteCount);\n-      }\n+    int b1 = 0;\n+    if (isClient) {\n+      b1 |= B1_FLAG_MASK;\n+      random.nextBytes(maskKey);\n+    }\n+    if (byteCount <= PAYLOAD_MAX) {","path":"okhttp-ws/src/main/java/com/squareup/okhttp/internal/ws/WebSocketWriter.java","position":148,"original_position":148,"commit_id":"27cff24dde834e3216c14b5736e666f8478de9b6","original_commit_id":"27cff24dde834e3216c14b5736e666f8478de9b6","user":{"login":"JakeWharton","id":66577,"avatar_url":"https://avatars.githubusercontent.com/u/66577?v=3","gravatar_id":"","url":"https://api.github.com/users/JakeWharton","html_url":"https://github.com/JakeWharton","followers_url":"https://api.github.com/users/JakeWharton/followers","following_url":"https://api.github.com/users/JakeWharton/following{/other_user}","gists_url":"https://api.github.com/users/JakeWharton/gists{/gist_id}","starred_url":"https://api.github.com/users/JakeWharton/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JakeWharton/subscriptions","organizations_url":"https://api.github.com/users/JakeWharton/orgs","repos_url":"https://api.github.com/users/JakeWharton/repos","events_url":"https://api.github.com/users/JakeWharton/events{/privacy}","received_events_url":"https://api.github.com/users/JakeWharton/received_events","type":"User","site_admin":false},"body":"Yes it would.","created_at":"2015-09-27T04:18:16Z","updated_at":"2015-09-27T04:18:16Z","html_url":"https://github.com/square/okhttp/pull/1876#discussion_r40501273","pull_request_url":"https://api.github.com/repos/square/okhttp/pulls/1876","_links":{"self":{"href":"https://api.github.com/repos/square/okhttp/pulls/comments/40501273"},"html":{"href":"https://github.com/square/okhttp/pull/1876#discussion_r40501273"},"pull_request":{"href":"https://api.github.com/repos/square/okhttp/pulls/1876"}}},"pull_request":{"url":"https://api.github.com/repos/square/okhttp/pulls/1876","id":46093961,"html_url":"https://github.com/square/okhttp/pull/1876","diff_url":"https://github.com/square/okhttp/pull/1876.diff","patch_url":"https://github.com/square/okhttp/pull/1876.patch","issue_url":"https://api.github.com/repos/square/okhttp/issues/1876","number":1876,"state":"open","locked":false,"title":"Introduce intermediate storage for frame contents.","user":{"login":"JakeWharton","id":66577,"avatar_url":"https://avatars.githubusercontent.com/u/66577?v=3","gravatar_id":"","url":"https://api.github.com/users/JakeWharton","html_url":"https://github.com/JakeWharton","followers_url":"https://api.github.com/users/JakeWharton/followers","following_url":"https://api.github.com/users/JakeWharton/following{/other_user}","gists_url":"https://api.github.com/users/JakeWharton/gists{/gist_id}","starred_url":"https://api.github.com/users/JakeWharton/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JakeWharton/subscriptions","organizations_url":"https://api.github.com/users/JakeWharton/orgs","repos_url":"https://api.github.com/users/JakeWharton/repos","events_url":"https://api.github.com/users/JakeWharton/events{/privacy}","received_events_url":"https://api.github.com/users/JakeWharton/received_events","type":"User","site_admin":false},"body":"This eliminates the need to always send a frame for every `FrameSink#write` and to always send an empty frame for `FrameSink#close`. Now, we only emit bytes once Okio reports complete segments.","created_at":"2015-09-27T02:43:56Z","updated_at":"2015-09-27T04:18:16Z","closed_at":null,"merged_at":null,"merge_commit_sha":"59d540a3667e711ef0ee3e5aec33de05c2d40b9f","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/square/okhttp/pulls/1876/commits","review_comments_url":"https://api.github.com/repos/square/okhttp/pulls/1876/comments","review_comment_url":"https://api.github.com/repos/square/okhttp/pulls/comments{/number}","comments_url":"https://api.github.com/repos/square/okhttp/issues/1876/comments","statuses_url":"https://api.github.com/repos/square/okhttp/statuses/27cff24dde834e3216c14b5736e666f8478de9b6","head":{"label":"square:jw/buffer-in-ws-writer","ref":"jw/buffer-in-ws-writer","sha":"27cff24dde834e3216c14b5736e666f8478de9b6","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-09-27T03:54:35Z","pushed_at":"2015-09-27T02:51:37Z","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":29557,"stargazers_count":6283,"watchers_count":6283,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":1511,"mirror_url":null,"open_issues_count":119,"forks":1511,"open_issues":119,"watchers":6283,"default_branch":"master"}},"base":{"label":"square:master","ref":"master","sha":"c6386cec99ffc9fba569d3d77e9f2df9044089d0","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-09-27T03:54:35Z","pushed_at":"2015-09-27T02:51:37Z","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":29557,"stargazers_count":6283,"watchers_count":6283,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":1511,"mirror_url":null,"open_issues_count":119,"forks":1511,"open_issues":119,"watchers":6283,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/square/okhttp/pulls/1876"},"html":{"href":"https://github.com/square/okhttp/pull/1876"},"issue":{"href":"https://api.github.com/repos/square/okhttp/issues/1876"},"comments":{"href":"https://api.github.com/repos/square/okhttp/issues/1876/comments"},"review_comments":{"href":"https://api.github.com/repos/square/okhttp/pulls/1876/comments"},"review_comment":{"href":"https://api.github.com/repos/square/okhttp/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/square/okhttp/pulls/1876/commits"},"statuses":{"href":"https://api.github.com/repos/square/okhttp/statuses/27cff24dde834e3216c14b5736e666f8478de9b6"}}}}