{"action":"created","comment":{"url":"https://api.github.com/repos/Microsoft/java-debug/pulls/comments/157164718","pull_request_review_id":83727895,"id":157164718,"diff_hunk":"@@ -0,0 +1,59 @@\n+/*******************************************************************************\n+ * Copyright (c) 2017 Microsoft Corporation and others.\n+ * All rights reserved. This program and the accompanying materials\n+ * are made available under the terms of the Eclipse Public License v1.0\n+ * which accompanies this distribution, and is available at\n+ * http://www.eclipse.org/legal/epl-v10.html\n+ *\n+ * Contributors:\n+ *     Microsoft Corporation - initial API and implementation\n+ *******************************************************************************/\n+\n+package com.microsoft.java.debug.core.adapter;\n+\n+import java.util.Collections;\n+import java.util.HashMap;\n+import java.util.Map;\n+import java.util.concurrent.locks.ReentrantLock;\n+\n+import com.sun.jdi.IncompatibleThreadStateException;\n+import com.sun.jdi.StackFrame;\n+import com.sun.jdi.ThreadReference;\n+\n+public class LockableStackFrameManager implements ILockableStackFrameManager {\n+    private Map<Long, StackFrame[]> threadStackFrameMap = Collections.synchronizedMap(new HashMap<>());\n+    private Map<Long, ReentrantLock> locks = new HashMap<>();\n+\n+    @Override\n+    public DisposableReentrantLock<StackFrame> getLockedStackFrame(ThreadReference thread, int depth) {\n+        ReentrantLock lock = locks.computeIfAbsent(thread.uniqueID(), t -> new ReentrantLock());\n+        lock.lock();\n+        StackFrame sf = getStackFrame(thread, depth);","path":"com.microsoft.java.debug.core/src/main/java/com/microsoft/java/debug/core/adapter/LockableStackFrameManager.java","position":31,"original_position":31,"commit_id":"5d3efe924757e6ef1dc4c5f3af4e735b79a8564b","original_commit_id":"5d3efe924757e6ef1dc4c5f3af4e735b79a8564b","user":{"login":"akaroml","id":16755094,"avatar_url":"https://avatars2.githubusercontent.com/u/16755094?v=4","gravatar_id":"","url":"https://api.github.com/users/akaroml","html_url":"https://github.com/akaroml","followers_url":"https://api.github.com/users/akaroml/followers","following_url":"https://api.github.com/users/akaroml/following{/other_user}","gists_url":"https://api.github.com/users/akaroml/gists{/gist_id}","starred_url":"https://api.github.com/users/akaroml/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/akaroml/subscriptions","organizations_url":"https://api.github.com/users/akaroml/orgs","repos_url":"https://api.github.com/users/akaroml/repos","events_url":"https://api.github.com/users/akaroml/events{/privacy}","received_events_url":"https://api.github.com/users/akaroml/received_events","type":"User","site_admin":false},"body":"No need to call another function.\r\n```java\r\ntry {\r\n    StackFrame sf = threadStackFrameMap.get(thread.uniqueID())[depth];\r\n    return new LockedObject<>(sf, lock);\r\n} catch (WhatEverException) {\r\n    lock.unlock();\r\n    throw;\r\n}\r\n```\r\nThe caller needs to handle the exception. Real scenario - when a queued evaluation request wants to acquire stack frame that is popped right after an HCR.","created_at":"2017-12-15T10:13:06Z","updated_at":"2017-12-15T10:55:14Z","html_url":"https://github.com/Microsoft/java-debug/pull/131#discussion_r157164718","pull_request_url":"https://api.github.com/repos/Microsoft/java-debug/pulls/131","author_association":"MEMBER","_links":{"self":{"href":"https://api.github.com/repos/Microsoft/java-debug/pulls/comments/157164718"},"html":{"href":"https://github.com/Microsoft/java-debug/pull/131#discussion_r157164718"},"pull_request":{"href":"https://api.github.com/repos/Microsoft/java-debug/pulls/131"}}},"pull_request":{"url":"https://api.github.com/repos/Microsoft/java-debug/pulls/131","id":157990576,"html_url":"https://github.com/Microsoft/java-debug/pull/131","diff_url":"https://github.com/Microsoft/java-debug/pull/131.diff","patch_url":"https://github.com/Microsoft/java-debug/pull/131.patch","issue_url":"https://api.github.com/repos/Microsoft/java-debug/issues/131","number":131,"state":"open","locked":false,"title":"evaluation handler and stackframe proxy for handling InvalidStackFrameException","user":{"login":"andxu","id":17075863,"avatar_url":"https://avatars3.githubusercontent.com/u/17075863?v=4","gravatar_id":"","url":"https://api.github.com/users/andxu","html_url":"https://github.com/andxu","followers_url":"https://api.github.com/users/andxu/followers","following_url":"https://api.github.com/users/andxu/following{/other_user}","gists_url":"https://api.github.com/users/andxu/gists{/gist_id}","starred_url":"https://api.github.com/users/andxu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/andxu/subscriptions","organizations_url":"https://api.github.com/users/andxu/orgs","repos_url":"https://api.github.com/users/andxu/repos","events_url":"https://api.github.com/users/andxu/events{/privacy}","received_events_url":"https://api.github.com/users/andxu/received_events","type":"User","site_admin":false},"body":"","created_at":"2017-12-13T02:40:56Z","updated_at":"2017-12-15T10:55:14Z","closed_at":null,"merged_at":null,"merge_commit_sha":"31a0bccd31ea0f0f2a85afd03beab6dc6c2908f3","assignee":null,"assignees":[],"requested_reviewers":[],"milestone":null,"commits_url":"https://api.github.com/repos/Microsoft/java-debug/pulls/131/commits","review_comments_url":"https://api.github.com/repos/Microsoft/java-debug/pulls/131/comments","review_comment_url":"https://api.github.com/repos/Microsoft/java-debug/pulls/comments{/number}","comments_url":"https://api.github.com/repos/Microsoft/java-debug/issues/131/comments","statuses_url":"https://api.github.com/repos/Microsoft/java-debug/statuses/5d3efe924757e6ef1dc4c5f3af4e735b79a8564b","head":{"label":"Microsoft:andy_evaluate","ref":"andy_evaluate","sha":"5d3efe924757e6ef1dc4c5f3af4e735b79a8564b","user":{"login":"Microsoft","id":6154722,"avatar_url":"https://avatars2.githubusercontent.com/u/6154722?v=4","gravatar_id":"","url":"https://api.github.com/users/Microsoft","html_url":"https://github.com/Microsoft","followers_url":"https://api.github.com/users/Microsoft/followers","following_url":"https://api.github.com/users/Microsoft/following{/other_user}","gists_url":"https://api.github.com/users/Microsoft/gists{/gist_id}","starred_url":"https://api.github.com/users/Microsoft/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Microsoft/subscriptions","organizations_url":"https://api.github.com/users/Microsoft/orgs","repos_url":"https://api.github.com/users/Microsoft/repos","events_url":"https://api.github.com/users/Microsoft/events{/privacy}","received_events_url":"https://api.github.com/users/Microsoft/received_events","type":"Organization","site_admin":false},"repo":{"id":102583752,"name":"java-debug","full_name":"Microsoft/java-debug","owner":{"login":"Microsoft","id":6154722,"avatar_url":"https://avatars2.githubusercontent.com/u/6154722?v=4","gravatar_id":"","url":"https://api.github.com/users/Microsoft","html_url":"https://github.com/Microsoft","followers_url":"https://api.github.com/users/Microsoft/followers","following_url":"https://api.github.com/users/Microsoft/following{/other_user}","gists_url":"https://api.github.com/users/Microsoft/gists{/gist_id}","starred_url":"https://api.github.com/users/Microsoft/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Microsoft/subscriptions","organizations_url":"https://api.github.com/users/Microsoft/orgs","repos_url":"https://api.github.com/users/Microsoft/repos","events_url":"https://api.github.com/users/Microsoft/events{/privacy}","received_events_url":"https://api.github.com/users/Microsoft/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Microsoft/java-debug","description":"The debug server implementation for Java. It conforms to the debug protocol of Visual Studio Code.","fork":false,"url":"https://api.github.com/repos/Microsoft/java-debug","forks_url":"https://api.github.com/repos/Microsoft/java-debug/forks","keys_url":"https://api.github.com/repos/Microsoft/java-debug/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Microsoft/java-debug/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Microsoft/java-debug/teams","hooks_url":"https://api.github.com/repos/Microsoft/java-debug/hooks","issue_events_url":"https://api.github.com/repos/Microsoft/java-debug/issues/events{/number}","events_url":"https://api.github.com/repos/Microsoft/java-debug/events","assignees_url":"https://api.github.com/repos/Microsoft/java-debug/assignees{/user}","branches_url":"https://api.github.com/repos/Microsoft/java-debug/branches{/branch}","tags_url":"https://api.github.com/repos/Microsoft/java-debug/tags","blobs_url":"https://api.github.com/repos/Microsoft/java-debug/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Microsoft/java-debug/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Microsoft/java-debug/git/refs{/sha}","trees_url":"https://api.github.com/repos/Microsoft/java-debug/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Microsoft/java-debug/statuses/{sha}","languages_url":"https://api.github.com/repos/Microsoft/java-debug/languages","stargazers_url":"https://api.github.com/repos/Microsoft/java-debug/stargazers","contributors_url":"https://api.github.com/repos/Microsoft/java-debug/contributors","subscribers_url":"https://api.github.com/repos/Microsoft/java-debug/subscribers","subscription_url":"https://api.github.com/repos/Microsoft/java-debug/subscription","commits_url":"https://api.github.com/repos/Microsoft/java-debug/commits{/sha}","git_commits_url":"https://api.github.com/repos/Microsoft/java-debug/git/commits{/sha}","comments_url":"https://api.github.com/repos/Microsoft/java-debug/comments{/number}","issue_comment_url":"https://api.github.com/repos/Microsoft/java-debug/issues/comments{/number}","contents_url":"https://api.github.com/repos/Microsoft/java-debug/contents/{+path}","compare_url":"https://api.github.com/repos/Microsoft/java-debug/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Microsoft/java-debug/merges","archive_url":"https://api.github.com/repos/Microsoft/java-debug/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Microsoft/java-debug/downloads","issues_url":"https://api.github.com/repos/Microsoft/java-debug/issues{/number}","pulls_url":"https://api.github.com/repos/Microsoft/java-debug/pulls{/number}","milestones_url":"https://api.github.com/repos/Microsoft/java-debug/milestones{/number}","notifications_url":"https://api.github.com/repos/Microsoft/java-debug/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Microsoft/java-debug/labels{/name}","releases_url":"https://api.github.com/repos/Microsoft/java-debug/releases{/id}","deployments_url":"https://api.github.com/repos/Microsoft/java-debug/deployments","created_at":"2017-09-06T08:31:17Z","updated_at":"2017-12-14T02:22:14Z","pushed_at":"2017-12-15T09:04:07Z","git_url":"git://github.com/Microsoft/java-debug.git","ssh_url":"git@github.com:Microsoft/java-debug.git","clone_url":"https://github.com/Microsoft/java-debug.git","svn_url":"https://github.com/Microsoft/java-debug","homepage":"","size":760,"stargazers_count":35,"watchers_count":35,"language":"Java","has_issues":true,"has_projects":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":8,"mirror_url":null,"archived":false,"open_issues_count":14,"license":{"key":"epl-1.0","name":"Eclipse Public License 1.0","spdx_id":"EPL-1.0","url":"https://api.github.com/licenses/epl-1.0"},"forks":8,"open_issues":14,"watchers":35,"default_branch":"master"}},"base":{"label":"Microsoft:master","ref":"master","sha":"285040d515a8330f6c88efa54650465d2ee46e61","user":{"login":"Microsoft","id":6154722,"avatar_url":"https://avatars2.githubusercontent.com/u/6154722?v=4","gravatar_id":"","url":"https://api.github.com/users/Microsoft","html_url":"https://github.com/Microsoft","followers_url":"https://api.github.com/users/Microsoft/followers","following_url":"https://api.github.com/users/Microsoft/following{/other_user}","gists_url":"https://api.github.com/users/Microsoft/gists{/gist_id}","starred_url":"https://api.github.com/users/Microsoft/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Microsoft/subscriptions","organizations_url":"https://api.github.com/users/Microsoft/orgs","repos_url":"https://api.github.com/users/Microsoft/repos","events_url":"https://api.github.com/users/Microsoft/events{/privacy}","received_events_url":"https://api.github.com/users/Microsoft/received_events","type":"Organization","site_admin":false},"repo":{"id":102583752,"name":"java-debug","full_name":"Microsoft/java-debug","owner":{"login":"Microsoft","id":6154722,"avatar_url":"https://avatars2.githubusercontent.com/u/6154722?v=4","gravatar_id":"","url":"https://api.github.com/users/Microsoft","html_url":"https://github.com/Microsoft","followers_url":"https://api.github.com/users/Microsoft/followers","following_url":"https://api.github.com/users/Microsoft/following{/other_user}","gists_url":"https://api.github.com/users/Microsoft/gists{/gist_id}","starred_url":"https://api.github.com/users/Microsoft/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Microsoft/subscriptions","organizations_url":"https://api.github.com/users/Microsoft/orgs","repos_url":"https://api.github.com/users/Microsoft/repos","events_url":"https://api.github.com/users/Microsoft/events{/privacy}","received_events_url":"https://api.github.com/users/Microsoft/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Microsoft/java-debug","description":"The debug server implementation for Java. It conforms to the debug protocol of Visual Studio Code.","fork":false,"url":"https://api.github.com/repos/Microsoft/java-debug","forks_url":"https://api.github.com/repos/Microsoft/java-debug/forks","keys_url":"https://api.github.com/repos/Microsoft/java-debug/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Microsoft/java-debug/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Microsoft/java-debug/teams","hooks_url":"https://api.github.com/repos/Microsoft/java-debug/hooks","issue_events_url":"https://api.github.com/repos/Microsoft/java-debug/issues/events{/number}","events_url":"https://api.github.com/repos/Microsoft/java-debug/events","assignees_url":"https://api.github.com/repos/Microsoft/java-debug/assignees{/user}","branches_url":"https://api.github.com/repos/Microsoft/java-debug/branches{/branch}","tags_url":"https://api.github.com/repos/Microsoft/java-debug/tags","blobs_url":"https://api.github.com/repos/Microsoft/java-debug/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Microsoft/java-debug/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Microsoft/java-debug/git/refs{/sha}","trees_url":"https://api.github.com/repos/Microsoft/java-debug/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Microsoft/java-debug/statuses/{sha}","languages_url":"https://api.github.com/repos/Microsoft/java-debug/languages","stargazers_url":"https://api.github.com/repos/Microsoft/java-debug/stargazers","contributors_url":"https://api.github.com/repos/Microsoft/java-debug/contributors","subscribers_url":"https://api.github.com/repos/Microsoft/java-debug/subscribers","subscription_url":"https://api.github.com/repos/Microsoft/java-debug/subscription","commits_url":"https://api.github.com/repos/Microsoft/java-debug/commits{/sha}","git_commits_url":"https://api.github.com/repos/Microsoft/java-debug/git/commits{/sha}","comments_url":"https://api.github.com/repos/Microsoft/java-debug/comments{/number}","issue_comment_url":"https://api.github.com/repos/Microsoft/java-debug/issues/comments{/number}","contents_url":"https://api.github.com/repos/Microsoft/java-debug/contents/{+path}","compare_url":"https://api.github.com/repos/Microsoft/java-debug/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Microsoft/java-debug/merges","archive_url":"https://api.github.com/repos/Microsoft/java-debug/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Microsoft/java-debug/downloads","issues_url":"https://api.github.com/repos/Microsoft/java-debug/issues{/number}","pulls_url":"https://api.github.com/repos/Microsoft/java-debug/pulls{/number}","milestones_url":"https://api.github.com/repos/Microsoft/java-debug/milestones{/number}","notifications_url":"https://api.github.com/repos/Microsoft/java-debug/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Microsoft/java-debug/labels{/name}","releases_url":"https://api.github.com/repos/Microsoft/java-debug/releases{/id}","deployments_url":"https://api.github.com/repos/Microsoft/java-debug/deployments","created_at":"2017-09-06T08:31:17Z","updated_at":"2017-12-14T02:22:14Z","pushed_at":"2017-12-15T09:04:07Z","git_url":"git://github.com/Microsoft/java-debug.git","ssh_url":"git@github.com:Microsoft/java-debug.git","clone_url":"https://github.com/Microsoft/java-debug.git","svn_url":"https://github.com/Microsoft/java-debug","homepage":"","size":760,"stargazers_count":35,"watchers_count":35,"language":"Java","has_issues":true,"has_projects":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":8,"mirror_url":null,"archived":false,"open_issues_count":14,"license":{"key":"epl-1.0","name":"Eclipse Public License 1.0","spdx_id":"EPL-1.0","url":"https://api.github.com/licenses/epl-1.0"},"forks":8,"open_issues":14,"watchers":35,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/Microsoft/java-debug/pulls/131"},"html":{"href":"https://github.com/Microsoft/java-debug/pull/131"},"issue":{"href":"https://api.github.com/repos/Microsoft/java-debug/issues/131"},"comments":{"href":"https://api.github.com/repos/Microsoft/java-debug/issues/131/comments"},"review_comments":{"href":"https://api.github.com/repos/Microsoft/java-debug/pulls/131/comments"},"review_comment":{"href":"https://api.github.com/repos/Microsoft/java-debug/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/Microsoft/java-debug/pulls/131/commits"},"statuses":{"href":"https://api.github.com/repos/Microsoft/java-debug/statuses/5d3efe924757e6ef1dc4c5f3af4e735b79a8564b"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"akaroml"}}