{"action":"created","issue":{"url":"https://api.github.com/repos/Genius/rails2/issues/2","labels_url":"https://api.github.com/repos/Genius/rails2/issues/2/labels{/name}","comments_url":"https://api.github.com/repos/Genius/rails2/issues/2/comments","events_url":"https://api.github.com/repos/Genius/rails2/issues/2/events","html_url":"https://github.com/Genius/rails2/pull/2","id":59843736,"number":2,"title":"Use double-ensure to prevent invalid scoped method state","user":{"login":"outoftime","id":14214,"avatar_url":"https://avatars.githubusercontent.com/u/14214?v=3","gravatar_id":"","url":"https://api.github.com/users/outoftime","html_url":"https://github.com/outoftime","followers_url":"https://api.github.com/users/outoftime/followers","following_url":"https://api.github.com/users/outoftime/following{/other_user}","gists_url":"https://api.github.com/users/outoftime/gists{/gist_id}","starred_url":"https://api.github.com/users/outoftime/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/outoftime/subscriptions","organizations_url":"https://api.github.com/users/outoftime/orgs","repos_url":"https://api.github.com/users/outoftime/repos","events_url":"https://api.github.com/users/outoftime/events{/privacy}","received_events_url":"https://api.github.com/users/outoftime/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-03-04T18:57:49Z","updated_at":"2015-03-04T18:58:56Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/Genius/rails2/pulls/2","html_url":"https://github.com/Genius/rails2/pull/2","diff_url":"https://github.com/Genius/rails2/pull/2.diff","patch_url":"https://github.com/Genius/rails2/pull/2.patch"},"body":"In the previous implementation, an exception (e.g. `Timeout::Error`) being thrown while line 2188 was executing would cause the thread-local `scoped_methods` to incorrectly retain the scope that was about to be cleared, for the life of the process.\r\n\r\nBy using a double-ensure, we can truly ensure that this does not happen. To wit:\r\n\r\n* If an exception occurs while line 2190 is executing, the outer `ensure` block will ensure that line 2193 runs\r\n* If an exception occurs while line 2193 is executing, the inner `ensure` block has already done the necessary work\r\n\r\nOf course, if two different thread exceptions take out both `ensure` blocks, we're still in trouble. But that is vanishingly unlikely."},"comment":{"url":"https://api.github.com/repos/Genius/rails2/issues/comments/77221675","html_url":"https://github.com/Genius/rails2/pull/2#issuecomment-77221675","issue_url":"https://api.github.com/repos/Genius/rails2/issues/2","id":77221675,"user":{"login":"outoftime","id":14214,"avatar_url":"https://avatars.githubusercontent.com/u/14214?v=3","gravatar_id":"","url":"https://api.github.com/users/outoftime","html_url":"https://github.com/outoftime","followers_url":"https://api.github.com/users/outoftime/followers","following_url":"https://api.github.com/users/outoftime/following{/other_user}","gists_url":"https://api.github.com/users/outoftime/gists{/gist_id}","starred_url":"https://api.github.com/users/outoftime/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/outoftime/subscriptions","organizations_url":"https://api.github.com/users/outoftime/orgs","repos_url":"https://api.github.com/users/outoftime/repos","events_url":"https://api.github.com/users/outoftime/events{/privacy}","received_events_url":"https://api.github.com/users/outoftime/received_events","type":"User","site_admin":false},"created_at":"2015-03-04T18:58:56Z","updated_at":"2015-03-04T18:58:56Z","body":"@a-warner WDYT?"}}