{"action":"created","comment":{"url":"https://api.github.com/repos/akka/akka/pulls/comments/60247968","id":60247968,"diff_hunk":"@@ -0,0 +1,140 @@\n+/**\n+ * Copyright (C) 2016 Lightbend Inc. <http://www.lightbend.com>\n+ */\n+package akka.actor\n+\n+import java.util.concurrent.atomic.AtomicInteger\n+\n+import akka.testkit.EventFilter\n+import akka.testkit.TestKit._\n+import com.typesafe.config.ConfigFactory\n+import org.scalatest.{Matchers, WordSpec}\n+import org.scalatest.junit.JUnitSuiteLike\n+\n+import scala.util.control.NoStackTrace\n+\n+\n+class JavaExtensionSpec extends JavaExtension with JUnitSuiteLike\n+\n+object TestExtension extends ExtensionId[TestExtension] with ExtensionIdProvider {\n+  def lookup = this\n+  def createExtension(s: ExtendedActorSystem) = new TestExtension(s)\n+}\n+\n+// Dont't place inside ActorSystemSpec object, since it will not be garbage collected and reference to system remains\n+class TestExtension(val system: ExtendedActorSystem) extends Extension\n+\n+object FailingTestExtension extends ExtensionId[FailingTestExtension] with ExtensionIdProvider {\n+  def lookup = this\n+  def createExtension(s: ExtendedActorSystem) = new FailingTestExtension(s)\n+\n+  class TestException extends IllegalArgumentException(\"ERR\") with NoStackTrace\n+}\n+\n+object InstanceCountingExtension extends ExtensionId[DummyExtensionImpl] with ExtensionIdProvider {\n+  val createCount = new AtomicInteger(0)\n+  override def createExtension(system: ExtendedActorSystem): DummyExtensionImpl = {\n+    createCount.addAndGet(1)\n+    new DummyExtensionImpl\n+  }\n+  override def lookup(): ExtensionId[_ <: Extension] = this\n+}\n+\n+class DummyExtensionImpl extends Extension\n+\n+// Dont't place inside ActorSystemSpec object, since it will not be garbage collected and reference to system remains\n+class FailingTestExtension(val system: ExtendedActorSystem) extends Extension {\n+  // first time the actor is created\n+  val ref = system.actorOf(Props.empty, \"uniqueName\")\n+  // but the extension initialization fails\n+  // second time it will throw exception when trying to create actor with same name,\n+  // but we want to see the first exception every time\n+  throw new FailingTestExtension.TestException\n+}\n+\n+\n+class ExtensionSpec extends WordSpec with Matchers {\n+\n+  \"The ActorSystem extensions support\" should {\n+\n+    \"support extensions\" in {\n+      val config = ConfigFactory.parseString(\"\"\"akka.extensions = [\"akka.actor.TestExtension\"]\"\"\")\n+      val system = ActorSystem(\"extensions\", config)\n+\n+      // TestExtension is configured and should be loaded at startup\n+      system.hasExtension(TestExtension) should ===(true)\n+      TestExtension(system).system should ===(system)\n+      system.extension(TestExtension).system should ===(system)\n+\n+      shutdownActorSystem(system)\n+    }\n+\n+    \"handle extensions that fail to initialize\" in {\n+      val system = ActorSystem(\"extensions\")\n+\n+      intercept[FailingTestExtension.TestException] {\n+        FailingTestExtension(system)\n+      }\n+      // same exception should be reported next time\n+      intercept[FailingTestExtension.TestException] {\n+        FailingTestExtension(system)\n+      }\n+\n+      shutdownActorSystem(system)\n+    }\n+\n+\n+    \"fail the actor system if an extension listed in akka.extensions fails to start\" in {\n+      intercept[RuntimeException]{\n+        val system = ActorSystem(\"failing\", ConfigFactory.parseString(\n+          \"\"\"\n+            akka.extensions = [\"akka.actor.FailingTestExtension\"]\n+          \"\"\"))\n+\n+        shutdownActorSystem(system)\n+      }\n+    }\n+\n+    \"log an error if an extension listed in akka.extensions cannot be loaded\" in {","path":"akka-actor-tests/src/test/scala/akka/actor/ExtensionSpec.scala","position":98,"original_position":98,"commit_id":"14c08df74a62c88e4d4cf84d624dce7726b81a4e","original_commit_id":"14c08df74a62c88e4d4cf84d624dce7726b81a4e","user":{"login":"patriknw","id":336161,"avatar_url":"https://avatars.githubusercontent.com/u/336161?v=3","gravatar_id":"","url":"https://api.github.com/users/patriknw","html_url":"https://github.com/patriknw","followers_url":"https://api.github.com/users/patriknw/followers","following_url":"https://api.github.com/users/patriknw/following{/other_user}","gists_url":"https://api.github.com/users/patriknw/gists{/gist_id}","starred_url":"https://api.github.com/users/patriknw/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/patriknw/subscriptions","organizations_url":"https://api.github.com/users/patriknw/orgs","repos_url":"https://api.github.com/users/patriknw/repos","events_url":"https://api.github.com/users/patriknw/events{/privacy}","received_events_url":"https://api.github.com/users/patriknw/received_events","type":"User","site_admin":false},"body":"I agree, but that's current behavior and I think that would be a bit dangerous to change in a patch release. For the the new library-extensions we fail.","created_at":"2016-04-19T15:03:33Z","updated_at":"2016-04-19T15:03:33Z","html_url":"https://github.com/akka/akka/pull/20333#discussion_r60247968","pull_request_url":"https://api.github.com/repos/akka/akka/pulls/20333","_links":{"self":{"href":"https://api.github.com/repos/akka/akka/pulls/comments/60247968"},"html":{"href":"https://github.com/akka/akka/pull/20333#discussion_r60247968"},"pull_request":{"href":"https://api.github.com/repos/akka/akka/pulls/20333"}}},"pull_request":{"url":"https://api.github.com/repos/akka/akka/pulls/20333","id":66640526,"html_url":"https://github.com/akka/akka/pull/20333","diff_url":"https://github.com/akka/akka/pull/20333.diff","patch_url":"https://github.com/akka/akka/pull/20333.patch","issue_url":"https://api.github.com/repos/akka/akka/issues/20333","number":20333,"state":"closed","locked":false,"title":"act #20332 Functionality to automatically load library extensions","user":{"login":"johanandren","id":666915,"avatar_url":"https://avatars.githubusercontent.com/u/666915?v=3","gravatar_id":"","url":"https://api.github.com/users/johanandren","html_url":"https://github.com/johanandren","followers_url":"https://api.github.com/users/johanandren/followers","following_url":"https://api.github.com/users/johanandren/following{/other_user}","gists_url":"https://api.github.com/users/johanandren/gists{/gist_id}","starred_url":"https://api.github.com/users/johanandren/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/johanandren/subscriptions","organizations_url":"https://api.github.com/users/johanandren/orgs","repos_url":"https://api.github.com/users/johanandren/repos","events_url":"https://api.github.com/users/johanandren/events{/privacy}","received_events_url":"https://api.github.com/users/johanandren/received_events","type":"User","site_admin":false},"body":"Refs #20332 ","created_at":"2016-04-15T13:16:04Z","updated_at":"2016-04-19T15:03:33Z","closed_at":"2016-04-19T13:16:55Z","merged_at":"2016-04-19T13:16:55Z","merge_commit_sha":"9af39f97baccaf148a7fe67143ebbca94b9177d4","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/akka/akka/pulls/20333/commits","review_comments_url":"https://api.github.com/repos/akka/akka/pulls/20333/comments","review_comment_url":"https://api.github.com/repos/akka/akka/pulls/comments{/number}","comments_url":"https://api.github.com/repos/akka/akka/issues/20333/comments","statuses_url":"https://api.github.com/repos/akka/akka/statuses/14c08df74a62c88e4d4cf84d624dce7726b81a4e","head":{"label":"johanandren:wip-20332-auto-load-library-extensions-johanandren","ref":"wip-20332-auto-load-library-extensions-johanandren","sha":"14c08df74a62c88e4d4cf84d624dce7726b81a4e","user":{"login":"johanandren","id":666915,"avatar_url":"https://avatars.githubusercontent.com/u/666915?v=3","gravatar_id":"","url":"https://api.github.com/users/johanandren","html_url":"https://github.com/johanandren","followers_url":"https://api.github.com/users/johanandren/followers","following_url":"https://api.github.com/users/johanandren/following{/other_user}","gists_url":"https://api.github.com/users/johanandren/gists{/gist_id}","starred_url":"https://api.github.com/users/johanandren/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/johanandren/subscriptions","organizations_url":"https://api.github.com/users/johanandren/orgs","repos_url":"https://api.github.com/users/johanandren/repos","events_url":"https://api.github.com/users/johanandren/events{/privacy}","received_events_url":"https://api.github.com/users/johanandren/received_events","type":"User","site_admin":false},"repo":{"id":41662207,"name":"akka","full_name":"johanandren/akka","owner":{"login":"johanandren","id":666915,"avatar_url":"https://avatars.githubusercontent.com/u/666915?v=3","gravatar_id":"","url":"https://api.github.com/users/johanandren","html_url":"https://github.com/johanandren","followers_url":"https://api.github.com/users/johanandren/followers","following_url":"https://api.github.com/users/johanandren/following{/other_user}","gists_url":"https://api.github.com/users/johanandren/gists{/gist_id}","starred_url":"https://api.github.com/users/johanandren/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/johanandren/subscriptions","organizations_url":"https://api.github.com/users/johanandren/orgs","repos_url":"https://api.github.com/users/johanandren/repos","events_url":"https://api.github.com/users/johanandren/events{/privacy}","received_events_url":"https://api.github.com/users/johanandren/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/johanandren/akka","description":"Akka Project","fork":true,"url":"https://api.github.com/repos/johanandren/akka","forks_url":"https://api.github.com/repos/johanandren/akka/forks","keys_url":"https://api.github.com/repos/johanandren/akka/keys{/key_id}","collaborators_url":"https://api.github.com/repos/johanandren/akka/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/johanandren/akka/teams","hooks_url":"https://api.github.com/repos/johanandren/akka/hooks","issue_events_url":"https://api.github.com/repos/johanandren/akka/issues/events{/number}","events_url":"https://api.github.com/repos/johanandren/akka/events","assignees_url":"https://api.github.com/repos/johanandren/akka/assignees{/user}","branches_url":"https://api.github.com/repos/johanandren/akka/branches{/branch}","tags_url":"https://api.github.com/repos/johanandren/akka/tags","blobs_url":"https://api.github.com/repos/johanandren/akka/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/johanandren/akka/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/johanandren/akka/git/refs{/sha}","trees_url":"https://api.github.com/repos/johanandren/akka/git/trees{/sha}","statuses_url":"https://api.github.com/repos/johanandren/akka/statuses/{sha}","languages_url":"https://api.github.com/repos/johanandren/akka/languages","stargazers_url":"https://api.github.com/repos/johanandren/akka/stargazers","contributors_url":"https://api.github.com/repos/johanandren/akka/contributors","subscribers_url":"https://api.github.com/repos/johanandren/akka/subscribers","subscription_url":"https://api.github.com/repos/johanandren/akka/subscription","commits_url":"https://api.github.com/repos/johanandren/akka/commits{/sha}","git_commits_url":"https://api.github.com/repos/johanandren/akka/git/commits{/sha}","comments_url":"https://api.github.com/repos/johanandren/akka/comments{/number}","issue_comment_url":"https://api.github.com/repos/johanandren/akka/issues/comments{/number}","contents_url":"https://api.github.com/repos/johanandren/akka/contents/{+path}","compare_url":"https://api.github.com/repos/johanandren/akka/compare/{base}...{head}","merges_url":"https://api.github.com/repos/johanandren/akka/merges","archive_url":"https://api.github.com/repos/johanandren/akka/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/johanandren/akka/downloads","issues_url":"https://api.github.com/repos/johanandren/akka/issues{/number}","pulls_url":"https://api.github.com/repos/johanandren/akka/pulls{/number}","milestones_url":"https://api.github.com/repos/johanandren/akka/milestones{/number}","notifications_url":"https://api.github.com/repos/johanandren/akka/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/johanandren/akka/labels{/name}","releases_url":"https://api.github.com/repos/johanandren/akka/releases{/id}","deployments_url":"https://api.github.com/repos/johanandren/akka/deployments","created_at":"2015-08-31T07:37:07Z","updated_at":"2016-02-02T08:15:23Z","pushed_at":"2016-04-19T13:19:35Z","git_url":"git://github.com/johanandren/akka.git","ssh_url":"git@github.com:johanandren/akka.git","clone_url":"https://github.com/johanandren/akka.git","svn_url":"https://github.com/johanandren/akka","homepage":"http://akka.io","size":192640,"stargazers_count":0,"watchers_count":0,"language":"Scala","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"akka:master","ref":"master","sha":"1c653b588d1fd601ac4a0e7c65a632c0a1cbad63","user":{"login":"akka","id":1496237,"avatar_url":"https://avatars.githubusercontent.com/u/1496237?v=3","gravatar_id":"","url":"https://api.github.com/users/akka","html_url":"https://github.com/akka","followers_url":"https://api.github.com/users/akka/followers","following_url":"https://api.github.com/users/akka/following{/other_user}","gists_url":"https://api.github.com/users/akka/gists{/gist_id}","starred_url":"https://api.github.com/users/akka/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/akka/subscriptions","organizations_url":"https://api.github.com/users/akka/orgs","repos_url":"https://api.github.com/users/akka/repos","events_url":"https://api.github.com/users/akka/events{/privacy}","received_events_url":"https://api.github.com/users/akka/received_events","type":"Organization","site_admin":false},"repo":{"id":130013,"name":"akka","full_name":"akka/akka","owner":{"login":"akka","id":1496237,"avatar_url":"https://avatars.githubusercontent.com/u/1496237?v=3","gravatar_id":"","url":"https://api.github.com/users/akka","html_url":"https://github.com/akka","followers_url":"https://api.github.com/users/akka/followers","following_url":"https://api.github.com/users/akka/following{/other_user}","gists_url":"https://api.github.com/users/akka/gists{/gist_id}","starred_url":"https://api.github.com/users/akka/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/akka/subscriptions","organizations_url":"https://api.github.com/users/akka/orgs","repos_url":"https://api.github.com/users/akka/repos","events_url":"https://api.github.com/users/akka/events{/privacy}","received_events_url":"https://api.github.com/users/akka/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/akka/akka","description":"Akka Project","fork":false,"url":"https://api.github.com/repos/akka/akka","forks_url":"https://api.github.com/repos/akka/akka/forks","keys_url":"https://api.github.com/repos/akka/akka/keys{/key_id}","collaborators_url":"https://api.github.com/repos/akka/akka/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/akka/akka/teams","hooks_url":"https://api.github.com/repos/akka/akka/hooks","issue_events_url":"https://api.github.com/repos/akka/akka/issues/events{/number}","events_url":"https://api.github.com/repos/akka/akka/events","assignees_url":"https://api.github.com/repos/akka/akka/assignees{/user}","branches_url":"https://api.github.com/repos/akka/akka/branches{/branch}","tags_url":"https://api.github.com/repos/akka/akka/tags","blobs_url":"https://api.github.com/repos/akka/akka/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/akka/akka/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/akka/akka/git/refs{/sha}","trees_url":"https://api.github.com/repos/akka/akka/git/trees{/sha}","statuses_url":"https://api.github.com/repos/akka/akka/statuses/{sha}","languages_url":"https://api.github.com/repos/akka/akka/languages","stargazers_url":"https://api.github.com/repos/akka/akka/stargazers","contributors_url":"https://api.github.com/repos/akka/akka/contributors","subscribers_url":"https://api.github.com/repos/akka/akka/subscribers","subscription_url":"https://api.github.com/repos/akka/akka/subscription","commits_url":"https://api.github.com/repos/akka/akka/commits{/sha}","git_commits_url":"https://api.github.com/repos/akka/akka/git/commits{/sha}","comments_url":"https://api.github.com/repos/akka/akka/comments{/number}","issue_comment_url":"https://api.github.com/repos/akka/akka/issues/comments{/number}","contents_url":"https://api.github.com/repos/akka/akka/contents/{+path}","compare_url":"https://api.github.com/repos/akka/akka/compare/{base}...{head}","merges_url":"https://api.github.com/repos/akka/akka/merges","archive_url":"https://api.github.com/repos/akka/akka/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/akka/akka/downloads","issues_url":"https://api.github.com/repos/akka/akka/issues{/number}","pulls_url":"https://api.github.com/repos/akka/akka/pulls{/number}","milestones_url":"https://api.github.com/repos/akka/akka/milestones{/number}","notifications_url":"https://api.github.com/repos/akka/akka/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/akka/akka/labels{/name}","releases_url":"https://api.github.com/repos/akka/akka/releases{/id}","deployments_url":"https://api.github.com/repos/akka/akka/deployments","created_at":"2009-02-16T12:51:54Z","updated_at":"2016-04-19T10:09:51Z","pushed_at":"2016-04-19T14:56:58Z","git_url":"git://github.com/akka/akka.git","ssh_url":"git@github.com:akka/akka.git","clone_url":"https://github.com/akka/akka.git","svn_url":"https://github.com/akka/akka","homepage":"http://akka.io","size":204610,"stargazers_count":5384,"watchers_count":5384,"language":"Scala","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":1678,"mirror_url":null,"open_issues_count":725,"forks":1678,"open_issues":725,"watchers":5384,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/akka/akka/pulls/20333"},"html":{"href":"https://github.com/akka/akka/pull/20333"},"issue":{"href":"https://api.github.com/repos/akka/akka/issues/20333"},"comments":{"href":"https://api.github.com/repos/akka/akka/issues/20333/comments"},"review_comments":{"href":"https://api.github.com/repos/akka/akka/pulls/20333/comments"},"review_comment":{"href":"https://api.github.com/repos/akka/akka/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/akka/akka/pulls/20333/commits"},"statuses":{"href":"https://api.github.com/repos/akka/akka/statuses/14c08df74a62c88e4d4cf84d624dce7726b81a4e"}}}}