{"action":"created","comment":{"url":"https://api.github.com/repos/netty/netty/pulls/comments/70714491","id":70714491,"diff_hunk":"@@ -0,0 +1,228 @@\n+/*\n+ * Copyright 2013 The Netty Project\n+ *\n+ * The Netty Project licenses this file to you under the Apache License,\n+ * version 2.0 (the \"License\"); you may not use this file except in compliance\n+ * with the License. You may obtain a copy of the License at:\n+ *\n+ *   http://www.apache.org/licenses/LICENSE-2.0\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, WITHOUT\n+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the\n+ * License for the specific language governing permissions and limitations\n+ * under the License.\n+ */\n+\n+package io.netty.util.concurrent;\n+\n+import org.junit.Test;\n+\n+import java.security.Permission;\n+import java.util.concurrent.atomic.AtomicInteger;\n+import java.util.concurrent.atomic.AtomicReference;\n+\n+import static org.hamcrest.CoreMatchers.equalTo;\n+import static org.hamcrest.MatcherAssert.assertThat;\n+import static org.junit.Assert.fail;\n+\n+public class DefaultThreadFactoryTest {\n+\n+    // test that ensures DefaultThreadGroup is not sticky about thread groups by default\n+    @Test\n+    public void testStickyThreadGroups() throws InterruptedException {\n+\n+        final AtomicReference<DefaultThreadFactory> factory = new AtomicReference<DefaultThreadFactory>();\n+        final AtomicReference<ThreadGroup> capturedGroup = new AtomicReference<ThreadGroup>();\n+        final AtomicReference<Thread.UncaughtExceptionHandler> capturedUh =\n+                new AtomicReference<Thread.UncaughtExceptionHandler>();\n+\n+        final ThreadGroup brother = new ThreadGroup(\"brother\");\n+\n+        final Thread first = new Thread(brother, new Runnable() {\n+            @Override\n+            public void run() {\n+                factory.set(new DefaultThreadFactory(this.getClass()));\n+            }\n+        });\n+        first.start();\n+        first.join();\n+\n+        final ThreadGroup sister = new ThreadGroup(\"sister\");\n+\n+        final Thread second = new Thread(sister, new Runnable() {\n+            @Override\n+            public void run() {\n+                final Thread t = factory.get().newThread(new Runnable() {\n+                    @Override\n+                    public void run() {\n+                        capturedGroup.set(Thread.currentThread().getThreadGroup());\n+                        capturedUh.set(Thread.currentThread().getUncaughtExceptionHandler());\n+                    }\n+                });\n+                t.start();\n+                try {\n+                    t.join();\n+                } catch (InterruptedException e) {\n+                    fail(e.toString());","path":"common/src/test/java/io/netty/util/concurrent/DefaultThreadFactoryTest.java","position":67,"original_position":67,"commit_id":"22b5674cf818058774af4867c6ed4c1df6472abc","original_commit_id":"22b5674cf818058774af4867c6ed4c1df6472abc","user":{"login":"jasontedor","id":4744941,"avatar_url":"https://avatars.githubusercontent.com/u/4744941?v=3","gravatar_id":"","url":"https://api.github.com/users/jasontedor","html_url":"https://github.com/jasontedor","followers_url":"https://api.github.com/users/jasontedor/followers","following_url":"https://api.github.com/users/jasontedor/following{/other_user}","gists_url":"https://api.github.com/users/jasontedor/gists{/gist_id}","starred_url":"https://api.github.com/users/jasontedor/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jasontedor/subscriptions","organizations_url":"https://api.github.com/users/jasontedor/orgs","repos_url":"https://api.github.com/users/jasontedor/repos","events_url":"https://api.github.com/users/jasontedor/events{/privacy}","received_events_url":"https://api.github.com/users/jasontedor/received_events","type":"User","site_admin":false},"body":"@Scottmitch Oh, I guess that means the Netty tests do not fail on *any* uncaught exception on *any* thread. I assumed that would be the case but I just verified that it does not. Sorry about that, I'm use to a test runner that attaches and uncaught exception handler to all tests and fails the test if there are any uncaught exceptions. I will push the change that you suggest.","created_at":"2016-07-13T21:42:47Z","updated_at":"2016-07-13T21:42:47Z","html_url":"https://github.com/netty/netty/pull/5533#discussion_r70714491","pull_request_url":"https://api.github.com/repos/netty/netty/pulls/5533","_links":{"self":{"href":"https://api.github.com/repos/netty/netty/pulls/comments/70714491"},"html":{"href":"https://github.com/netty/netty/pull/5533#discussion_r70714491"},"pull_request":{"href":"https://api.github.com/repos/netty/netty/pulls/5533"}}},"pull_request":{"url":"https://api.github.com/repos/netty/netty/pulls/5533","id":77346470,"html_url":"https://github.com/netty/netty/pull/5533","diff_url":"https://github.com/netty/netty/pull/5533.diff","patch_url":"https://github.com/netty/netty/pull/5533.patch","issue_url":"https://api.github.com/repos/netty/netty/issues/5533","number":5533,"state":"open","locked":false,"title":"Remove sticky thread group in DefaultThreadFactory","user":{"login":"jasontedor","id":4744941,"avatar_url":"https://avatars.githubusercontent.com/u/4744941?v=3","gravatar_id":"","url":"https://api.github.com/users/jasontedor","html_url":"https://github.com/jasontedor","followers_url":"https://api.github.com/users/jasontedor/followers","following_url":"https://api.github.com/users/jasontedor/following{/other_user}","gists_url":"https://api.github.com/users/jasontedor/gists{/gist_id}","starred_url":"https://api.github.com/users/jasontedor/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jasontedor/subscriptions","organizations_url":"https://api.github.com/users/jasontedor/orgs","repos_url":"https://api.github.com/users/jasontedor/repos","events_url":"https://api.github.com/users/jasontedor/events{/privacy}","received_events_url":"https://api.github.com/users/jasontedor/received_events","type":"User","site_admin":false},"body":"Motivation:\r\n\r\nA recent change to DefaultThreadFactory modified it so that it is sticky\r\nwith respect to thread groups. In particular, this change made it so\r\nthat DefaultThreadFactory would hold on to the thread group that created\r\nit, and then use that thread group to create threads.\r\n\r\nThis has problematic semantics since it violates a tenet of thread\r\ngroups that a thread can only modify threads in its own thread group and\r\ndescendant thread groups. With a sticky thread group, a thread\r\ntriggering the creation of a new thread via\r\nDefaultThreadFactory#newThread will be modifying a thread from the\r\nsticky thread group which will not necessarily be its own nor a\r\ndescendant thread group. When a security manager is in place that\r\nenforces this requirement, these modifications are now impossible. This\r\nis especially problematic in the context of Netty because certain global\r\nsingletons like GlobalEventExecutor will create a\r\nDefaultThreadFactory. If DefaultThreadFactory is sticky about thread\r\ngroups, it means that submitting tasks to the GlobalEventExecutor\r\nsingleton can cause a thread to be created from the DefaultThreadFactory\r\nsticky thread group, exactly the problem with DefaultThreadFactory being\r\nsticky about thread groups. A similar problem arises from the\r\nThreadDeathWatcher.\r\n\r\nModifications:\r\n\r\nThis commit undoes the modification to DefaultThreadFactory so that it\r\nis not sticky with respect to the thread group that created it.\r\n\r\nResult:\r\n\r\nDefaultThreadFactory will not be sticky about the thread group that led\r\nto its creation. Instead, threads created by a DefaultThreadFactory will\r\ninherit the default thread group which will either be the thread group\r\nfrom the security manager or the current thread's thread group.\r\n\r\nRelates #5084","created_at":"2016-07-13T19:24:29Z","updated_at":"2016-07-13T21:42:47Z","closed_at":null,"merged_at":null,"merge_commit_sha":"d0b69f35e284c253da7d31917852efe1fb23eedd","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/netty/netty/pulls/5533/commits","review_comments_url":"https://api.github.com/repos/netty/netty/pulls/5533/comments","review_comment_url":"https://api.github.com/repos/netty/netty/pulls/comments{/number}","comments_url":"https://api.github.com/repos/netty/netty/issues/5533/comments","statuses_url":"https://api.github.com/repos/netty/netty/statuses/22b5674cf818058774af4867c6ed4c1df6472abc","head":{"label":"jasontedor:default-thread-factory-sticky-thread-group","ref":"default-thread-factory-sticky-thread-group","sha":"22b5674cf818058774af4867c6ed4c1df6472abc","user":{"login":"jasontedor","id":4744941,"avatar_url":"https://avatars.githubusercontent.com/u/4744941?v=3","gravatar_id":"","url":"https://api.github.com/users/jasontedor","html_url":"https://github.com/jasontedor","followers_url":"https://api.github.com/users/jasontedor/followers","following_url":"https://api.github.com/users/jasontedor/following{/other_user}","gists_url":"https://api.github.com/users/jasontedor/gists{/gist_id}","starred_url":"https://api.github.com/users/jasontedor/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jasontedor/subscriptions","organizations_url":"https://api.github.com/users/jasontedor/orgs","repos_url":"https://api.github.com/users/jasontedor/repos","events_url":"https://api.github.com/users/jasontedor/events{/privacy}","received_events_url":"https://api.github.com/users/jasontedor/received_events","type":"User","site_admin":false},"repo":{"id":62667953,"name":"netty","full_name":"jasontedor/netty","owner":{"login":"jasontedor","id":4744941,"avatar_url":"https://avatars.githubusercontent.com/u/4744941?v=3","gravatar_id":"","url":"https://api.github.com/users/jasontedor","html_url":"https://github.com/jasontedor","followers_url":"https://api.github.com/users/jasontedor/followers","following_url":"https://api.github.com/users/jasontedor/following{/other_user}","gists_url":"https://api.github.com/users/jasontedor/gists{/gist_id}","starred_url":"https://api.github.com/users/jasontedor/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jasontedor/subscriptions","organizations_url":"https://api.github.com/users/jasontedor/orgs","repos_url":"https://api.github.com/users/jasontedor/repos","events_url":"https://api.github.com/users/jasontedor/events{/privacy}","received_events_url":"https://api.github.com/users/jasontedor/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/jasontedor/netty","description":"Netty project - an event-driven asynchronous network application framework","fork":true,"url":"https://api.github.com/repos/jasontedor/netty","forks_url":"https://api.github.com/repos/jasontedor/netty/forks","keys_url":"https://api.github.com/repos/jasontedor/netty/keys{/key_id}","collaborators_url":"https://api.github.com/repos/jasontedor/netty/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/jasontedor/netty/teams","hooks_url":"https://api.github.com/repos/jasontedor/netty/hooks","issue_events_url":"https://api.github.com/repos/jasontedor/netty/issues/events{/number}","events_url":"https://api.github.com/repos/jasontedor/netty/events","assignees_url":"https://api.github.com/repos/jasontedor/netty/assignees{/user}","branches_url":"https://api.github.com/repos/jasontedor/netty/branches{/branch}","tags_url":"https://api.github.com/repos/jasontedor/netty/tags","blobs_url":"https://api.github.com/repos/jasontedor/netty/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/jasontedor/netty/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/jasontedor/netty/git/refs{/sha}","trees_url":"https://api.github.com/repos/jasontedor/netty/git/trees{/sha}","statuses_url":"https://api.github.com/repos/jasontedor/netty/statuses/{sha}","languages_url":"https://api.github.com/repos/jasontedor/netty/languages","stargazers_url":"https://api.github.com/repos/jasontedor/netty/stargazers","contributors_url":"https://api.github.com/repos/jasontedor/netty/contributors","subscribers_url":"https://api.github.com/repos/jasontedor/netty/subscribers","subscription_url":"https://api.github.com/repos/jasontedor/netty/subscription","commits_url":"https://api.github.com/repos/jasontedor/netty/commits{/sha}","git_commits_url":"https://api.github.com/repos/jasontedor/netty/git/commits{/sha}","comments_url":"https://api.github.com/repos/jasontedor/netty/comments{/number}","issue_comment_url":"https://api.github.com/repos/jasontedor/netty/issues/comments{/number}","contents_url":"https://api.github.com/repos/jasontedor/netty/contents/{+path}","compare_url":"https://api.github.com/repos/jasontedor/netty/compare/{base}...{head}","merges_url":"https://api.github.com/repos/jasontedor/netty/merges","archive_url":"https://api.github.com/repos/jasontedor/netty/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/jasontedor/netty/downloads","issues_url":"https://api.github.com/repos/jasontedor/netty/issues{/number}","pulls_url":"https://api.github.com/repos/jasontedor/netty/pulls{/number}","milestones_url":"https://api.github.com/repos/jasontedor/netty/milestones{/number}","notifications_url":"https://api.github.com/repos/jasontedor/netty/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/jasontedor/netty/labels{/name}","releases_url":"https://api.github.com/repos/jasontedor/netty/releases{/id}","deployments_url":"https://api.github.com/repos/jasontedor/netty/deployments","created_at":"2016-07-05T20:36:42Z","updated_at":"2016-07-05T20:36:54Z","pushed_at":"2016-07-13T20:03:08Z","git_url":"git://github.com/jasontedor/netty.git","ssh_url":"git@github.com:jasontedor/netty.git","clone_url":"https://github.com/jasontedor/netty.git","svn_url":"https://github.com/jasontedor/netty","homepage":"http://netty.io/","size":41618,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"4.1"}},"base":{"label":"netty:4.1","ref":"4.1","sha":"771cfaec22248a52b97400e9b29522b94c7be536","user":{"login":"netty","id":473791,"avatar_url":"https://avatars.githubusercontent.com/u/473791?v=3","gravatar_id":"","url":"https://api.github.com/users/netty","html_url":"https://github.com/netty","followers_url":"https://api.github.com/users/netty/followers","following_url":"https://api.github.com/users/netty/following{/other_user}","gists_url":"https://api.github.com/users/netty/gists{/gist_id}","starred_url":"https://api.github.com/users/netty/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/netty/subscriptions","organizations_url":"https://api.github.com/users/netty/orgs","repos_url":"https://api.github.com/users/netty/repos","events_url":"https://api.github.com/users/netty/events{/privacy}","received_events_url":"https://api.github.com/users/netty/received_events","type":"Organization","site_admin":false},"repo":{"id":1064563,"name":"netty","full_name":"netty/netty","owner":{"login":"netty","id":473791,"avatar_url":"https://avatars.githubusercontent.com/u/473791?v=3","gravatar_id":"","url":"https://api.github.com/users/netty","html_url":"https://github.com/netty","followers_url":"https://api.github.com/users/netty/followers","following_url":"https://api.github.com/users/netty/following{/other_user}","gists_url":"https://api.github.com/users/netty/gists{/gist_id}","starred_url":"https://api.github.com/users/netty/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/netty/subscriptions","organizations_url":"https://api.github.com/users/netty/orgs","repos_url":"https://api.github.com/users/netty/repos","events_url":"https://api.github.com/users/netty/events{/privacy}","received_events_url":"https://api.github.com/users/netty/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/netty/netty","description":"Netty project - an event-driven asynchronous network application framework","fork":false,"url":"https://api.github.com/repos/netty/netty","forks_url":"https://api.github.com/repos/netty/netty/forks","keys_url":"https://api.github.com/repos/netty/netty/keys{/key_id}","collaborators_url":"https://api.github.com/repos/netty/netty/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/netty/netty/teams","hooks_url":"https://api.github.com/repos/netty/netty/hooks","issue_events_url":"https://api.github.com/repos/netty/netty/issues/events{/number}","events_url":"https://api.github.com/repos/netty/netty/events","assignees_url":"https://api.github.com/repos/netty/netty/assignees{/user}","branches_url":"https://api.github.com/repos/netty/netty/branches{/branch}","tags_url":"https://api.github.com/repos/netty/netty/tags","blobs_url":"https://api.github.com/repos/netty/netty/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/netty/netty/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/netty/netty/git/refs{/sha}","trees_url":"https://api.github.com/repos/netty/netty/git/trees{/sha}","statuses_url":"https://api.github.com/repos/netty/netty/statuses/{sha}","languages_url":"https://api.github.com/repos/netty/netty/languages","stargazers_url":"https://api.github.com/repos/netty/netty/stargazers","contributors_url":"https://api.github.com/repos/netty/netty/contributors","subscribers_url":"https://api.github.com/repos/netty/netty/subscribers","subscription_url":"https://api.github.com/repos/netty/netty/subscription","commits_url":"https://api.github.com/repos/netty/netty/commits{/sha}","git_commits_url":"https://api.github.com/repos/netty/netty/git/commits{/sha}","comments_url":"https://api.github.com/repos/netty/netty/comments{/number}","issue_comment_url":"https://api.github.com/repos/netty/netty/issues/comments{/number}","contents_url":"https://api.github.com/repos/netty/netty/contents/{+path}","compare_url":"https://api.github.com/repos/netty/netty/compare/{base}...{head}","merges_url":"https://api.github.com/repos/netty/netty/merges","archive_url":"https://api.github.com/repos/netty/netty/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/netty/netty/downloads","issues_url":"https://api.github.com/repos/netty/netty/issues{/number}","pulls_url":"https://api.github.com/repos/netty/netty/pulls{/number}","milestones_url":"https://api.github.com/repos/netty/netty/milestones{/number}","notifications_url":"https://api.github.com/repos/netty/netty/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/netty/netty/labels{/name}","releases_url":"https://api.github.com/repos/netty/netty/releases{/id}","deployments_url":"https://api.github.com/repos/netty/netty/deployments","created_at":"2010-11-09T09:22:21Z","updated_at":"2016-07-13T13:42:00Z","pushed_at":"2016-07-13T20:03:09Z","git_url":"git://github.com/netty/netty.git","ssh_url":"git@github.com:netty/netty.git","clone_url":"https://github.com/netty/netty.git","svn_url":"https://github.com/netty/netty","homepage":"http://netty.io/","size":70837,"stargazers_count":7304,"watchers_count":7304,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":3724,"mirror_url":null,"open_issues_count":316,"forks":3724,"open_issues":316,"watchers":7304,"default_branch":"4.1"}},"_links":{"self":{"href":"https://api.github.com/repos/netty/netty/pulls/5533"},"html":{"href":"https://github.com/netty/netty/pull/5533"},"issue":{"href":"https://api.github.com/repos/netty/netty/issues/5533"},"comments":{"href":"https://api.github.com/repos/netty/netty/issues/5533/comments"},"review_comments":{"href":"https://api.github.com/repos/netty/netty/pulls/5533/comments"},"review_comment":{"href":"https://api.github.com/repos/netty/netty/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/netty/netty/pulls/5533/commits"},"statuses":{"href":"https://api.github.com/repos/netty/netty/statuses/22b5674cf818058774af4867c6ed4c1df6472abc"}}}}
{"actor":{"display_login":"jasontedor"}}